html-react-parser 1.4.11 → 1.4.14
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 +768 -565
- 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.d.ts +3 -3
- package/index.js +7 -7
- package/lib/attributes-to-props.d.ts +2 -2
- package/lib/attributes-to-props.js +3 -3
- package/lib/dom-to-react.d.ts +3 -3
- package/lib/dom-to-react.js +7 -7
- package/lib/utilities.js +7 -7
- package/package.json +23 -19
|
@@ -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
|
|
|
@@ -1137,6 +1137,7 @@
|
|
|
1137
1137
|
var HYPHEN_REGEX = /-([a-z])/g;
|
|
1138
1138
|
var NO_HYPHEN_REGEX = /^[^-]+$/;
|
|
1139
1139
|
var VENDOR_PREFIX_REGEX = /^-(webkit|moz|ms|o|khtml)-/;
|
|
1140
|
+
var MS_VENDOR_PREFIX_REGEX = /^-(ms)-/;
|
|
1140
1141
|
var skipCamelCase = function (property) {
|
|
1141
1142
|
return !property ||
|
|
1142
1143
|
NO_HYPHEN_REGEX.test(property) ||
|
|
@@ -1145,14 +1146,17 @@
|
|
|
1145
1146
|
var capitalize = function (match, character) {
|
|
1146
1147
|
return character.toUpperCase();
|
|
1147
1148
|
};
|
|
1148
|
-
var trimHyphen = function (match, prefix) { return prefix
|
|
1149
|
+
var trimHyphen = function (match, prefix) { return "".concat(prefix, "-"); };
|
|
1149
1150
|
var camelCase = function (property, options) {
|
|
1150
1151
|
if (options === void 0) { options = {}; }
|
|
1151
1152
|
if (skipCamelCase(property)) {
|
|
1152
1153
|
return property;
|
|
1153
1154
|
}
|
|
1154
1155
|
property = property.toLowerCase();
|
|
1155
|
-
if (
|
|
1156
|
+
if (options.reactCompat) {
|
|
1157
|
+
property = property.replace(MS_VENDOR_PREFIX_REGEX, trimHyphen);
|
|
1158
|
+
}
|
|
1159
|
+
else {
|
|
1156
1160
|
property = property.replace(VENDOR_PREFIX_REGEX, trimHyphen);
|
|
1157
1161
|
}
|
|
1158
1162
|
return property.replace(HYPHEN_REGEX, capitalize);
|
|
@@ -1160,26 +1164,26 @@
|
|
|
1160
1164
|
utilities$4.camelCase = camelCase;
|
|
1161
1165
|
|
|
1162
1166
|
(function (exports) {
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
}(cjs));
|
|
1167
|
+
var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
|
|
1168
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
1169
|
+
};
|
|
1170
|
+
exports.__esModule = true;
|
|
1171
|
+
var style_to_object_1 = __importDefault(styleToObject);
|
|
1172
|
+
var utilities_1 = utilities$4;
|
|
1173
|
+
function StyleToJS(style, options) {
|
|
1174
|
+
var output = {};
|
|
1175
|
+
if (!style || typeof style !== 'string') {
|
|
1176
|
+
return output;
|
|
1177
|
+
}
|
|
1178
|
+
(0, style_to_object_1["default"])(style, function (property, value) {
|
|
1179
|
+
if (property && value) {
|
|
1180
|
+
output[(0, utilities_1.camelCase)(property, options)] = value;
|
|
1181
|
+
}
|
|
1182
|
+
});
|
|
1183
|
+
return output;
|
|
1184
|
+
}
|
|
1185
|
+
exports["default"] = StyleToJS;
|
|
1186
|
+
} (cjs));
|
|
1183
1187
|
|
|
1184
1188
|
var React$1 = require$$0__default["default"];
|
|
1185
1189
|
var styleToJS = cjs.default;
|
|
@@ -1187,9 +1191,9 @@
|
|
|
1187
1191
|
/**
|
|
1188
1192
|
* Swap key with value in an object.
|
|
1189
1193
|
*
|
|
1190
|
-
* @param
|
|
1191
|
-
* @param
|
|
1192
|
-
* @
|
|
1194
|
+
* @param {object} obj - The object.
|
|
1195
|
+
* @param {Function} [override] - The override method.
|
|
1196
|
+
* @returns - The inverted object.
|
|
1193
1197
|
*/
|
|
1194
1198
|
function invertObject(obj, override) {
|
|
1195
1199
|
if (!obj || typeof obj !== 'object') {
|
|
@@ -1227,8 +1231,8 @@
|
|
|
1227
1231
|
* @see {@link https://github.com/facebook/react/blob/v16.6.3/packages/react-dom/src/shared/isCustomComponent.js}
|
|
1228
1232
|
*
|
|
1229
1233
|
* @param {string} tagName - The name of the html tag.
|
|
1230
|
-
* @param {
|
|
1231
|
-
* @
|
|
1234
|
+
* @param {object} props - The props being passed to the element.
|
|
1235
|
+
* @returns - Whether tag is custom component.
|
|
1232
1236
|
*/
|
|
1233
1237
|
function isCustomComponent(tagName, props) {
|
|
1234
1238
|
if (tagName.indexOf('-') === -1) {
|
|
@@ -1296,8 +1300,8 @@
|
|
|
1296
1300
|
/**
|
|
1297
1301
|
* Checks if the given node can contain text nodes
|
|
1298
1302
|
*
|
|
1299
|
-
* @param {DomElement} node
|
|
1300
|
-
* @returns
|
|
1303
|
+
* @param {DomElement} node - Node.
|
|
1304
|
+
* @returns - Whether node can contain text nodes.
|
|
1301
1305
|
*/
|
|
1302
1306
|
function canTextBeChildOfNode$1(node) {
|
|
1303
1307
|
return !elementsWithNoTextChildren.has(node.name);
|
|
@@ -1312,14 +1316,14 @@
|
|
|
1312
1316
|
elementsWithNoTextChildren: elementsWithNoTextChildren
|
|
1313
1317
|
};
|
|
1314
1318
|
|
|
1315
|
-
var reactProperty = lib$
|
|
1319
|
+
var reactProperty = lib$2;
|
|
1316
1320
|
var utilities$2 = utilities$3;
|
|
1317
1321
|
|
|
1318
1322
|
/**
|
|
1319
1323
|
* Converts HTML/SVG DOM attributes to React props.
|
|
1320
1324
|
*
|
|
1321
|
-
* @param
|
|
1322
|
-
* @
|
|
1325
|
+
* @param {object} [attributes={}] - HTML/SVG DOM attributes.
|
|
1326
|
+
* @returns - React props.
|
|
1323
1327
|
*/
|
|
1324
1328
|
var attributesToProps$2 = function attributesToProps(attributes) {
|
|
1325
1329
|
attributes = attributes || {};
|
|
@@ -1393,7 +1397,7 @@
|
|
|
1393
1397
|
* Gets prop name from lowercased attribute name.
|
|
1394
1398
|
*
|
|
1395
1399
|
* @param {string} attributeName - Lowercased attribute name.
|
|
1396
|
-
* @
|
|
1400
|
+
* @returns - Prop name.
|
|
1397
1401
|
*/
|
|
1398
1402
|
function getPropName(attributeName) {
|
|
1399
1403
|
return reactProperty.possibleStandardNames[attributeName];
|
|
@@ -1409,11 +1413,11 @@
|
|
|
1409
1413
|
/**
|
|
1410
1414
|
* Converts DOM nodes to JSX element(s).
|
|
1411
1415
|
*
|
|
1412
|
-
* @param
|
|
1413
|
-
* @param
|
|
1414
|
-
* @param
|
|
1415
|
-
* @param
|
|
1416
|
-
* @
|
|
1416
|
+
* @param {DomElement[]} nodes - DOM nodes.
|
|
1417
|
+
* @param {object} [options={}] - Options.
|
|
1418
|
+
* @param {Function} [options.replace] - Replacer.
|
|
1419
|
+
* @param {object} [options.library] - Library (React, Preact, etc.).
|
|
1420
|
+
* @returns - String or JSX element(s).
|
|
1417
1421
|
*/
|
|
1418
1422
|
function domToReact$1(nodes, options) {
|
|
1419
1423
|
options = options || {};
|
|
@@ -1526,8 +1530,8 @@
|
|
|
1526
1530
|
* Determines whether DOM element attributes should be transformed to props.
|
|
1527
1531
|
* Web Components should not have their attributes transformed except for `style`.
|
|
1528
1532
|
*
|
|
1529
|
-
* @param
|
|
1530
|
-
* @
|
|
1533
|
+
* @param {DomElement} node
|
|
1534
|
+
* @returns - Whether node attributes should be converted to props.
|
|
1531
1535
|
*/
|
|
1532
1536
|
function skipAttributesToProps(node) {
|
|
1533
1537
|
return (
|
|
@@ -1585,511 +1589,525 @@
|
|
|
1585
1589
|
|
|
1586
1590
|
var node = {};
|
|
1587
1591
|
|
|
1588
|
-
var lib = {};
|
|
1592
|
+
var lib$1 = {};
|
|
1589
1593
|
|
|
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
|
-
|
|
1624
|
-
|
|
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
|
-
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);
|
|
1594
|
+
var hasRequiredLib$1;
|
|
1595
|
+
|
|
1596
|
+
function requireLib$1 () {
|
|
1597
|
+
if (hasRequiredLib$1) return lib$1;
|
|
1598
|
+
hasRequiredLib$1 = 1;
|
|
1599
|
+
(function (exports) {
|
|
1600
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1601
|
+
exports.Doctype = exports.CDATA = exports.Tag = exports.Style = exports.Script = exports.Comment = exports.Directive = exports.Text = exports.Root = exports.isTag = exports.ElementType = void 0;
|
|
1602
|
+
/** Types of elements found in htmlparser2's DOM */
|
|
1603
|
+
var ElementType;
|
|
1604
|
+
(function (ElementType) {
|
|
1605
|
+
/** Type for the root element of a document */
|
|
1606
|
+
ElementType["Root"] = "root";
|
|
1607
|
+
/** Type for Text */
|
|
1608
|
+
ElementType["Text"] = "text";
|
|
1609
|
+
/** Type for <? ... ?> */
|
|
1610
|
+
ElementType["Directive"] = "directive";
|
|
1611
|
+
/** Type for <!-- ... --> */
|
|
1612
|
+
ElementType["Comment"] = "comment";
|
|
1613
|
+
/** Type for <script> tags */
|
|
1614
|
+
ElementType["Script"] = "script";
|
|
1615
|
+
/** Type for <style> tags */
|
|
1616
|
+
ElementType["Style"] = "style";
|
|
1617
|
+
/** Type for Any tag */
|
|
1618
|
+
ElementType["Tag"] = "tag";
|
|
1619
|
+
/** Type for <![CDATA[ ... ]]> */
|
|
1620
|
+
ElementType["CDATA"] = "cdata";
|
|
1621
|
+
/** Type for <!doctype ...> */
|
|
1622
|
+
ElementType["Doctype"] = "doctype";
|
|
1623
|
+
})(ElementType = exports.ElementType || (exports.ElementType = {}));
|
|
1624
|
+
/**
|
|
1625
|
+
* Tests whether an element is a tag or not.
|
|
1626
|
+
*
|
|
1627
|
+
* @param elem Element to test
|
|
1628
|
+
*/
|
|
1629
|
+
function isTag(elem) {
|
|
1630
|
+
return (elem.type === ElementType.Tag ||
|
|
1631
|
+
elem.type === ElementType.Script ||
|
|
1632
|
+
elem.type === ElementType.Style);
|
|
1633
|
+
}
|
|
1634
|
+
exports.isTag = isTag;
|
|
1635
|
+
// Exports for backwards compatibility
|
|
1636
|
+
/** Type for the root element of a document */
|
|
1637
|
+
exports.Root = ElementType.Root;
|
|
1638
|
+
/** Type for Text */
|
|
1639
|
+
exports.Text = ElementType.Text;
|
|
1640
|
+
/** Type for <? ... ?> */
|
|
1641
|
+
exports.Directive = ElementType.Directive;
|
|
1642
|
+
/** Type for <!-- ... --> */
|
|
1643
|
+
exports.Comment = ElementType.Comment;
|
|
1644
|
+
/** Type for <script> tags */
|
|
1645
|
+
exports.Script = ElementType.Script;
|
|
1646
|
+
/** Type for <style> tags */
|
|
1647
|
+
exports.Style = ElementType.Style;
|
|
1648
|
+
/** Type for Any tag */
|
|
1649
|
+
exports.Tag = ElementType.Tag;
|
|
1650
|
+
/** Type for <![CDATA[ ... ]]> */
|
|
1651
|
+
exports.CDATA = ElementType.CDATA;
|
|
1652
|
+
/** Type for <!doctype ...> */
|
|
1653
|
+
exports.Doctype = ElementType.Doctype;
|
|
1654
|
+
} (lib$1));
|
|
1655
|
+
return lib$1;
|
|
1967
1656
|
}
|
|
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
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
1657
|
+
|
|
1658
|
+
var hasRequiredNode;
|
|
1659
|
+
|
|
1660
|
+
function requireNode () {
|
|
1661
|
+
if (hasRequiredNode) return node;
|
|
1662
|
+
hasRequiredNode = 1;
|
|
1663
|
+
var __extends = (commonjsGlobal && commonjsGlobal.__extends) || (function () {
|
|
1664
|
+
var extendStatics = function (d, b) {
|
|
1665
|
+
extendStatics = Object.setPrototypeOf ||
|
|
1666
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
1667
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
1668
|
+
return extendStatics(d, b);
|
|
1669
|
+
};
|
|
1670
|
+
return function (d, b) {
|
|
1671
|
+
if (typeof b !== "function" && b !== null)
|
|
1672
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
1673
|
+
extendStatics(d, b);
|
|
1674
|
+
function __() { this.constructor = d; }
|
|
1675
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
1676
|
+
};
|
|
1677
|
+
})();
|
|
1678
|
+
var __assign = (commonjsGlobal && commonjsGlobal.__assign) || function () {
|
|
1679
|
+
__assign = Object.assign || function(t) {
|
|
1680
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
1681
|
+
s = arguments[i];
|
|
1682
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
1683
|
+
t[p] = s[p];
|
|
1684
|
+
}
|
|
1685
|
+
return t;
|
|
1686
|
+
};
|
|
1687
|
+
return __assign.apply(this, arguments);
|
|
1688
|
+
};
|
|
1689
|
+
Object.defineProperty(node, "__esModule", { value: true });
|
|
1690
|
+
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;
|
|
1691
|
+
var domelementtype_1 = requireLib$1();
|
|
1692
|
+
var nodeTypes = new Map([
|
|
1693
|
+
[domelementtype_1.ElementType.Tag, 1],
|
|
1694
|
+
[domelementtype_1.ElementType.Script, 1],
|
|
1695
|
+
[domelementtype_1.ElementType.Style, 1],
|
|
1696
|
+
[domelementtype_1.ElementType.Directive, 1],
|
|
1697
|
+
[domelementtype_1.ElementType.Text, 3],
|
|
1698
|
+
[domelementtype_1.ElementType.CDATA, 4],
|
|
1699
|
+
[domelementtype_1.ElementType.Comment, 8],
|
|
1700
|
+
[domelementtype_1.ElementType.Root, 9],
|
|
1701
|
+
]);
|
|
1702
|
+
/**
|
|
1703
|
+
* This object will be used as the prototype for Nodes when creating a
|
|
1704
|
+
* DOM-Level-1-compliant structure.
|
|
1705
|
+
*/
|
|
1706
|
+
var Node = /** @class */ (function () {
|
|
1707
|
+
/**
|
|
1708
|
+
*
|
|
1709
|
+
* @param type The type of the node.
|
|
1710
|
+
*/
|
|
1711
|
+
function Node(type) {
|
|
1712
|
+
this.type = type;
|
|
1713
|
+
/** Parent of the node */
|
|
1714
|
+
this.parent = null;
|
|
1715
|
+
/** Previous sibling */
|
|
1716
|
+
this.prev = null;
|
|
1717
|
+
/** Next sibling */
|
|
1718
|
+
this.next = null;
|
|
1719
|
+
/** The start index of the node. Requires `withStartIndices` on the handler to be `true. */
|
|
1720
|
+
this.startIndex = null;
|
|
1721
|
+
/** The end index of the node. Requires `withEndIndices` on the handler to be `true. */
|
|
1722
|
+
this.endIndex = null;
|
|
1723
|
+
}
|
|
1724
|
+
Object.defineProperty(Node.prototype, "nodeType", {
|
|
1725
|
+
// Read-only aliases
|
|
1726
|
+
/**
|
|
1727
|
+
* [DOM spec](https://dom.spec.whatwg.org/#dom-node-nodetype)-compatible
|
|
1728
|
+
* node {@link type}.
|
|
1729
|
+
*/
|
|
1730
|
+
get: function () {
|
|
1731
|
+
var _a;
|
|
1732
|
+
return (_a = nodeTypes.get(this.type)) !== null && _a !== void 0 ? _a : 1;
|
|
1733
|
+
},
|
|
1734
|
+
enumerable: false,
|
|
1735
|
+
configurable: true
|
|
1736
|
+
});
|
|
1737
|
+
Object.defineProperty(Node.prototype, "parentNode", {
|
|
1738
|
+
// Read-write aliases for properties
|
|
1739
|
+
/**
|
|
1740
|
+
* Same as {@link parent}.
|
|
1741
|
+
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
|
1742
|
+
*/
|
|
1743
|
+
get: function () {
|
|
1744
|
+
return this.parent;
|
|
1745
|
+
},
|
|
1746
|
+
set: function (parent) {
|
|
1747
|
+
this.parent = parent;
|
|
1748
|
+
},
|
|
1749
|
+
enumerable: false,
|
|
1750
|
+
configurable: true
|
|
1751
|
+
});
|
|
1752
|
+
Object.defineProperty(Node.prototype, "previousSibling", {
|
|
1753
|
+
/**
|
|
1754
|
+
* Same as {@link prev}.
|
|
1755
|
+
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
|
1756
|
+
*/
|
|
1757
|
+
get: function () {
|
|
1758
|
+
return this.prev;
|
|
1759
|
+
},
|
|
1760
|
+
set: function (prev) {
|
|
1761
|
+
this.prev = prev;
|
|
1762
|
+
},
|
|
1763
|
+
enumerable: false,
|
|
1764
|
+
configurable: true
|
|
1765
|
+
});
|
|
1766
|
+
Object.defineProperty(Node.prototype, "nextSibling", {
|
|
1767
|
+
/**
|
|
1768
|
+
* Same as {@link next}.
|
|
1769
|
+
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
|
1770
|
+
*/
|
|
1771
|
+
get: function () {
|
|
1772
|
+
return this.next;
|
|
1773
|
+
},
|
|
1774
|
+
set: function (next) {
|
|
1775
|
+
this.next = next;
|
|
1776
|
+
},
|
|
1777
|
+
enumerable: false,
|
|
1778
|
+
configurable: true
|
|
1779
|
+
});
|
|
1780
|
+
/**
|
|
1781
|
+
* Clone this node, and optionally its children.
|
|
1782
|
+
*
|
|
1783
|
+
* @param recursive Clone child nodes as well.
|
|
1784
|
+
* @returns A clone of the node.
|
|
1785
|
+
*/
|
|
1786
|
+
Node.prototype.cloneNode = function (recursive) {
|
|
1787
|
+
if (recursive === void 0) { recursive = false; }
|
|
1788
|
+
return cloneNode(this, recursive);
|
|
1789
|
+
};
|
|
1790
|
+
return Node;
|
|
1791
|
+
}());
|
|
1792
|
+
node.Node = Node;
|
|
1793
|
+
/**
|
|
1794
|
+
* A node that contains some data.
|
|
1795
|
+
*/
|
|
1796
|
+
var DataNode = /** @class */ (function (_super) {
|
|
1797
|
+
__extends(DataNode, _super);
|
|
1798
|
+
/**
|
|
1799
|
+
* @param type The type of the node
|
|
1800
|
+
* @param data The content of the data node
|
|
1801
|
+
*/
|
|
1802
|
+
function DataNode(type, data) {
|
|
1803
|
+
var _this = _super.call(this, type) || this;
|
|
1804
|
+
_this.data = data;
|
|
1805
|
+
return _this;
|
|
1806
|
+
}
|
|
1807
|
+
Object.defineProperty(DataNode.prototype, "nodeValue", {
|
|
1808
|
+
/**
|
|
1809
|
+
* Same as {@link data}.
|
|
1810
|
+
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
|
1811
|
+
*/
|
|
1812
|
+
get: function () {
|
|
1813
|
+
return this.data;
|
|
1814
|
+
},
|
|
1815
|
+
set: function (data) {
|
|
1816
|
+
this.data = data;
|
|
1817
|
+
},
|
|
1818
|
+
enumerable: false,
|
|
1819
|
+
configurable: true
|
|
1820
|
+
});
|
|
1821
|
+
return DataNode;
|
|
1822
|
+
}(Node));
|
|
1823
|
+
node.DataNode = DataNode;
|
|
1824
|
+
/**
|
|
1825
|
+
* Text within the document.
|
|
1826
|
+
*/
|
|
1827
|
+
var Text = /** @class */ (function (_super) {
|
|
1828
|
+
__extends(Text, _super);
|
|
1829
|
+
function Text(data) {
|
|
1830
|
+
return _super.call(this, domelementtype_1.ElementType.Text, data) || this;
|
|
1831
|
+
}
|
|
1832
|
+
return Text;
|
|
1833
|
+
}(DataNode));
|
|
1834
|
+
node.Text = Text;
|
|
1835
|
+
/**
|
|
1836
|
+
* Comments within the document.
|
|
1837
|
+
*/
|
|
1838
|
+
var Comment = /** @class */ (function (_super) {
|
|
1839
|
+
__extends(Comment, _super);
|
|
1840
|
+
function Comment(data) {
|
|
1841
|
+
return _super.call(this, domelementtype_1.ElementType.Comment, data) || this;
|
|
1842
|
+
}
|
|
1843
|
+
return Comment;
|
|
1844
|
+
}(DataNode));
|
|
1845
|
+
node.Comment = Comment;
|
|
1846
|
+
/**
|
|
1847
|
+
* Processing instructions, including doc types.
|
|
1848
|
+
*/
|
|
1849
|
+
var ProcessingInstruction = /** @class */ (function (_super) {
|
|
1850
|
+
__extends(ProcessingInstruction, _super);
|
|
1851
|
+
function ProcessingInstruction(name, data) {
|
|
1852
|
+
var _this = _super.call(this, domelementtype_1.ElementType.Directive, data) || this;
|
|
1853
|
+
_this.name = name;
|
|
1854
|
+
return _this;
|
|
1855
|
+
}
|
|
1856
|
+
return ProcessingInstruction;
|
|
1857
|
+
}(DataNode));
|
|
1858
|
+
node.ProcessingInstruction = ProcessingInstruction;
|
|
1859
|
+
/**
|
|
1860
|
+
* A `Node` that can have children.
|
|
1861
|
+
*/
|
|
1862
|
+
var NodeWithChildren = /** @class */ (function (_super) {
|
|
1863
|
+
__extends(NodeWithChildren, _super);
|
|
1864
|
+
/**
|
|
1865
|
+
* @param type Type of the node.
|
|
1866
|
+
* @param children Children of the node. Only certain node types can have children.
|
|
1867
|
+
*/
|
|
1868
|
+
function NodeWithChildren(type, children) {
|
|
1869
|
+
var _this = _super.call(this, type) || this;
|
|
1870
|
+
_this.children = children;
|
|
1871
|
+
return _this;
|
|
1872
|
+
}
|
|
1873
|
+
Object.defineProperty(NodeWithChildren.prototype, "firstChild", {
|
|
1874
|
+
// Aliases
|
|
1875
|
+
/** First child of the node. */
|
|
1876
|
+
get: function () {
|
|
1877
|
+
var _a;
|
|
1878
|
+
return (_a = this.children[0]) !== null && _a !== void 0 ? _a : null;
|
|
1879
|
+
},
|
|
1880
|
+
enumerable: false,
|
|
1881
|
+
configurable: true
|
|
1882
|
+
});
|
|
1883
|
+
Object.defineProperty(NodeWithChildren.prototype, "lastChild", {
|
|
1884
|
+
/** Last child of the node. */
|
|
1885
|
+
get: function () {
|
|
1886
|
+
return this.children.length > 0
|
|
1887
|
+
? this.children[this.children.length - 1]
|
|
1888
|
+
: null;
|
|
1889
|
+
},
|
|
1890
|
+
enumerable: false,
|
|
1891
|
+
configurable: true
|
|
1892
|
+
});
|
|
1893
|
+
Object.defineProperty(NodeWithChildren.prototype, "childNodes", {
|
|
1894
|
+
/**
|
|
1895
|
+
* Same as {@link children}.
|
|
1896
|
+
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
|
1897
|
+
*/
|
|
1898
|
+
get: function () {
|
|
1899
|
+
return this.children;
|
|
1900
|
+
},
|
|
1901
|
+
set: function (children) {
|
|
1902
|
+
this.children = children;
|
|
1903
|
+
},
|
|
1904
|
+
enumerable: false,
|
|
1905
|
+
configurable: true
|
|
1906
|
+
});
|
|
1907
|
+
return NodeWithChildren;
|
|
1908
|
+
}(Node));
|
|
1909
|
+
node.NodeWithChildren = NodeWithChildren;
|
|
1910
|
+
/**
|
|
1911
|
+
* The root node of the document.
|
|
1912
|
+
*/
|
|
1913
|
+
var Document = /** @class */ (function (_super) {
|
|
1914
|
+
__extends(Document, _super);
|
|
1915
|
+
function Document(children) {
|
|
1916
|
+
return _super.call(this, domelementtype_1.ElementType.Root, children) || this;
|
|
1917
|
+
}
|
|
1918
|
+
return Document;
|
|
1919
|
+
}(NodeWithChildren));
|
|
1920
|
+
node.Document = Document;
|
|
1921
|
+
/**
|
|
1922
|
+
* An element within the DOM.
|
|
1923
|
+
*/
|
|
1924
|
+
var Element = /** @class */ (function (_super) {
|
|
1925
|
+
__extends(Element, _super);
|
|
1926
|
+
/**
|
|
1927
|
+
* @param name Name of the tag, eg. `div`, `span`.
|
|
1928
|
+
* @param attribs Object mapping attribute names to attribute values.
|
|
1929
|
+
* @param children Children of the node.
|
|
1930
|
+
*/
|
|
1931
|
+
function Element(name, attribs, children, type) {
|
|
1932
|
+
if (children === void 0) { children = []; }
|
|
1933
|
+
if (type === void 0) { type = name === "script"
|
|
1934
|
+
? domelementtype_1.ElementType.Script
|
|
1935
|
+
: name === "style"
|
|
1936
|
+
? domelementtype_1.ElementType.Style
|
|
1937
|
+
: domelementtype_1.ElementType.Tag; }
|
|
1938
|
+
var _this = _super.call(this, type, children) || this;
|
|
1939
|
+
_this.name = name;
|
|
1940
|
+
_this.attribs = attribs;
|
|
1941
|
+
return _this;
|
|
1942
|
+
}
|
|
1943
|
+
Object.defineProperty(Element.prototype, "tagName", {
|
|
1944
|
+
// DOM Level 1 aliases
|
|
1945
|
+
/**
|
|
1946
|
+
* Same as {@link name}.
|
|
1947
|
+
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
|
1948
|
+
*/
|
|
1949
|
+
get: function () {
|
|
1950
|
+
return this.name;
|
|
1951
|
+
},
|
|
1952
|
+
set: function (name) {
|
|
1953
|
+
this.name = name;
|
|
1954
|
+
},
|
|
1955
|
+
enumerable: false,
|
|
1956
|
+
configurable: true
|
|
1957
|
+
});
|
|
1958
|
+
Object.defineProperty(Element.prototype, "attributes", {
|
|
1959
|
+
get: function () {
|
|
1960
|
+
var _this = this;
|
|
1961
|
+
return Object.keys(this.attribs).map(function (name) {
|
|
1962
|
+
var _a, _b;
|
|
1963
|
+
return ({
|
|
1964
|
+
name: name,
|
|
1965
|
+
value: _this.attribs[name],
|
|
1966
|
+
namespace: (_a = _this["x-attribsNamespace"]) === null || _a === void 0 ? void 0 : _a[name],
|
|
1967
|
+
prefix: (_b = _this["x-attribsPrefix"]) === null || _b === void 0 ? void 0 : _b[name],
|
|
1968
|
+
});
|
|
1969
|
+
});
|
|
1970
|
+
},
|
|
1971
|
+
enumerable: false,
|
|
1972
|
+
configurable: true
|
|
1973
|
+
});
|
|
1974
|
+
return Element;
|
|
1975
|
+
}(NodeWithChildren));
|
|
1976
|
+
node.Element = Element;
|
|
1977
|
+
/**
|
|
1978
|
+
* @param node Node to check.
|
|
1979
|
+
* @returns `true` if the node is a `Element`, `false` otherwise.
|
|
1980
|
+
*/
|
|
1981
|
+
function isTag(node) {
|
|
1982
|
+
return (0, domelementtype_1.isTag)(node);
|
|
1983
|
+
}
|
|
1984
|
+
node.isTag = isTag;
|
|
1985
|
+
/**
|
|
1986
|
+
* @param node Node to check.
|
|
1987
|
+
* @returns `true` if the node has the type `CDATA`, `false` otherwise.
|
|
1988
|
+
*/
|
|
1989
|
+
function isCDATA(node) {
|
|
1990
|
+
return node.type === domelementtype_1.ElementType.CDATA;
|
|
1991
|
+
}
|
|
1992
|
+
node.isCDATA = isCDATA;
|
|
1993
|
+
/**
|
|
1994
|
+
* @param node Node to check.
|
|
1995
|
+
* @returns `true` if the node has the type `Text`, `false` otherwise.
|
|
1996
|
+
*/
|
|
1997
|
+
function isText(node) {
|
|
1998
|
+
return node.type === domelementtype_1.ElementType.Text;
|
|
1999
|
+
}
|
|
2000
|
+
node.isText = isText;
|
|
2001
|
+
/**
|
|
2002
|
+
* @param node Node to check.
|
|
2003
|
+
* @returns `true` if the node has the type `Comment`, `false` otherwise.
|
|
2004
|
+
*/
|
|
2005
|
+
function isComment(node) {
|
|
2006
|
+
return node.type === domelementtype_1.ElementType.Comment;
|
|
2007
|
+
}
|
|
2008
|
+
node.isComment = isComment;
|
|
2009
|
+
/**
|
|
2010
|
+
* @param node Node to check.
|
|
2011
|
+
* @returns `true` if the node has the type `ProcessingInstruction`, `false` otherwise.
|
|
2012
|
+
*/
|
|
2013
|
+
function isDirective(node) {
|
|
2014
|
+
return node.type === domelementtype_1.ElementType.Directive;
|
|
2015
|
+
}
|
|
2016
|
+
node.isDirective = isDirective;
|
|
2017
|
+
/**
|
|
2018
|
+
* @param node Node to check.
|
|
2019
|
+
* @returns `true` if the node has the type `ProcessingInstruction`, `false` otherwise.
|
|
2020
|
+
*/
|
|
2021
|
+
function isDocument(node) {
|
|
2022
|
+
return node.type === domelementtype_1.ElementType.Root;
|
|
2023
|
+
}
|
|
2024
|
+
node.isDocument = isDocument;
|
|
2025
|
+
/**
|
|
2026
|
+
* @param node Node to check.
|
|
2027
|
+
* @returns `true` if the node is a `NodeWithChildren` (has children), `false` otherwise.
|
|
2028
|
+
*/
|
|
2029
|
+
function hasChildren(node) {
|
|
2030
|
+
return Object.prototype.hasOwnProperty.call(node, "children");
|
|
2031
|
+
}
|
|
2032
|
+
node.hasChildren = hasChildren;
|
|
2033
|
+
/**
|
|
2034
|
+
* Clone a node, and optionally its children.
|
|
2035
|
+
*
|
|
2036
|
+
* @param recursive Clone child nodes as well.
|
|
2037
|
+
* @returns A clone of the node.
|
|
2038
|
+
*/
|
|
2039
|
+
function cloneNode(node, recursive) {
|
|
2040
|
+
if (recursive === void 0) { recursive = false; }
|
|
2041
|
+
var result;
|
|
2042
|
+
if (isText(node)) {
|
|
2043
|
+
result = new Text(node.data);
|
|
2044
|
+
}
|
|
2045
|
+
else if (isComment(node)) {
|
|
2046
|
+
result = new Comment(node.data);
|
|
2047
|
+
}
|
|
2048
|
+
else if (isTag(node)) {
|
|
2049
|
+
var children = recursive ? cloneChildren(node.children) : [];
|
|
2050
|
+
var clone_1 = new Element(node.name, __assign({}, node.attribs), children);
|
|
2051
|
+
children.forEach(function (child) { return (child.parent = clone_1); });
|
|
2052
|
+
if (node.namespace != null) {
|
|
2053
|
+
clone_1.namespace = node.namespace;
|
|
2054
|
+
}
|
|
2055
|
+
if (node["x-attribsNamespace"]) {
|
|
2056
|
+
clone_1["x-attribsNamespace"] = __assign({}, node["x-attribsNamespace"]);
|
|
2057
|
+
}
|
|
2058
|
+
if (node["x-attribsPrefix"]) {
|
|
2059
|
+
clone_1["x-attribsPrefix"] = __assign({}, node["x-attribsPrefix"]);
|
|
2060
|
+
}
|
|
2061
|
+
result = clone_1;
|
|
2062
|
+
}
|
|
2063
|
+
else if (isCDATA(node)) {
|
|
2064
|
+
var children = recursive ? cloneChildren(node.children) : [];
|
|
2065
|
+
var clone_2 = new NodeWithChildren(domelementtype_1.ElementType.CDATA, children);
|
|
2066
|
+
children.forEach(function (child) { return (child.parent = clone_2); });
|
|
2067
|
+
result = clone_2;
|
|
2068
|
+
}
|
|
2069
|
+
else if (isDocument(node)) {
|
|
2070
|
+
var children = recursive ? cloneChildren(node.children) : [];
|
|
2071
|
+
var clone_3 = new Document(children);
|
|
2072
|
+
children.forEach(function (child) { return (child.parent = clone_3); });
|
|
2073
|
+
if (node["x-mode"]) {
|
|
2074
|
+
clone_3["x-mode"] = node["x-mode"];
|
|
2075
|
+
}
|
|
2076
|
+
result = clone_3;
|
|
2077
|
+
}
|
|
2078
|
+
else if (isDirective(node)) {
|
|
2079
|
+
var instruction = new ProcessingInstruction(node.name, node.data);
|
|
2080
|
+
if (node["x-name"] != null) {
|
|
2081
|
+
instruction["x-name"] = node["x-name"];
|
|
2082
|
+
instruction["x-publicId"] = node["x-publicId"];
|
|
2083
|
+
instruction["x-systemId"] = node["x-systemId"];
|
|
2084
|
+
}
|
|
2085
|
+
result = instruction;
|
|
2086
|
+
}
|
|
2087
|
+
else {
|
|
2088
|
+
throw new Error("Not implemented yet: ".concat(node.type));
|
|
2089
|
+
}
|
|
2090
|
+
result.startIndex = node.startIndex;
|
|
2091
|
+
result.endIndex = node.endIndex;
|
|
2092
|
+
if (node.sourceCodeLocation != null) {
|
|
2093
|
+
result.sourceCodeLocation = node.sourceCodeLocation;
|
|
2094
|
+
}
|
|
2095
|
+
return result;
|
|
2096
|
+
}
|
|
2097
|
+
node.cloneNode = cloneNode;
|
|
2098
|
+
function cloneChildren(childs) {
|
|
2099
|
+
var children = childs.map(function (child) { return cloneNode(child, true); });
|
|
2100
|
+
for (var i = 1; i < children.length; i++) {
|
|
2101
|
+
children[i].prev = children[i - 1];
|
|
2102
|
+
children[i - 1].next = children[i];
|
|
2103
|
+
}
|
|
2104
|
+
return children;
|
|
2105
|
+
}
|
|
2106
|
+
return node;
|
|
2089
2107
|
}
|
|
2090
2108
|
|
|
2091
2109
|
var constants = constants$1;
|
|
2092
|
-
var domhandler =
|
|
2110
|
+
var domhandler = requireNode();
|
|
2093
2111
|
|
|
2094
2112
|
var CASE_SENSITIVE_TAG_NAMES = constants.CASE_SENSITIVE_TAG_NAMES;
|
|
2095
2113
|
|
|
@@ -2431,6 +2449,193 @@
|
|
|
2431
2449
|
|
|
2432
2450
|
var htmlToDom = HTMLDOMParser;
|
|
2433
2451
|
|
|
2452
|
+
var lib = {};
|
|
2453
|
+
|
|
2454
|
+
var hasRequiredLib;
|
|
2455
|
+
|
|
2456
|
+
function requireLib () {
|
|
2457
|
+
if (hasRequiredLib) return lib;
|
|
2458
|
+
hasRequiredLib = 1;
|
|
2459
|
+
(function (exports) {
|
|
2460
|
+
var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
2461
|
+
if (k2 === undefined) k2 = k;
|
|
2462
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
2463
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
2464
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
2465
|
+
}
|
|
2466
|
+
Object.defineProperty(o, k2, desc);
|
|
2467
|
+
}) : (function(o, m, k, k2) {
|
|
2468
|
+
if (k2 === undefined) k2 = k;
|
|
2469
|
+
o[k2] = m[k];
|
|
2470
|
+
}));
|
|
2471
|
+
var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
|
|
2472
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
2473
|
+
};
|
|
2474
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2475
|
+
exports.DomHandler = void 0;
|
|
2476
|
+
var domelementtype_1 = requireLib$1();
|
|
2477
|
+
var node_1 = requireNode();
|
|
2478
|
+
__exportStar(requireNode(), exports);
|
|
2479
|
+
var reWhitespace = /\s+/g;
|
|
2480
|
+
// Default options
|
|
2481
|
+
var defaultOpts = {
|
|
2482
|
+
normalizeWhitespace: false,
|
|
2483
|
+
withStartIndices: false,
|
|
2484
|
+
withEndIndices: false,
|
|
2485
|
+
xmlMode: false,
|
|
2486
|
+
};
|
|
2487
|
+
var DomHandler = /** @class */ (function () {
|
|
2488
|
+
/**
|
|
2489
|
+
* @param callback Called once parsing has completed.
|
|
2490
|
+
* @param options Settings for the handler.
|
|
2491
|
+
* @param elementCB Callback whenever a tag is closed.
|
|
2492
|
+
*/
|
|
2493
|
+
function DomHandler(callback, options, elementCB) {
|
|
2494
|
+
/** The elements of the DOM */
|
|
2495
|
+
this.dom = [];
|
|
2496
|
+
/** The root element for the DOM */
|
|
2497
|
+
this.root = new node_1.Document(this.dom);
|
|
2498
|
+
/** Indicated whether parsing has been completed. */
|
|
2499
|
+
this.done = false;
|
|
2500
|
+
/** Stack of open tags. */
|
|
2501
|
+
this.tagStack = [this.root];
|
|
2502
|
+
/** A data node that is still being written to. */
|
|
2503
|
+
this.lastNode = null;
|
|
2504
|
+
/** Reference to the parser instance. Used for location information. */
|
|
2505
|
+
this.parser = null;
|
|
2506
|
+
// Make it possible to skip arguments, for backwards-compatibility
|
|
2507
|
+
if (typeof options === "function") {
|
|
2508
|
+
elementCB = options;
|
|
2509
|
+
options = defaultOpts;
|
|
2510
|
+
}
|
|
2511
|
+
if (typeof callback === "object") {
|
|
2512
|
+
options = callback;
|
|
2513
|
+
callback = undefined;
|
|
2514
|
+
}
|
|
2515
|
+
this.callback = callback !== null && callback !== void 0 ? callback : null;
|
|
2516
|
+
this.options = options !== null && options !== void 0 ? options : defaultOpts;
|
|
2517
|
+
this.elementCB = elementCB !== null && elementCB !== void 0 ? elementCB : null;
|
|
2518
|
+
}
|
|
2519
|
+
DomHandler.prototype.onparserinit = function (parser) {
|
|
2520
|
+
this.parser = parser;
|
|
2521
|
+
};
|
|
2522
|
+
// Resets the handler back to starting state
|
|
2523
|
+
DomHandler.prototype.onreset = function () {
|
|
2524
|
+
this.dom = [];
|
|
2525
|
+
this.root = new node_1.Document(this.dom);
|
|
2526
|
+
this.done = false;
|
|
2527
|
+
this.tagStack = [this.root];
|
|
2528
|
+
this.lastNode = null;
|
|
2529
|
+
this.parser = null;
|
|
2530
|
+
};
|
|
2531
|
+
// Signals the handler that parsing is done
|
|
2532
|
+
DomHandler.prototype.onend = function () {
|
|
2533
|
+
if (this.done)
|
|
2534
|
+
return;
|
|
2535
|
+
this.done = true;
|
|
2536
|
+
this.parser = null;
|
|
2537
|
+
this.handleCallback(null);
|
|
2538
|
+
};
|
|
2539
|
+
DomHandler.prototype.onerror = function (error) {
|
|
2540
|
+
this.handleCallback(error);
|
|
2541
|
+
};
|
|
2542
|
+
DomHandler.prototype.onclosetag = function () {
|
|
2543
|
+
this.lastNode = null;
|
|
2544
|
+
var elem = this.tagStack.pop();
|
|
2545
|
+
if (this.options.withEndIndices) {
|
|
2546
|
+
elem.endIndex = this.parser.endIndex;
|
|
2547
|
+
}
|
|
2548
|
+
if (this.elementCB)
|
|
2549
|
+
this.elementCB(elem);
|
|
2550
|
+
};
|
|
2551
|
+
DomHandler.prototype.onopentag = function (name, attribs) {
|
|
2552
|
+
var type = this.options.xmlMode ? domelementtype_1.ElementType.Tag : undefined;
|
|
2553
|
+
var element = new node_1.Element(name, attribs, undefined, type);
|
|
2554
|
+
this.addNode(element);
|
|
2555
|
+
this.tagStack.push(element);
|
|
2556
|
+
};
|
|
2557
|
+
DomHandler.prototype.ontext = function (data) {
|
|
2558
|
+
var normalizeWhitespace = this.options.normalizeWhitespace;
|
|
2559
|
+
var lastNode = this.lastNode;
|
|
2560
|
+
if (lastNode && lastNode.type === domelementtype_1.ElementType.Text) {
|
|
2561
|
+
if (normalizeWhitespace) {
|
|
2562
|
+
lastNode.data = (lastNode.data + data).replace(reWhitespace, " ");
|
|
2563
|
+
}
|
|
2564
|
+
else {
|
|
2565
|
+
lastNode.data += data;
|
|
2566
|
+
}
|
|
2567
|
+
if (this.options.withEndIndices) {
|
|
2568
|
+
lastNode.endIndex = this.parser.endIndex;
|
|
2569
|
+
}
|
|
2570
|
+
}
|
|
2571
|
+
else {
|
|
2572
|
+
if (normalizeWhitespace) {
|
|
2573
|
+
data = data.replace(reWhitespace, " ");
|
|
2574
|
+
}
|
|
2575
|
+
var node = new node_1.Text(data);
|
|
2576
|
+
this.addNode(node);
|
|
2577
|
+
this.lastNode = node;
|
|
2578
|
+
}
|
|
2579
|
+
};
|
|
2580
|
+
DomHandler.prototype.oncomment = function (data) {
|
|
2581
|
+
if (this.lastNode && this.lastNode.type === domelementtype_1.ElementType.Comment) {
|
|
2582
|
+
this.lastNode.data += data;
|
|
2583
|
+
return;
|
|
2584
|
+
}
|
|
2585
|
+
var node = new node_1.Comment(data);
|
|
2586
|
+
this.addNode(node);
|
|
2587
|
+
this.lastNode = node;
|
|
2588
|
+
};
|
|
2589
|
+
DomHandler.prototype.oncommentend = function () {
|
|
2590
|
+
this.lastNode = null;
|
|
2591
|
+
};
|
|
2592
|
+
DomHandler.prototype.oncdatastart = function () {
|
|
2593
|
+
var text = new node_1.Text("");
|
|
2594
|
+
var node = new node_1.NodeWithChildren(domelementtype_1.ElementType.CDATA, [text]);
|
|
2595
|
+
this.addNode(node);
|
|
2596
|
+
text.parent = node;
|
|
2597
|
+
this.lastNode = text;
|
|
2598
|
+
};
|
|
2599
|
+
DomHandler.prototype.oncdataend = function () {
|
|
2600
|
+
this.lastNode = null;
|
|
2601
|
+
};
|
|
2602
|
+
DomHandler.prototype.onprocessinginstruction = function (name, data) {
|
|
2603
|
+
var node = new node_1.ProcessingInstruction(name, data);
|
|
2604
|
+
this.addNode(node);
|
|
2605
|
+
};
|
|
2606
|
+
DomHandler.prototype.handleCallback = function (error) {
|
|
2607
|
+
if (typeof this.callback === "function") {
|
|
2608
|
+
this.callback(error, this.dom);
|
|
2609
|
+
}
|
|
2610
|
+
else if (error) {
|
|
2611
|
+
throw error;
|
|
2612
|
+
}
|
|
2613
|
+
};
|
|
2614
|
+
DomHandler.prototype.addNode = function (node) {
|
|
2615
|
+
var parent = this.tagStack[this.tagStack.length - 1];
|
|
2616
|
+
var previousSibling = parent.children[parent.children.length - 1];
|
|
2617
|
+
if (this.options.withStartIndices) {
|
|
2618
|
+
node.startIndex = this.parser.startIndex;
|
|
2619
|
+
}
|
|
2620
|
+
if (this.options.withEndIndices) {
|
|
2621
|
+
node.endIndex = this.parser.endIndex;
|
|
2622
|
+
}
|
|
2623
|
+
parent.children.push(node);
|
|
2624
|
+
if (previousSibling) {
|
|
2625
|
+
node.prev = previousSibling;
|
|
2626
|
+
previousSibling.next = node;
|
|
2627
|
+
}
|
|
2628
|
+
node.parent = parent;
|
|
2629
|
+
this.lastNode = null;
|
|
2630
|
+
};
|
|
2631
|
+
return DomHandler;
|
|
2632
|
+
}());
|
|
2633
|
+
exports.DomHandler = DomHandler;
|
|
2634
|
+
exports.default = DomHandler;
|
|
2635
|
+
} (lib));
|
|
2636
|
+
return lib;
|
|
2637
|
+
}
|
|
2638
|
+
|
|
2434
2639
|
var domToReact = domToReact_1;
|
|
2435
2640
|
var attributesToProps = attributesToProps$2;
|
|
2436
2641
|
var htmlToDOM = htmlToDom;
|
|
@@ -2445,12 +2650,12 @@
|
|
|
2445
2650
|
/**
|
|
2446
2651
|
* Converts HTML string to React elements.
|
|
2447
2652
|
*
|
|
2448
|
-
* @param
|
|
2449
|
-
* @param
|
|
2450
|
-
* @param
|
|
2451
|
-
* @param
|
|
2452
|
-
* @param
|
|
2453
|
-
* @
|
|
2653
|
+
* @param {string} html - HTML string.
|
|
2654
|
+
* @param {object} [options] - Parser options.
|
|
2655
|
+
* @param {object} [options.htmlparser2] - htmlparser2 options.
|
|
2656
|
+
* @param {object} [options.library] - Library for React, Preact, etc.
|
|
2657
|
+
* @param {Function} [options.replace] - Replace method.
|
|
2658
|
+
* @returns {JSX.Element|JSX.Element[]|string} - React element(s), empty array, or string.
|
|
2454
2659
|
*/
|
|
2455
2660
|
function HTMLReactParser(html, options) {
|
|
2456
2661
|
if (typeof html !== 'string') {
|
|
@@ -2469,15 +2674,13 @@
|
|
|
2469
2674
|
HTMLReactParser.domToReact = domToReact;
|
|
2470
2675
|
HTMLReactParser.htmlToDOM = htmlToDOM;
|
|
2471
2676
|
HTMLReactParser.attributesToProps = attributesToProps;
|
|
2472
|
-
HTMLReactParser.Element =
|
|
2677
|
+
HTMLReactParser.Element = requireLib().Element;
|
|
2473
2678
|
|
|
2474
2679
|
// support CommonJS and ES Modules
|
|
2475
|
-
htmlReactParser
|
|
2476
|
-
htmlReactParser
|
|
2477
|
-
|
|
2478
|
-
var htmlReactParser = htmlReactParser$1.exports;
|
|
2680
|
+
htmlReactParser.exports = HTMLReactParser;
|
|
2681
|
+
htmlReactParser.exports.default = HTMLReactParser;
|
|
2479
2682
|
|
|
2480
|
-
return htmlReactParser;
|
|
2683
|
+
return htmlReactParser.exports;
|
|
2481
2684
|
|
|
2482
2685
|
}));
|
|
2483
2686
|
//# sourceMappingURL=html-react-parser.js.map
|