7f7f938a0f6356acd000e00a2ad3aa43f624d75888b460ff94db9e3d85a5aadae78c8fec5c4657cd54e7a5eccc1c8d0f81a9e5a91396f0401b75ac02f4fc49 1.9 KB

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