cd9027e86eda97c4a9794aeb81ac0089007ecb6079024407c8610f648826e89d59bcd9319e9bab077ce5fa428344a20a2213ae819174a19bfe724add7d0ee4 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /** Types of elements found in htmlparser2's DOM */
  2. export var ElementType;
  3. (function (ElementType) {
  4. /** Type for the root element of a document */
  5. ElementType["Root"] = "root";
  6. /** Type for Text */
  7. ElementType["Text"] = "text";
  8. /** Type for <? ... ?> */
  9. ElementType["Directive"] = "directive";
  10. /** Type for <!-- ... --> */
  11. ElementType["Comment"] = "comment";
  12. /** Type for <script> tags */
  13. ElementType["Script"] = "script";
  14. /** Type for <style> tags */
  15. ElementType["Style"] = "style";
  16. /** Type for Any tag */
  17. ElementType["Tag"] = "tag";
  18. /** Type for <![CDATA[ ... ]]> */
  19. ElementType["CDATA"] = "cdata";
  20. /** Type for <!doctype ...> */
  21. ElementType["Doctype"] = "doctype";
  22. })(ElementType || (ElementType = {}));
  23. /**
  24. * Tests whether an element is a tag or not.
  25. *
  26. * @param elem Element to test
  27. */
  28. export function isTag(elem) {
  29. return (elem.type === ElementType.Tag ||
  30. elem.type === ElementType.Script ||
  31. elem.type === ElementType.Style);
  32. }
  33. // Exports for backwards compatibility
  34. /** Type for the root element of a document */
  35. export const Root = ElementType.Root;
  36. /** Type for Text */
  37. export const Text = ElementType.Text;
  38. /** Type for <? ... ?> */
  39. export const Directive = ElementType.Directive;
  40. /** Type for <!-- ... --> */
  41. export const Comment = ElementType.Comment;
  42. /** Type for <script> tags */
  43. export const Script = ElementType.Script;
  44. /** Type for <style> tags */
  45. export const Style = ElementType.Style;
  46. /** Type for Any tag */
  47. export const Tag = ElementType.Tag;
  48. /** Type for <![CDATA[ ... ]]> */
  49. export const CDATA = ElementType.CDATA;
  50. /** Type for <!doctype ...> */
  51. export const Doctype = ElementType.Doctype;