html-react-parser 1.4.12 → 1.4.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,9 +10,9 @@
10
10
 
11
11
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
12
12
 
13
- var htmlReactParser$1 = {exports: {}};
13
+ var htmlReactParser = {exports: {}};
14
14
 
15
- var lib$1 = {};
15
+ var lib$2 = {};
16
16
 
17
17
  var possibleStandardNamesOptimized$1 = {};
18
18
 
@@ -510,7 +510,7 @@
510
510
  zoomAndPan: 1
511
511
  };
512
512
 
513
- Object.defineProperty(lib$1, '__esModule', { value: true });
513
+ Object.defineProperty(lib$2, '__esModule', { value: true });
514
514
 
515
515
  function _slicedToArray(arr, i) {
516
516
  return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
@@ -815,16 +815,16 @@
815
815
  return accumulator;
816
816
  }, {});
817
817
 
818
- lib$1.BOOLEAN = BOOLEAN;
819
- lib$1.BOOLEANISH_STRING = BOOLEANISH_STRING;
820
- lib$1.NUMERIC = NUMERIC;
821
- lib$1.OVERLOADED_BOOLEAN = OVERLOADED_BOOLEAN;
822
- lib$1.POSITIVE_NUMERIC = POSITIVE_NUMERIC;
823
- lib$1.RESERVED = RESERVED;
824
- lib$1.STRING = STRING;
825
- lib$1.getPropertyInfo = getPropertyInfo;
826
- lib$1.isCustomAttribute = isCustomAttribute;
827
- lib$1.possibleStandardNames = possibleStandardNames;
818
+ lib$2.BOOLEAN = BOOLEAN;
819
+ lib$2.BOOLEANISH_STRING = BOOLEANISH_STRING;
820
+ lib$2.NUMERIC = NUMERIC;
821
+ lib$2.OVERLOADED_BOOLEAN = OVERLOADED_BOOLEAN;
822
+ lib$2.POSITIVE_NUMERIC = POSITIVE_NUMERIC;
823
+ lib$2.RESERVED = RESERVED;
824
+ lib$2.STRING = STRING;
825
+ lib$2.getPropertyInfo = getPropertyInfo;
826
+ lib$2.isCustomAttribute = isCustomAttribute;
827
+ lib$2.possibleStandardNames = possibleStandardNames;
828
828
 
829
829
  var cjs = {};
830
830
 
@@ -1160,26 +1160,26 @@
1160
1160
  utilities$4.camelCase = camelCase;
1161
1161
 
1162
1162
  (function (exports) {
1163
- var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
1164
- return (mod && mod.__esModule) ? mod : { "default": mod };
1165
- };
1166
- exports.__esModule = true;
1167
- var style_to_object_1 = __importDefault(styleToObject);
1168
- var utilities_1 = utilities$4;
1169
- function StyleToJS(style, options) {
1170
- var output = {};
1171
- if (!style || typeof style !== 'string') {
1172
- return output;
1173
- }
1174
- style_to_object_1["default"](style, function (property, value) {
1175
- if (property && value) {
1176
- output[utilities_1.camelCase(property, options)] = value;
1177
- }
1178
- });
1179
- return output;
1180
- }
1181
- exports["default"] = StyleToJS;
1182
- }(cjs));
1163
+ var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
1164
+ return (mod && mod.__esModule) ? mod : { "default": mod };
1165
+ };
1166
+ exports.__esModule = true;
1167
+ var style_to_object_1 = __importDefault(styleToObject);
1168
+ var utilities_1 = utilities$4;
1169
+ function StyleToJS(style, options) {
1170
+ var output = {};
1171
+ if (!style || typeof style !== 'string') {
1172
+ return output;
1173
+ }
1174
+ style_to_object_1["default"](style, function (property, value) {
1175
+ if (property && value) {
1176
+ output[utilities_1.camelCase(property, options)] = value;
1177
+ }
1178
+ });
1179
+ return output;
1180
+ }
1181
+ exports["default"] = StyleToJS;
1182
+ } (cjs));
1183
1183
 
1184
1184
  var React$1 = require$$0__default["default"];
1185
1185
  var styleToJS = cjs.default;
@@ -1312,7 +1312,7 @@
1312
1312
  elementsWithNoTextChildren: elementsWithNoTextChildren
1313
1313
  };
1314
1314
 
1315
- var reactProperty = lib$1;
1315
+ var reactProperty = lib$2;
1316
1316
  var utilities$2 = utilities$3;
1317
1317
 
