html-react-parser 1.4.10 → 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.
- package/dist/html-react-parser.js +739 -540
- package/dist/html-react-parser.js.map +1 -1
- package/dist/html-react-parser.min.js +1 -1
- package/dist/html-react-parser.min.js.map +1 -1
- package/index.js +1 -1
- package/package.json +24 -20
|
@@ -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
|
|
13
|
+
var htmlReactParser = {exports: {}};
|
|
14
14
|
|
|
15
|
-
var lib$
|
|
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$
|
|
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$
|
|
819
|
-
lib$
|
|
820
|
-
lib$
|
|
821
|
-
lib$
|
|
822
|
-
lib$
|
|
823
|
-
lib$
|
|
824
|
-
lib$
|
|
825
|
-
lib$
|
|
826
|
-
lib$
|
|
827
|
-
lib$
|
|
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
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
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$
|
|
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
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
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
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
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 =
|
|
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 =
|
|
2673
|
+
HTMLReactParser.Element = requireLib().Element;
|
|
2473
2674
|
|
|
2474
2675
|
// support CommonJS and ES Modules
|
|
2475
|
-
htmlReactParser
|
|
2476
|
-
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
|