@augment-vir/web
Version:
A collection of augments, helpers types, functions, and classes only for web (frontend) JavaScript environments.
20 lines (19 loc) • 735 B
JavaScript
import { DeclarativeElement } from 'element-vir';
import { ensureSpecTagName } from 'html-spec-tags';
/**
* Reduce an element down to its tag name or its element definition if it's a custom element defined
* by element-vir. Note that the types for this won't work in your project if you use custom element
* tag names that aren't generated via element-vir.
*
* @category Web : Elements
* @category Package : @augment-vir/web
* @package [`@augment-vir/web`](https://www.npmjs.com/package/@augment-vir/web)
*/
export function toTagOrDefinition(element) {
if (element instanceof DeclarativeElement) {
return element.definition;
}
else {
return ensureSpecTagName(element.tagName.toLowerCase());
}
}