domelementtype
Version:
all the types of nodes in htmlparser2's dom
61 lines (60 loc) • 2.22 kB
JavaScript
/** Types of elements found in htmlparser2's DOM */
export var ElementType;
(function (ElementType) {
/** Type for the root element of a document */
ElementType["Root"] = "root";
/** Type for Text */
ElementType["Text"] = "text";
/** Type for ... */
ElementType["Directive"] = "directive";
/** Type for <!-- ... --> */
ElementType["Comment"] = "comment";
/** Type for <script> tags */
ElementType["Script"] = "script";
/** Type for <style> tags */
ElementType["Style"] = "style";
/** Type for Any tag */
ElementType["Tag"] = "tag";
/** Type for <![CDATA[ ... ]]> */
ElementType["CDATA"] = "cdata";
/** Type for <!doctype ...> */
ElementType["Doctype"] = "doctype";
})(ElementType || (ElementType = {}));
/**
* Tests whether an element is a tag or not.
* @param element Element to test
* @param element.type Node type discriminator to check.
*/
export function isTag(element) {
return (element.type === ElementType.Tag ||
element.type === ElementType.Script ||
element.type === ElementType.Style);
}
// Exports for backwards compatibility
/** Type for the root element of a document */
// eslint-disable-next-line prefer-destructuring
export const Root = ElementType.Root;
/** Type for Text */
// eslint-disable-next-line prefer-destructuring
export const Text = ElementType.Text;
/** Type for ... */
// eslint-disable-next-line prefer-destructuring
export const Directive = ElementType.Directive;
/** Type for <!-- ... --> */
// eslint-disable-next-line prefer-destructuring
export const Comment = ElementType.Comment;
/** Type for <script> tags */
// eslint-disable-next-line prefer-destructuring
export const Script = ElementType.Script;
/** Type for <style> tags */
// eslint-disable-next-line prefer-destructuring
export const Style = ElementType.Style;
/** Type for Any tag */
// eslint-disable-next-line prefer-destructuring
export const Tag = ElementType.Tag;
/** Type for <![CDATA[ ... ]]> */
// eslint-disable-next-line prefer-destructuring
export const CDATA = ElementType.CDATA;
/** Type for */
// eslint-disable-next-line prefer-destructuring
export const Doctype = ElementType.Doctype;