1318
1318
  /**
@@ -1585,511 +1585,525 @@
1585
1585
 
1586
1586
  var node = {};
1587
1587
 
1588
- var lib = {};
1588
+ var lib$1 = {};
1589
1589
 
1590
- (function (exports) {
1591
- Object.defineProperty(exports, "__esModule", { value: true });
1592
- exports.Doctype = exports.CDATA = exports.Tag = exports.Style = exports.Script = exports.Comment = exports.Directive = exports.Text = exports.Root = exports.isTag = exports.ElementType = void 0;
1593
- /** Types of elements found in htmlparser2's DOM */
1594
- var ElementType;
1595
- (function (ElementType) {
1596
- /** Type for the root element of a document */
1597
- ElementType["Root"] = "root";
1598
- /** Type for Text */
1599
- ElementType["Text"] = "text";
1600
- /** Type for <? ... ?> */
1601
- ElementType["Directive"] = "directive";
1602
- /** Type for <!-- ... --> */
1603
- ElementType["Comment"] = "comment";
1604
- /** Type for <script> tags */
1605
- ElementType["Script"] = "script";
1606
- /** Type for <style> tags */
1607
- ElementType["Style"] = "style";
1608
- /** Type for Any tag */
1609
- ElementType["Tag"] = "tag";
1610
- /** Type for <![CDATA[ ... ]]> */
1611
- ElementType["CDATA"] = "cdata";
1612
- /** Type for <!doctype ...> */
1613
- ElementType["Doctype"] = "doctype";
1614
- })(ElementType = exports.ElementType || (exports.ElementType = {}));
1615
- /**
1616
- * Tests whether an element is a tag or not.
1617
- *
1618
- * @param elem Element to test
1619
- */
1620
- function isTag(elem) {
1621
- return (elem.type === ElementType.Tag ||
1622
- elem.type === ElementType.Script ||
1623
- elem.type === ElementType.Style);
1590
+ var hasRequiredLib$1;
1591
+
1592
+ function requireLib$1 () {
1593
+ if (hasRequiredLib$1) return lib$1;
1594
+ hasRequiredLib$1 = 1;
1595
+ (function (exports) {
1596
+ Object.defineProperty(exports, "__esModule", { value: true });
1597
+ exports.Doctype = exports.CDATA = exports.Tag = exports.Style = exports.Script = exports.Comment = exports.Directive = exports.Text = exports.Root = exports.isTag = exports.ElementType = void 0;
1598
+ /** Types of elements found in htmlparser2's DOM */
1599
+ var ElementType;
1600
+ (function (ElementType) {
1601
+ /** Type for the root element of a document */
1602
+ ElementType["Root"] = "root";
1603
+ /** Type for Text */
1604
+ ElementType["Text"] = "text";
1605
+ /** Type for <? ... ?> */
1606
+ ElementType["Directive"] = "directive";
1607
+ /** Type for <!-- ... --> */
1608
+ ElementType["Comment"] = "comment";
1609
+ /** Type for <script> tags */
1610
+ ElementType["Script"] = "script";
1611
+ /** Type for <style> tags */
1612
+ ElementType["Style"] = "style";
1613
+ /** Type for Any tag */
1614
+ ElementType["Tag"] = "tag";
1615
+ /** Type for <![CDATA[ ... ]]> */
1616
+ ElementType["CDATA"] = "cdata";
1617
+ /** Type for <!doctype ...> */
1618
+ ElementType["Doctype"] = "doctype";
1619
+ })(ElementType = exports.ElementType || (exports.ElementType = {}));
1620
+ /**
1621
+ * Tests whether an element is a tag or not.
1622
+ *
1623
+ * @param elem Element to test
1624
+ */
1625
+ function isTag(elem) {
1626
+ return (elem.type === ElementType.Tag ||
1627
+ elem.type === ElementType.Script ||
1628
+ elem.type === ElementType.Style);
1629
+ }
1630
+ exports.isTag = isTag;
1631
+ // Exports for backwards compatibility
1632
+ /** Type for the root element of a document */
1633
+ exports.Root = ElementType.Root;
1634
+ /** Type for Text */
1635
+ exports.Text = ElementType.Text;
1636
+ /** Type for <? ... ?> */
1637
+ exports.Directive = ElementType.Directive;
1638
+ /** Type for <!-- ... --> */
1639
+ exports.Comment = ElementType.Comment;
1640
+ /** Type for <script> tags */
1641
+ exports.Script = ElementType.Script;
1642
+ /** Type for <style> tags */
1643
+ exports.Style = ElementType.Style;
1644
+ /** Type for Any tag */
1645
+ exports.Tag = ElementType.Tag;
1646
+ /** Type for <![CDATA[ ... ]]> */
1647
+ exports.CDATA = ElementType.CDATA;
1648
+ /** Type for <!doctype ...> */
1649
+ exports.Doctype = ElementType.Doctype;
1650
+ } (lib$1));
1651
+ return lib$1;
1624
1652
  }
1625
- exports.isTag = isTag;
1626
- // Exports for backwards compatibility
1627
- /** Type for the root element of a document */
1628
- exports.Root = ElementType.Root;
1629
- /** Type for Text */
1630
- exports.Text = ElementType.Text;
1631
- /** Type for <? ... ?> */
1632
- exports.Directive = ElementType.Directive;
1633
- /** Type for <!-- ... --> */
1634
- exports.Comment = ElementType.Comment;
1635
- /** Type for <script> tags */
1636
- exports.Script = ElementType.Script;
1637
- /** Type for <style> tags */
1638
- exports.Style = ElementType.Style;
1639
- /** Type for Any tag */
1640
- exports.Tag = ElementType.Tag;
1641
- /** Type for <![CDATA[ ... ]]> */
1642
- exports.CDATA = ElementType.CDATA;
1643
- /** Type for <!doctype ...> */
1644
- exports.Doctype = ElementType.Doctype;
1645
- }(lib));
1646
-
1647
- var __extends = (commonjsGlobal && commonjsGlobal.__extends) || (function () {
1648
- var extendStatics = function (d, b) {
1649
- extendStatics = Object.setPrototypeOf ||
1650
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
1651
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
1652
- return extendStatics(d, b);
1653
- };
1654
- return function (d, b) {
1655
- if (typeof b !== "function" && b !== null)
1656
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
1657
- extendStatics(d, b);
1658
- function __() { this.constructor = d; }
1659
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
1660
- };
1661
- })();
1662
- var __assign = (commonjsGlobal && commonjsGlobal.__assign) || function () {
1663
- __assign = Object.assign || function(t) {
1664
- for (var s, i = 1, n = arguments.length; i < n; i++) {
1665
- s = arguments[i];
1666
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
1667
- t[p] = s[p];
1668
- }
1669
- return t;
1670
- };
1671
- return __assign.apply(this, arguments);
1672
- };
1673
- Object.defineProperty(node, "__esModule", { value: true });
1674
- node.cloneNode = node.hasChildren = node.isDocument = node.isDirective = node.isComment = node.isText = node.isCDATA = node.isTag = node.Element = node.Document = node.NodeWithChildren = node.ProcessingInstruction = node.Comment = node.Text = node.DataNode = node.Node = void 0;
1675
- var domelementtype_1 = lib;
1676
- var nodeTypes = new Map([
1677
- [domelementtype_1.ElementType.Tag, 1],
1678
- [domelementtype_1.ElementType.Script, 1],
1679
- [domelementtype_1.ElementType.Style, 1],
1680
- [domelementtype_1.ElementType.Directive, 1],
1681
- [domelementtype_1.ElementType.Text, 3],
1682
- [domelementtype_1.ElementType.CDATA, 4],
1683
- [domelementtype_1.ElementType.Comment, 8],
1684
- [domelementtype_1.ElementType.Root, 9],
1685
- ]);
1686
- /**
1687
- * This object will be used as the prototype for Nodes when creating a
1688
- * DOM-Level-1-compliant structure.
1689
- */
1690
- var Node = /** @class */ (function () {
1691
- /**
1692
- *
1693
- * @param type The type of the node.
1694
- */
1695
- function Node(type) {
1696
- this.type = type;
1697
- /** Parent of the node */
1698
- this.parent = null;
1699
- /** Previous sibling */
1700
- this.prev = null;
1701
- /** Next sibling */
1702
- this.next = null;
1703
- /** The start index of the node. Requires `withStartIndices` on the handler to be `true. */
1704
- this.startIndex = null;
1705
- /** The end index of the node. Requires `withEndIndices` on the handler to be `true. */
1706
- this.endIndex = null;
1707
- }
1708
- Object.defineProperty(Node.prototype, "nodeType", {
1709
- // Read-only aliases
1710
- /**
1711
- * [DOM spec](https://dom.spec.whatwg.org/#dom-node-nodetype)-compatible
1712
- * node {@link type}.
1713
- */
1714
- get: function () {
1715
- var _a;
1716
- return (_a = nodeTypes.get(this.type)) !== null && _a !== void 0 ? _a : 1;
1717
- },
1718
- enumerable: false,
1719
- configurable: true
1720
- });
1721
- Object.defineProperty(Node.prototype, "parentNode", {
1722
- // Read-write aliases for properties
1723
- /**
1724
- * Same as {@link parent}.
1725
- * [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
1726
- */
1727
- get: function () {
1728
- return this.parent;
1729
- },
1730
- set: function (parent) {
1731
- this.parent = parent;
1732
- },
1733
- enumerable: false,
1734
- configurable: true
1735
- });
1736
- Object.defineProperty(Node.prototype, "previousSibling", {
1737
- /**
1738
- * Same as {@link prev}.
1739
- * [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
1740
- */
1741
- get: function () {
1742
- return this.prev;
1743
- },
1744
- set: function (prev) {
1745
- this.prev = prev;
1746
- },
1747
- enumerable: false,
1748
- configurable: true
1749
- });
1750
- Object.defineProperty(Node.prototype, "nextSibling", {
1751
- /**
1752
- * Same as {@link next}.
1753
- * [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
1754
- */
1755
- get: function () {
1756
- return this.next;
1757
- },
1758
- set: function (next) {
1759
- this.next = next;
1760
- },
1761
- enumerable: false,
1762
- configurable: true
1763
- });
1764
- /**
1765
- * Clone this node, and optionally its children.
1766
- *
1767
- * @param recursive Clone child nodes as well.
1768
- * @returns A clone of the node.
1769
- */
1770
- Node.prototype.cloneNode = function (recursive) {
1771
- if (recursive === void 0) { recursive = false; }
1772
- return cloneNode(this, recursive);
1773
- };
1774
- return Node;
1775
- }());
1776
- node.Node = Node;
1777
- /**
1778
- * A node that contains some data.
1779
- */
1780
- var DataNode = /** @class */ (function (_super) {
1781
- __extends(DataNode, _super);
1782
- /**
1783
- * @param type The type of the node
1784
- * @param data The content of the data node
1785
- */
1786
- function DataNode(type, data) {
1787
- var _this = _super.call(this, type) || this;
1788
- _this.data = data;
1789
- return _this;
1790
- }
1791
- Object.defineProperty(DataNode.prototype, "nodeValue", {
1792
- /**
1793
- * Same as {@link data}.
1794
- * [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
1795
- */
1796
- get: function () {
1797
- return this.data;
1798
- },
1799
- set: function (data) {
1800
- this.data = data;
1801
- },
1802
- enumerable: false,
1803
- configurable: true
1804
- });
1805
- return DataNode;
1806
- }(Node));
1807
- node.DataNode = DataNode;
1808
- /**
1809
- * Text within the document.
1810
- */
1811
- var Text$1 = /** @class */ (function (_super) {
1812
- __extends(Text, _super);
1813
- function Text(data) {
1814
- return _super.call(this, domelementtype_1.ElementType.Text, data) || this;
1815
- }
1816
- return Text;
1817
- }(DataNode));
1818
- node.Text = Text$1;
1819
- /**
1820
- * Comments within the document.
1821
- */
1822
- var Comment$1 = /** @class */ (function (_super) {
1823
- __extends(Comment, _super);
1824
- function Comment(data) {
1825
- return _super.call(this, domelementtype_1.ElementType.Comment, data) || this;
1826
- }
1827
- return Comment;
1828
- }(DataNode));
1829
- node.Comment = Comment$1;
1830
- /**
1831
- * Processing instructions, including doc types.
1832
- */
1833
- var ProcessingInstruction$1 = /** @class */ (function (_super) {
1834
- __extends(ProcessingInstruction, _super);
1835
- function ProcessingInstruction(name, data) {
1836
- var _this = _super.call(this, domelementtype_1.ElementType.Directive, data) || this;
1837
- _this.name = name;
1838
- return _this;
1839
- }
1840
- return ProcessingInstruction;
1841
- }(DataNode));
1842
- node.ProcessingInstruction = ProcessingInstruction$1;
1843
- /**
1844
- * A `Node` that can have children.
1845
- */
1846
- var NodeWithChildren = /** @class */ (function (_super) {
1847
- __extends(NodeWithChildren, _super);
1848
- /**
1849
- * @param type Type of the node.
1850
- * @param children Children of the node. Only certain node types can have children.
1851
- */
1852
- function NodeWithChildren(type, children) {
1853
- var _this = _super.call(this, type) || this;
1854
- _this.children = children;
1855
- return _this;
1856
- }
1857
- Object.defineProperty(NodeWithChildren.prototype, "firstChild", {
1858
- // Aliases
1859
- /** First child of the node. */
1860
- get: function () {
1861
- var _a;
1862
- return (_a = this.children[0]) !== null && _a !== void 0 ? _a : null;
1863
- },
1864
- enumerable: false,
1865
- configurable: true
1866
- });
1867
- Object.defineProperty(NodeWithChildren.prototype, "lastChild", {
1868
- /** Last child of the node. */
1869
- get: function () {
1870
- return this.children.length > 0
1871
- ? this.children[this.children.length - 1]
1872
- : null;
1873
- },
1874
- enumerable: false,
1875
- configurable: true
1876
- });
1877
- Object.defineProperty(NodeWithChildren.prototype, "childNodes", {
1878
- /**
1879
- * Same as {@link children}.
1880
- * [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
1881
- */
1882
- get: function () {
1883
- return this.children;
1884
- },
1885
- set: function (children) {
1886
- this.children = children;
1887
- },
1888
- enumerable: false,
1889
- configurable: true
1890
- });
1891
- return NodeWithChildren;
1892
- }(Node));
1893
- node.NodeWithChildren = NodeWithChildren;
1894
- /**
1895
- * The root node of the document.
1896
- */
1897
- var Document = /** @class */ (function (_super) {
1898
- __extends(Document, _super);
1899
- function Document(children) {
1900
- return _super.call(this, domelementtype_1.ElementType.Root, children) || this;
1901
- }
1902
- return Document;
1903
- }(NodeWithChildren));
1904
- node.Document = Document;
1905
- /**
1906
- * An element within the DOM.
1907
- */
1908
- var Element$1 = /** @class */ (function (_super) {
1909
- __extends(Element, _super);
1910
- /**
1911
- * @param name Name of the tag, eg. `div`, `span`.
1912
- * @param attribs Object mapping attribute names to attribute values.
1913
- * @param children Children of the node.
1914
- */
1915
- function Element(name, attribs, children, type) {
1916
- if (children === void 0) { children = []; }
1917
- if (type === void 0) { type = name === "script"
1918
- ? domelementtype_1.ElementType.Script
1919
- : name === "style"
1920
- ? domelementtype_1.ElementType.Style
1921
- : domelementtype_1.ElementType.Tag; }
1922
- var _this = _super.call(this, type, children) || this;
1923
- _this.name = name;
1924
- _this.attribs = attribs;
1925
- return _this;
1926
- }
1927
- Object.defineProperty(Element.prototype, "tagName", {
1928
- // DOM Level 1 aliases
1929
- /**
1930
- * Same as {@link name}.
1931
- * [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
1932
- */
1933
- get: function () {
1934
- return this.name;
1935
- },
1936
- set: function (name) {
1937
- this.name = name;
1938
- },
1939
- enumerable: false,
1940
- configurable: true
1941
- });
1942
- Object.defineProperty(Element.prototype, "attributes", {
1943
- get: function () {
1944
- var _this = this;
1945
- return Object.keys(this.attribs).map(function (name) {
1946
- var _a, _b;
1947
- return ({
1948
- name: name,
1949
- value: _this.attribs[name],
1950
- namespace: (_a = _this["x-attribsNamespace"]) === null || _a === void 0 ? void 0 : _a[name],
1951
- prefix: (_b = _this["x-attribsPrefix"]) === null || _b === void 0 ? void 0 : _b[name],
1952
- });
1953
- });
1954
- },
1955
- enumerable: false,
1956
- configurable: true
1957
- });
1958
- return Element;
1959
- }(NodeWithChildren));
1960
- node.Element = Element$1;
1961
- /**
1962
- * @param node Node to check.
1963
- * @returns `true` if the node is a `Element`, `false` otherwise.
1964
- */
1965
- function isTag(node) {
1966
- return (0, domelementtype_1.isTag)(node);
1967
- }
1968
- node.isTag = isTag;
1969
- /**
1970
- * @param node Node to check.
1971
- * @returns `true` if the node has the type `CDATA`, `false` otherwise.
1972
- */
1973
- function isCDATA(node) {
1974
- return node.type === domelementtype_1.ElementType.CDATA;
1975
- }
1976
- node.isCDATA = isCDATA;
1977
- /**
1978
- * @param node Node to check.
1979
- * @returns `true` if the node has the type `Text`, `false` otherwise.
1980
- */
1981
- function isText(node) {
1982
- return node.type === domelementtype_1.ElementType.Text;
1983
- }
1984
- node.isText = isText;
1985
- /**
1986
- * @param node Node to check.
1987
- * @returns `true` if the node has the type `Comment`, `false` otherwise.
1988
- */
1989
- function isComment(node) {
1990
- return node.type === domelementtype_1.ElementType.Comment;
1991
- }
1992
- node.isComment = isComment;
1993
- /**
1994
- * @param node Node to check.
1995
- * @returns `true` if the node has the type `ProcessingInstruction`, `false` otherwise.
1996
- */
1997
- function isDirective(node) {
1998
- return node.type === domelementtype_1.ElementType.Directive;
1999
- }
2000
- node.isDirective = isDirective;
2001
- /**
2002
- * @param node Node to check.
2003
- * @returns `true` if the node has the type `ProcessingInstruction`, `false` otherwise.
2004
- */
2005
- function isDocument(node) {
2006
- return node.type === domelementtype_1.ElementType.Root;
2007
- }
2008
- node.isDocument = isDocument;
2009
- /**
2010
- * @param node Node to check.
2011
- * @returns `true` if the node is a `NodeWithChildren` (has children), `false` otherwise.
2012
- */
2013
- function hasChildren(node) {
2014
- return Object.prototype.hasOwnProperty.call(node, "children");
2015
- }
2016
- node.hasChildren = hasChildren;
2017
- /**
2018
- * Clone a node, and optionally its children.
2019
- *
2020
- * @param recursive Clone child nodes as well.
2021
- * @returns A clone of the node.
2022
- */
2023
- function cloneNode(node, recursive) {
2024
- if (recursive === void 0) { recursive = false; }
2025
- var result;
2026
- if (isText(node)) {
2027
- result = new Text$1(node.data);
2028
- }
2029
- else if (isComment(node)) {
2030
- result = new Comment$1(node.data);
2031
- }
2032
- else if (isTag(node)) {
2033
- var children = recursive ? cloneChildren(node.children) : [];
2034
- var clone_1 = new Element$1(node.name, __assign({}, node.attribs), children);
2035
- children.forEach(function (child) { return (child.parent = clone_1); });
2036
- if (node.namespace != null) {
2037
- clone_1.namespace = node.namespace;
2038
- }
2039
- if (node["x-attribsNamespace"]) {
2040
- clone_1["x-attribsNamespace"] = __assign({}, node["x-attribsNamespace"]);
2041
- }
2042
- if (node["x-attribsPrefix"]) {
2043
- clone_1["x-attribsPrefix"] = __assign({}, node["x-attribsPrefix"]);
2044
- }
2045
- result = clone_1;
2046
- }
2047
- else if (isCDATA(node)) {
2048
- var children = recursive ? cloneChildren(node.children) : [];
2049
- var clone_2 = new NodeWithChildren(domelementtype_1.ElementType.CDATA, children);
2050
- children.forEach(function (child) { return (child.parent = clone_2); });
2051
- result = clone_2;
2052
- }
2053
- else if (isDocument(node)) {
2054
- var children = recursive ? cloneChildren(node.children) : [];
2055
- var clone_3 = new Document(children);
2056
- children.forEach(function (child) { return (child.parent = clone_3); });
2057
- if (node["x-mode"]) {
2058
- clone_3["x-mode"] = node["x-mode"];
2059
- }
2060
- result = clone_3;
2061
- }
2062
- else if (isDirective(node)) {
2063
- var instruction = new ProcessingInstruction$1(node.name, node.data);
2064
- if (node["x-name"] != null) {
2065
- instruction["x-name"] = node["x-name"];
2066
- instruction["x-publicId"] = node["x-publicId"];
2067
- instruction["x-systemId"] = node["x-systemId"];
2068
- }
2069
- result = instruction;
2070
- }
2071
- else {
2072
- throw new Error("Not implemented yet: ".concat(node.type));
2073
- }
2074
- result.startIndex = node.startIndex;
2075
- result.endIndex = node.endIndex;
2076
- if (node.sourceCodeLocation != null) {
2077
- result.sourceCodeLocation = node.sourceCodeLocation;
2078
- }
2079
- return result;
2080
- }
2081
- node.cloneNode = cloneNode;
2082
- function cloneChildren(childs) {
2083
- var children = childs.map(function (child) { return cloneNode(child, true); });
2084
- for (var i = 1; i < children.length; i++) {
2085
- children[i].prev = children[i - 1];
2086
- children[i - 1].next = children[i];
2087
- }
2088
- return children;
1653
+
1654
+ var hasRequiredNode;
1655
+
1656
+ function requireNode () {
1657
+ if (hasRequiredNode) return node;
1658
+ hasRequiredNode = 1;
1659
+ var __extends = (commonjsGlobal && commonjsGlobal.__extends) || (function () {
1660
+ var extendStatics = function (d, b) {
1661
+ extendStatics = Object.setPrototypeOf ||
1662
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
1663
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
1664
+ return extendStatics(d, b);
1665
+ };
1666
+ return function (d, b) {
1667
+ if (typeof b !== "function" && b !== null)
1668
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
1669
+ extendStatics(d, b);
1670
+ function __() { this.constructor = d; }
1671
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
1672
+ };
1673
+ })();
1674
+ var __assign = (commonjsGlobal && commonjsGlobal.__assign) || function () {
1675
+ __assign = Object.assign || function(t) {
1676
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
1677
+ s = arguments[i];
1678
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
1679
+ t[p] = s[p];
1680
+ }
1681
+ return t;
1682
+ };
1683
+ return __assign.apply(this, arguments);
1684
+ };
1685
+ Object.defineProperty(node, "__esModule", { value: true });
1686
+ node.cloneNode = node.hasChildren = node.isDocument = node.isDirective = node.isComment = node.isText = node.isCDATA = node.isTag = node.Element = node.Document = node.NodeWithChildren = node.ProcessingInstruction = node.Comment = node.Text = node.DataNode = node.Node = void 0;
1687
+ var domelementtype_1 = requireLib$1();
1688
+ var nodeTypes = new Map([
1689
+ [domelementtype_1.ElementType.Tag, 1],
1690
+ [domelementtype_1.ElementType.Script, 1],
1691
+ [domelementtype_1.ElementType.Style, 1],
1692
+ [domelementtype_1.ElementType.Directive, 1],
1693
+ [domelementtype_1.ElementType.Text, 3],
1694
+ [domelementtype_1.ElementType.CDATA, 4],
1695
+ [domelementtype_1.ElementType.Comment, 8],
1696
+ [domelementtype_1.ElementType.Root, 9],
1697
+ ]);
1698
+ /**
1699
+ * This object will be used as the prototype for Nodes when creating a
1700
+ * DOM-Level-1-compliant structure.
1701
+ */
1702
+ var Node = /** @class */ (function () {
1703
+ /**
1704
+ *
1705
+ * @param type The type of the node.
1706
+ */
1707
+ function Node(type) {
1708
+ this.type = type;
1709
+ /** Parent of the node */
1710
+ this.parent = null;
1711
+ /** Previous sibling */
1712
+ this.prev = null;
1713
+ /** Next sibling */
1714
+ this.next = null;
1715
+ /** The start index of the node. Requires `withStartIndices` on the handler to be `true. */
1716
+ this.startIndex = null;
1717
+ /** The end index of the node. Requires `withEndIndices` on the handler to be `true. */
1718
+ this.endIndex = null;
1719
+ }
1720
+ Object.defineProperty(Node.prototype, "nodeType", {
1721
+ // Read-only aliases
1722
+ /**
1723
+ * [DOM spec](https://dom.spec.whatwg.org/#dom-node-nodetype)-compatible
1724
+ * node {@link type}.
1725
+ */
1726
+ get: function () {
1727
+ var _a;
1728
+ return (_a = nodeTypes.get(this.type)) !== null && _a !== void 0 ? _a : 1;
1729
+ },
1730
+ enumerable: false,
1731
+ configurable: true
1732
+ });
1733
+ Object.defineProperty(Node.prototype, "parentNode", {
1734
+ // Read-write aliases for properties
1735
+ /**
1736
+ * Same as {@link parent}.
1737
+ * [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
1738
+ */
1739
+ get: function () {
1740
+ return this.parent;
1741
+ },
1742
+ set: function (parent) {
1743
+ this.parent = parent;
1744
+ },
1745
+ enumerable: false,
1746
+ configurable: true
1747
+ });
1748
+ Object.defineProperty(Node.prototype, "previousSibling", {
1749
+ /**
1750
+ * Same as {@link prev}.
1751
+ * [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
1752
+ */
1753
+ get: function () {
1754
+ return this.prev;
1755
+ },
1756
+ set: function (prev) {
1757
+ this.prev = prev;
1758
+ },
1759
+ enumerable: false,
1760
+ configurable: true
1761
+ });
1762
+ Object.defineProperty(Node.prototype, "nextSibling", {
1763
+ /**
1764
+ * Same as {@link next}.
1765
+ * [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
1766
+ */
1767
+ get: function () {
1768
+ return this.next;
1769
+ },
1770
+ set: function (next) {
1771
+ this.next = next;
1772
+ },
1773
+ enumerable: false,
1774
+ configurable: true
1775
+ });
1776
+ /**
1777
+ * Clone this node, and optionally its children.
1778
+ *
1779
+ * @param recursive Clone child nodes as well.
1780
+ * @returns A clone of the node.
1781
+ */
1782
+ Node.prototype.cloneNode = function (recursive) {
1783
+ if (recursive === void 0) { recursive = false; }
1784
+ return cloneNode(this, recursive);
1785
+ };
1786
+ return Node;
1787
+ }());
1788
+ node.Node = Node;
1789
+ /**
1790
+ * A node that contains some data.
1791
+ */
1792
+ var DataNode = /** @class */ (function (_super) {
1793
+ __extends(DataNode, _super);
1794
+ /**
1795
+ * @param type The type of the node
1796
+ * @param data The content of the data node
1797
+ */
1798
+ function DataNode(type, data) {
1799
+ var _this = _super.call(this, type) || this;
1800
+ _this.data = data;
1801
+ return _this;
1802
+ }
1803
+ Object.defineProperty(DataNode.prototype, "nodeValue", {
1804
+ /**
1805
+ * Same as {@link data}.
1806
+ * [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
1807
+ */
1808
+ get: function () {
1809
+ return this.data;
1810
+ },
1811
+ set: function (data) {
1812
+ this.data = data;
1813
+ },
1814
+ enumerable: false,
1815
+ configurable: true
1816
+ });
1817
+ return DataNode;
1818
+ }(Node));
1819
+ node.DataNode = DataNode;
1820
+ /**
1821
+ * Text within the document.
1822
+ */
1823
+ var Text = /** @class */ (function (_super) {
1824
+ __extends(Text, _super);
1825
+ function Text(data) {
1826
+ return _super.call(this, domelementtype_1.ElementType.Text, data) || this;
1827
+ }
1828
+ return Text;
1829
+ }(DataNode));
1830
+ node.Text = Text;
1831
+ /**
1832
+ * Comments within the document.
1833
+ */
1834
+ var Comment = /** @class */ (function (_super) {
1835
+ __extends(Comment, _super);
1836
+ function Comment(data) {
1837
+ return _super.call(this, domelementtype_1.ElementType.Comment, data) || this;
1838
+ }
1839
+ return Comment;
1840
+ }(DataNode));
1841
+ node.Comment = Comment;
1842
+ /**
1843
+ * Processing instructions, including doc types.
1844
+ */
1845
+ var ProcessingInstruction = /** @class */ (function (_super) {
1846
+ __extends(ProcessingInstruction, _super);
1847
+ function ProcessingInstruction(name, data) {
1848
+ var _this = _super.call(this, domelementtype_1.ElementType.Directive, data) || this;
1849
+ _this.name = name;
1850
+ return _this;
1851
+ }
1852
+ return ProcessingInstruction;
1853
+ }(DataNode));
1854
+ node.ProcessingInstruction = ProcessingInstruction;
1855
+ /**
1856
+ * A `Node` that can have children.
1857
+ */
1858
+ var NodeWithChildren = /** @class */ (function (_super) {
1859
+ __extends(NodeWithChildren, _super);
1860
+ /**
1861
+ * @param type Type of the node.
1862
+ * @param children Children of the node. Only certain node types can have children.
1863
+ */
1864
+ function NodeWithChildren(type, children) {
1865
+ var _this = _super.call(this, type) || this;
1866
+ _this.children = children;
1867
+ return _this;
1868
+ }
1869
+ Object.defineProperty(NodeWithChildren.prototype, "firstChild", {
1870
+ // Aliases
1871
+ /** First child of the node. */
1872
+ get: function () {
1873
+ var _a;
1874
+ return (_a = this.children[0]) !== null && _a !== void 0 ? _a : null;
1875
+ },
1876
+ enumerable: false,
1877
+ configurable: true
1878
+ });
1879
+ Object.defineProperty(NodeWithChildren.prototype, "lastChild", {
1880
+ /** Last child of the node. */
1881
+ get: function () {
1882
+ return this.children.length > 0
1883
+ ? this.children[this.children.length - 1]
1884
+ : null;
1885
+ },
1886
+ enumerable: false,
1887
+ configurable: true
1888
+ });
1889
+ Object.defineProperty(NodeWithChildren.prototype, "childNodes", {
1890
+ /**
1891
+ * Same as {@link children}.
1892
+ * [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
1893
+ */
1894
+ get: function () {
1895
+ return this.children;
1896
+ },
1897
+ set: function (children) {
1898
+ this.children = children;
1899
+ },
1900
+ enumerable: false,
1901
+ configurable: true
1902
+ });
1903
+ return NodeWithChildren;
1904
+ }(Node));
1905
+ node.NodeWithChildren = NodeWithChildren;
1906
+ /**
1907
+ * The root node of the document.
1908
+ */
1909
+ var Document = /** @class */ (function (_super) {
1910
+ __extends(Document, _super);
1911
+ function Document(children) {
1912
+ return _super.call(this, domelementtype_1.ElementType.Root, children) || this;
1913
+ }
1914
+ return Document;
1915
+ }(NodeWithChildren));
1916
+ node.Document = Document;
1917
+ /**
1918
+ * An element within the DOM.
1919
+ */
1920
+ var Element = /** @class */ (function (_super) {
1921
+ __extends(Element, _super);
1922
+ /**
1923
+ * @param name Name of the tag, eg. `div`, `span`.
1924
+ * @param attribs Object mapping attribute names to attribute values.
1925
+ * @param children Children of the node.
1926
+ */
1927
+ function Element(name, attribs, children, type) {
1928
+ if (children === void 0) { children = []; }
1929
+ if (type === void 0) { type = name === "script"
1930
+ ? domelementtype_1.ElementType.Script
1931
+ : name === "style"
1932
+ ? domelementtype_1.ElementType.Style
1933
+ : domelementtype_1.ElementType.Tag; }
1934
+ var _this = _super.call(this, type, children) || this;
1935
+ _this.name = name;
1936
+ _this.attribs = attribs;
1937
+ return _this;
1938
+ }
1939
+ Object.defineProperty(Element.prototype, "tagName", {
1940
+ // DOM Level 1 aliases
1941
+ /**
1942
+ * Same as {@link name}.
1943
+ * [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
1944
+ */
1945
+ get: function () {
1946
+ return this.name;
1947
+ },
1948
+ set: function (name) {
1949
+ this.name = name;
1950
+ },
1951
+ enumerable: false,
1952
+ configurable: true
1953
+ });
1954
+ Object.defineProperty(Element.prototype, "attributes", {
1955
+ get: function () {
1956
+ var _this = this;
1957
+ return Object.keys(this.attribs).map(function (name) {
1958
+ var _a, _b;
1959
+ return ({
1960
+ name: name,
1961
+ value: _this.attribs[name],
1962
+ namespace: (_a = _this["x-attribsNamespace"]) === null || _a === void 0 ? void 0 : _a[name],
1963
+ prefix: (_b = _this["x-attribsPrefix"]) === null || _b === void 0 ? void 0 : _b[name],
1964
+ });
1965
+ });
1966
+ },
1967
+ enumerable: false,
1968
+ configurable: true
1969
+ });
1970
+ return Element;
1971
+ }(NodeWithChildren));
1972
+ node.Element = Element;
1973
+ /**
1974
+ * @param node Node to check.
1975
+ * @returns `true` if the node is a `Element`, `false` otherwise.
1976
+ */
1977
+ function isTag(node) {
1978
+ return (0, domelementtype_1.isTag)(node);
1979
+ }
1980
+ node.isTag = isTag;
1981
+ /**
1982
+ * @param node Node to check.
1983
+ * @returns `true` if the node has the type `CDATA`, `false` otherwise.
1984
+ */
1985
+ function isCDATA(node) {
1986
+ return node.type === domelementtype_1.ElementType.CDATA;
1987
+ }
1988
+ node.isCDATA = isCDATA;
1989
+ /**
1990
+ * @param node Node to check.
1991
+ * @returns `true` if the node has the type `Text`, `false` otherwise.
1992
+ */
1993
+ function isText(node) {
1994
+ return node.type === domelementtype_1.ElementType.Text;
1995
+ }
1996
+ node.isText = isText;
1997
+ /**
1998
+ * @param node Node to check.
1999
+ * @returns `true` if the node has the type `Comment`, `false` otherwise.
2000
+ */
2001
+ function isComment(node) {
2002
+ return node.type === domelementtype_1.ElementType.Comment;
2003
+ }
2004
+ node.isComment = isComment;
2005
+ /**
2006
+ * @param node Node to check.
2007
+ * @returns `true` if the node has the type `ProcessingInstruction`, `false` otherwise.
2008
+ */
2009
+ function isDirective(node) {
2010
+ return node.type === domelementtype_1.ElementType.Directive;
2011
+ }
2012
+ node.isDirective = isDirective;
2013
+ /**
2014
+ * @param node Node to check.
2015
+ * @returns `true` if the node has the type `ProcessingInstruction`, `false` otherwise.
2016
+ */
2017
+ function isDocument(node) {
2018
+ return node.type === domelementtype_1.ElementType.Root;
2019
+ }
2020
+ node.isDocument = isDocument;
2021
+ /**
2022
+ * @param node Node to check.
2023
+ * @returns `true` if the node is a `NodeWithChildren` (has children), `false` otherwise.
2024
+ */
2025
+ function hasChildren(node) {
2026
+ return Object.prototype.hasOwnProperty.call(node, "children");
2027
+ }
2028
+ node.hasChildren = hasChildren;
2029
+ /**
2030
+ * Clone a node, and optionally its children.
2031
+ *
2032
+ * @param recursive Clone child nodes as well.
2033
+ * @returns A clone of the node.
2034
+ */
2035
+ function cloneNode(node, recursive) {
2036
+ if (recursive === void 0) { recursive = false; }
2037
+ var result;
2038
+ if (isText(node)) {
2039
+ result = new Text(node.data);
2040
+ }
2041
+ else if (isComment(node)) {
2042
+ result = new Comment(node.data);
2043
+ }
2044
+ else if (isTag(node)) {
2045
+ var children = recursive ? cloneChildren(node.children) : [];
2046
+ var clone_1 = new Element(node.name, __assign({}, node.attribs), children);
2047
+ children.forEach(function (child) { return (child.parent = clone_1); });
2048
+ if (node.namespace != null) {
2049
+ clone_1.namespace = node.namespace;
2050
+ }
2051
+ if (node["x-attribsNamespace"]) {
2052
+ clone_1["x-attribsNamespace"] = __assign({}, node["x-attribsNamespace"]);
2053
+ }
2054
+ if (node["x-attribsPrefix"]) {
2055
+ clone_1["x-attribsPrefix"] = __assign({}, node["x-attribsPrefix"]);
2056
+ }
2057
+ result = clone_1;
2058
+ }
2059
+ else if (isCDATA(node)) {
2060
+ var children = recursive ? cloneChildren(node.children) : [];
2061
+ var clone_2 = new NodeWithChildren(domelementtype_1.ElementType.CDATA, children);
2062
+ children.forEach(function (child) { return (child.parent = clone_2); });
2063
+ result = clone_2;
2064
+ }
2065
+ else if (isDocument(node)) {
2066
+ var children = recursive ? cloneChildren(node.children) : [];
2067
+ var clone_3 = new Document(children);
2068
+ children.forEach(function (child) { return (child.parent = clone_3); });
2069
+ if (node["x-mode"]) {
2070
+ clone_3["x-mode"] = node["x-mode"];
2071
+ }
2072
+ result = clone_3;
2073
+ }
2074
+ else if (isDirective(node)) {
2075
+ var instruction = new ProcessingInstruction(node.name, node.data);
2076
+ if (node["x-name"] != null) {
2077
+ instruction["x-name"] = node["x-name"];
2078
+ instruction["x-publicId"] = node["x-publicId"];
2079
+ instruction["x-systemId"] = node["x-systemId"];
2080
+ }
2081
+ result = instruction;
2082
+ }
2083
+ else {
2084
+ throw new Error("Not implemented yet: ".concat(node.type));
2085
+ }
2086
+ result.startIndex = node.startIndex;
2087
+ result.endIndex = node.endIndex;
2088
+ if (node.sourceCodeLocation != null) {
2089
+ result.sourceCodeLocation = node.sourceCodeLocation;
2090
+ }
2091
+ return result;
2092
+ }
2093
+ node.cloneNode = cloneNode;
2094
+ function cloneChildren(childs) {
2095
+ var children = childs.map(function (child) { return cloneNode(child, true); });
2096
+ for (var i = 1; i < children.length; i++) {
2097
+ children[i].prev = children[i - 1];
2098
+ children[i - 1].next = children[i];
2099
+ }
2100
+ return children;
2101
+ }
2102
+ return node;
2089
2103
  }
2090
2104
 
2091
2105
  var constants = constants$1;
2092
- var domhandler = node;
2106
+ var domhandler = requireNode();
2093
2107
 
2094
2108
  var CASE_SENSITIVE_TAG_NAMES = constants.CASE_SENSITIVE_TAG_NAMES;
2095
2109
 
@@ -2431,6 +2445,193 @@
2431
2445
 
2432
2446
  var htmlToDom = HTMLDOMParser;
2433
2447
 
2448
+ var lib = {};
2449
+
2450
+ var hasRequiredLib;
2451
+
2452
+ function requireLib () {
2453
+ if (hasRequiredLib) return lib;
2454
+ hasRequiredLib = 1;
2455
+ (function (exports) {
2456
+ var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
2457
+ if (k2 === undefined) k2 = k;
2458
+ var desc = Object.getOwnPropertyDescriptor(m, k);
2459
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
2460
+ desc = { enumerable: true, get: function() { return m[k]; } };
2461
+ }
2462
+ Object.defineProperty(o, k2, desc);
2463
+ }) : (function(o, m, k, k2) {
2464
+ if (k2 === undefined) k2 = k;
2465
+ o[k2] = m[k];
2466
+ }));
2467
+ var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
2468
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
2469
+ };
2470
+ Object.defineProperty(exports, "__esModule", { value: true });
2471
+ exports.DomHandler = void 0;
2472
+ var domelementtype_1 = requireLib$1();
2473
+ var node_1 = requireNode();
2474
+ __exportStar(requireNode(), exports);
2475
+ var reWhitespace = /\s+/g;
2476
+ // Default options
2477
+ var defaultOpts = {
2478
+ normalizeWhitespace: false,
2479
+ withStartIndices: false,
2480
+ withEndIndices: false,
2481
+ xmlMode: false,
2482
+ };
2483
+ var DomHandler = /** @class */ (function () {
2484
+ /**
2485
+ * @param callback Called once parsing has completed.
2486
+ * @param options Settings for the handler.
2487
+ * @param elementCB Callback whenever a tag is closed.
2488
+ */
2489
+ function DomHandler(callback, options, elementCB) {
2490
+ /** The elements of the DOM */
2491
+ this.dom = [];
2492
+ /** The root element for the DOM */
2493
+ this.root = new node_1.Document(this.dom);
2494
+ /** Indicated whether parsing has been completed. */
2495
+ this.done = false;
2496
+ /** Stack of open tags. */
2497
+ this.tagStack = [this.root];
2498
+ /** A data node that is still being written to. */
2499
+ this.lastNode = null;
2500
+ /** Reference to the parser instance. Used for location information. */
2501
+ this.parser = null;
2502
+ // Make it possible to skip arguments, for backwards-compatibility
2503
+ if (typeof options === "function") {
2504
+ elementCB = options;
2505
+ options = defaultOpts;
2506
+ }
2507
+ if (typeof callback === "object") {
2508
+ options = callback;
2509
+ callback = undefined;
2510
+ }
2511
+ this.callback = callback !== null && callback !== void 0 ? callback : null;
2512
+ this.options = options !== null && options !== void 0 ? options : defaultOpts;
2513
+ this.elementCB = elementCB !== null && elementCB !== void 0 ? elementCB : null;
2514
+ }
2515
+ DomHandler.prototype.onparserinit = function (parser) {
2516
+ this.parser = parser;
2517
+ };
2518
+ // Resets the handler back to starting state
2519
+ DomHandler.prototype.onreset = function () {
2520
+ this.dom = [];
2521
+ this.root = new node_1.Document(this.dom);
2522
+ this.done = false;
2523
+ this.tagStack = [this.root];
2524
+ this.lastNode = null;
2525
+ this.parser = null;
2526
+ };
2527
+ // Signals the handler that parsing is done
2528
+ DomHandler.prototype.onend = function () {
2529
+ if (this.done)
2530
+ return;
2531
+ this.done = true;
2532
+ this.parser = null;
2533
+ this.handleCallback(null);
2534
+ };
2535
+ DomHandler.prototype.onerror = function (error) {
2536
+ this.handleCallback(error);
2537
+ };
2538
+ DomHandler.prototype.onclosetag = function () {
2539
+ this.lastNode = null;
2540
+ var elem = this.tagStack.pop();
2541
+ if (this.options.withEndIndices) {
2542
+ elem.endIndex = this.parser.endIndex;
2543
+ }
2544
+ if (this.elementCB)
2545
+ this.elementCB(elem);
2546
+ };
2547
+ DomHandler.prototype.onopentag = function (name, attribs) {
2548
+ var type = this.options.xmlMode ? domelementtype_1.ElementType.Tag : undefined;
2549
+ var element = new node_1.Element(name, attribs, undefined, type);
2550
+ this.addNode(element);
2551
+ this.tagStack.push(element);
2552
+ };
2553
+ DomHandler.prototype.ontext = function (data) {
2554
+ var normalizeWhitespace = this.options.normalizeWhitespace;
2555
+ var lastNode = this.lastNode;
2556
+ if (lastNode && lastNode.type === domelementtype_1.ElementType.Text) {
2557
+ if (normalizeWhitespace) {
2558
+ lastNode.data = (lastNode.data + data).replace(reWhitespace, " ");
2559
+ }
2560
+ else {
2561
+ lastNode.data += data;
2562
+ }
2563
+ if (this.options.withEndIndices) {
2564
+ lastNode.endIndex = this.parser.endIndex;
2565
+ }
2566
+ }
2567
+ else {
2568
+ if (normalizeWhitespace) {
2569
+ data = data.replace(reWhitespace, " ");
2570
+ }
2571
+ var node = new node_1.Text(data);
2572
+ this.addNode(node);
2573
+ this.lastNode = node;
2574
+ }
2575
+ };
2576
+ DomHandler.prototype.oncomment = function (data) {
2577
+ if (this.lastNode && this.lastNode.type === domelementtype_1.ElementType.Comment) {
2578
+ this.lastNode.data += data;
2579
+ return;
2580
+ }
2581
+ var node = new node_1.Comment(data);
2582
+ this.addNode(node);
2583
+ this.lastNode = node;
2584
+ };
2585
+ DomHandler.prototype.oncommentend = function () {
2586
+ this.lastNode = null;
2587
+ };
2588
+ DomHandler.prototype.oncdatastart = function () {
2589
+ var text = new node_1.Text("");
2590
+ var node = new node_1.NodeWithChildren(domelementtype_1.ElementType.CDATA, [text]);
2591
+ this.addNode(node);
2592
+ text.parent = node;
2593
+ this.lastNode = text;
2594
+ };
2595
+ DomHandler.prototype.oncdataend = function () {
2596
+ this.lastNode = null;
2597
+ };
2598
+ DomHandler.prototype.onprocessinginstruction = function (name, data) {
2599
+ var node = new node_1.ProcessingInstruction(name, data);
2600
+ this.addNode(node);
2601
+ };
2602
+ DomHandler.prototype.handleCallback = function (error) {
2603
+ if (typeof this.callback === "function") {
2604
+ this.callback(error, this.dom);
2605
+ }
2606
+ else if (error) {
2607
+ throw error;
2608
+ }
2609
+ };
2610
+ DomHandler.prototype.addNode = function (node) {
2611
+ var parent = this.tagStack[this.tagStack.length - 1];
2612
+ var previousSibling = parent.children[parent.children.length - 1];
2613
+ if (this.options.withStartIndices) {
2614
+ node.startIndex = this.parser.startIndex;
2615
+ }
2616
+ if (this.options.withEndIndices) {
2617
+ node.endIndex = this.parser.endIndex;
2618
+ }
2619
+ parent.children.push(node);
2620
+ if (previousSibling) {
2621
+ node.prev = previousSibling;
2622
+ previousSibling.next = node;
2623
+ }
2624
+ node.parent = parent;
2625
+ this.lastNode = null;
2626
+ };
2627
+ return DomHandler;
2628
+ }());
2629
+ exports.DomHandler = DomHandler;
2630
+ exports.default = DomHandler;
2631
+ } (lib));
2632
+ return lib;
2633
+ }
2634
+
2434
2635
  var domToReact = domToReact_1;
2435
2636
  var attributesToProps = attributesToProps$2;
2436
2637
  var htmlToDOM = htmlToDom;
@@ -2469,15 +2670,13 @@
2469
2670
  HTMLReactParser.domToReact = domToReact;
2470
2671
  HTMLReactParser.htmlToDOM = htmlToDOM;
2471
2672
  HTMLReactParser.attributesToProps = attributesToProps;
2472
- HTMLReactParser.Element = node.Element;
2673
+ HTMLReactParser.Element = requireLib().Element;
2473
2674
 
2474
2675
  // support CommonJS and ES Modules
2475
- htmlReactParser$1.exports = HTMLReactParser;
2476
- htmlReactParser$1.exports.default = HTMLReactParser;
2477
-
2478
- var htmlReactParser = htmlReactParser$1.exports;
2676
+ htmlReactParser.exports = HTMLReactParser;
2677
+ htmlReactParser.exports.default = HTMLReactParser;
2479
2678
 
2480
- return htmlReactParser;
2679
+ return htmlReactParser.exports;
2481
2680
 
2482
2681
  }));
2483
2682
  //# sourceMappingURL=html-react-parser.js.map