html-react-parser 2.0.0 → 3.0.0

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.
@@ -1701,58 +1701,16 @@
1701
1701
 
1702
1702
  var domparser_1 = domparser$1;
1703
1703
 
1704
- /**
1705
- * SVG elements are case-sensitive.
1706
- *
1707
- * @see {@link https://developer.mozilla.org/docs/Web/SVG/Element#SVG_elements_A_to_Z}
1708
- */
1709
-
1710
- var CASE_SENSITIVE_TAG_NAMES$1 = [
1711
- 'animateMotion',
1712
- 'animateTransform',
1713
- 'clipPath',
1714
- 'feBlend',
1715
- 'feColorMatrix',
1716
- 'feComponentTransfer',
1717
- 'feComposite',
1718
- 'feConvolveMatrix',
1719
- 'feDiffuseLighting',
1720
- 'feDisplacementMap',
1721
- 'feDropShadow',
1722
- 'feFlood',
1723
- 'feFuncA',
1724
- 'feFuncB',
1725
- 'feFuncG',
1726
- 'feFuncR',
1727
- 'feGaussainBlur',
1728
- 'feImage',
1729
- 'feMerge',
1730
- 'feMergeNode',
1731
- 'feMorphology',
1732
- 'feOffset',
1733
- 'fePointLight',
1734
- 'feSpecularLighting',
1735
- 'feSpotLight',
1736
- 'feTile',
1737
- 'feTurbulence',
1738
- 'foreignObject',
1739
- 'linearGradient',
1740
- 'radialGradient',
1741
- 'textPath'
1742
- ];
1743
-
1744
- var constants$1 = {
1745
- CASE_SENSITIVE_TAG_NAMES: CASE_SENSITIVE_TAG_NAMES$1
1746
- };
1747
-
1748
- var node = {};
1704
+ var utilities = {};
1749
1705
 
1750
1706
  var lib$1 = {};
1751
1707
 
1708
+ var lib = {};
1709
+
1752
1710
  var hasRequiredLib$1;
1753
1711
 
1754
1712
  function requireLib$1 () {
1755
- if (hasRequiredLib$1) return lib$1;
1713
+ if (hasRequiredLib$1) return lib;
1756
1714
  hasRequiredLib$1 = 1;
1757
1715
  (function (exports) {
1758
1716
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -1809,10 +1767,12 @@
1809
1767
  exports.CDATA = ElementType.CDATA;
1810
1768
  /** Type for <!doctype ...> */
1811
1769
  exports.Doctype = ElementType.Doctype;
1812
- } (lib$1));
1813
- return lib$1;
1770
+ } (lib));
1771
+ return lib;
1814
1772
  }
1815
1773
 
1774
+ var node = {};
1775
+
1816
1776
  var hasRequiredNode;
1817
1777
 
1818
1778
  function requireNode () {
@@ -1845,29 +1805,14 @@
1845
1805
  return __assign.apply(this, arguments);
1846
1806
  };
1847
1807
  Object.defineProperty(node, "__esModule", { value: true });
1848
- 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;
1808
+ node.cloneNode = node.hasChildren = node.isDocument = node.isDirective = node.isComment = node.isText = node.isCDATA = node.isTag = node.Element = node.Document = node.CDATA = node.NodeWithChildren = node.ProcessingInstruction = node.Comment = node.Text = node.DataNode = node.Node = void 0;
1849
1809
  var domelementtype_1 = requireLib$1();
1850
- var nodeTypes = new Map([
1851
- [domelementtype_1.ElementType.Tag, 1],
1852
- [domelementtype_1.ElementType.Script, 1],
1853
- [domelementtype_1.ElementType.Style, 1],
1854
- [domelementtype_1.ElementType.Directive, 1],
1855
- [domelementtype_1.ElementType.Text, 3],
1856
- [domelementtype_1.ElementType.CDATA, 4],
1857
- [domelementtype_1.ElementType.Comment, 8],
1858
- [domelementtype_1.ElementType.Root, 9],
1859
- ]);
1860
1810
  /**
1861
1811
  * This object will be used as the prototype for Nodes when creating a
1862
1812
  * DOM-Level-1-compliant structure.
1863
1813
  */
1864
1814
  var Node = /** @class */ (function () {
1865
- /**
1866
- *
1867
- * @param type The type of the node.
1868
- */
1869
- function Node(type) {
1870
- this.type = type;
1815
+ function Node() {
1871
1816
  /** Parent of the node */
1872
1817
  this.parent = null;
1873
1818
  /** Previous sibling */
@@ -1879,19 +1824,6 @@
1879
1824
  /** The end index of the node. Requires `withEndIndices` on the handler to be `true. */
1880
1825
  this.endIndex = null;
1881
1826
  }
1882
- Object.defineProperty(Node.prototype, "nodeType", {
1883
- // Read-only aliases
1884
- /**
1885
- * [DOM spec](https://dom.spec.whatwg.org/#dom-node-nodetype)-compatible
1886
- * node {@link type}.
1887
- */
1888
- get: function () {
1889
- var _a;
1890
- return (_a = nodeTypes.get(this.type)) !== null && _a !== void 0 ? _a : 1;
1891
- },
1892
- enumerable: false,
1893
- configurable: true
1894
- });
1895
1827
  Object.defineProperty(Node.prototype, "parentNode", {
1896
1828
  // Read-write aliases for properties
1897
1829
  /**
@@ -1954,11 +1886,10 @@
1954
1886
  var DataNode = /** @class */ (function (_super) {
1955
1887
  __extends(DataNode, _super);
1956
1888
  /**
1957
- * @param type The type of the node
1958
1889
  * @param data The content of the data node
1959
1890
  */
1960
- function DataNode(type, data) {
1961
- var _this = _super.call(this, type) || this;
1891
+ function DataNode(data) {
1892
+ var _this = _super.call(this) || this;
1962
1893
  _this.data = data;
1963
1894
  return _this;
1964
1895
  }
@@ -1984,9 +1915,18 @@
1984
1915
  */
1985
1916
  var Text = /** @class */ (function (_super) {
1986
1917
  __extends(Text, _super);
1987
- function Text(data) {
1988
- return _super.call(this, domelementtype_1.ElementType.Text, data) || this;
1918
+ function Text() {
1919
+ var _this = _super !== null && _super.apply(this, arguments) || this;
1920
+ _this.type = domelementtype_1.ElementType.Text;
1921
+ return _this;
1989
1922
  }
1923
+ Object.defineProperty(Text.prototype, "nodeType", {
1924
+ get: function () {
1925
+ return 3;
1926
+ },
1927
+ enumerable: false,
1928
+ configurable: true
1929
+ });
1990
1930
  return Text;
1991
1931
  }(DataNode));
1992
1932
  node.Text = Text;
@@ -1995,9 +1935,18 @@
1995
1935
  */
1996
1936
  var Comment = /** @class */ (function (_super) {
1997
1937
  __extends(Comment, _super);
1998
- function Comment(data) {
1999
- return _super.call(this, domelementtype_1.ElementType.Comment, data) || this;
1938
+ function Comment() {
1939
+ var _this = _super !== null && _super.apply(this, arguments) || this;
1940
+ _this.type = domelementtype_1.ElementType.Comment;
1941
+ return _this;
2000
1942
  }
1943
+ Object.defineProperty(Comment.prototype, "nodeType", {
1944
+ get: function () {
1945
+ return 8;
1946
+ },
1947
+ enumerable: false,
1948
+ configurable: true
1949
+ });
2001
1950
  return Comment;
2002
1951
  }(DataNode));
2003
1952
  node.Comment = Comment;
@@ -2007,10 +1956,18 @@
2007
1956
  var ProcessingInstruction = /** @class */ (function (_super) {
2008
1957
  __extends(ProcessingInstruction, _super);
2009
1958
  function ProcessingInstruction(name, data) {
2010
- var _this = _super.call(this, domelementtype_1.ElementType.Directive, data) || this;
1959
+ var _this = _super.call(this, data) || this;
2011
1960
  _this.name = name;
1961
+ _this.type = domelementtype_1.ElementType.Directive;
2012
1962
  return _this;
2013
1963
  }
1964
+ Object.defineProperty(ProcessingInstruction.prototype, "nodeType", {
1965
+ get: function () {
1966
+ return 1;
1967
+ },
1968
+ enumerable: false,
1969
+ configurable: true
1970
+ });
2014
1971
  return ProcessingInstruction;
2015
1972
  }(DataNode));
2016
1973
  node.ProcessingInstruction = ProcessingInstruction;
@@ -2020,11 +1977,10 @@
2020
1977
  var NodeWithChildren = /** @class */ (function (_super) {
2021
1978
  __extends(NodeWithChildren, _super);
2022
1979
  /**
2023
- * @param type Type of the node.
2024
1980
  * @param children Children of the node. Only certain node types can have children.
2025
1981
  */
2026
- function NodeWithChildren(type, children) {
2027
- var _this = _super.call(this, type) || this;
1982
+ function NodeWithChildren(children) {
1983
+ var _this = _super.call(this) || this;
2028
1984
  _this.children = children;
2029
1985
  return _this;
2030
1986
  }
@@ -2065,14 +2021,40 @@
2065
2021
  return NodeWithChildren;
2066
2022
  }(Node));
2067
2023
  node.NodeWithChildren = NodeWithChildren;
2024
+ var CDATA = /** @class */ (function (_super) {
2025
+ __extends(CDATA, _super);
2026
+ function CDATA() {
2027
+ var _this = _super !== null && _super.apply(this, arguments) || this;
2028
+ _this.type = domelementtype_1.ElementType.CDATA;
2029
+ return _this;
2030
+ }
2031
+ Object.defineProperty(CDATA.prototype, "nodeType", {
2032
+ get: function () {
2033
+ return 4;
2034
+ },
2035
+ enumerable: false,
2036
+ configurable: true
2037
+ });
2038
+ return CDATA;
2039
+ }(NodeWithChildren));
2040
+ node.CDATA = CDATA;
2068
2041
  /**
2069
2042
  * The root node of the document.
2070
2043
  */
2071
2044
  var Document = /** @class */ (function (_super) {
2072
2045
  __extends(Document, _super);
2073
- function Document(children) {
2074
- return _super.call(this, domelementtype_1.ElementType.Root, children) || this;
2046
+ function Document() {
2047
+ var _this = _super !== null && _super.apply(this, arguments) || this;
2048
+ _this.type = domelementtype_1.ElementType.Root;
2049
+ return _this;
2075
2050
  }
2051
+ Object.defineProperty(Document.prototype, "nodeType", {
2052
+ get: function () {
2053
+ return 9;
2054
+ },
2055
+ enumerable: false,
2056
+ configurable: true
2057
+ });
2076
2058
  return Document;
2077
2059
  }(NodeWithChildren));
2078
2060
  node.Document = Document;
@@ -2093,11 +2075,19 @@
2093
2075
  : name === "style"
2094
2076
  ? domelementtype_1.ElementType.Style
2095
2077
  : domelementtype_1.ElementType.Tag; }
2096
- var _this = _super.call(this, type, children) || this;
2078
+ var _this = _super.call(this, children) || this;
2097
2079
  _this.name = name;
2098
2080
  _this.attribs = attribs;
2081
+ _this.type = type;
2099
2082
  return _this;
2100
2083
  }
2084
+ Object.defineProperty(Element.prototype, "nodeType", {
2085
+ get: function () {
2086
+ return 1;
2087
+ },
2088
+ enumerable: false,
2089
+ configurable: true
2090
+ });
2101
2091
  Object.defineProperty(Element.prototype, "tagName", {
2102
2092
  // DOM Level 1 aliases
2103
2093
  /**
@@ -2182,7 +2172,7 @@
2182
2172
  node.isDocument = isDocument;
2183
2173
  /**
2184
2174
  * @param node Node to check.
2185
- * @returns `true` if the node is a `NodeWithChildren` (has children), `false` otherwise.
2175
+ * @returns `true` if the node has children, `false` otherwise.
2186
2176
  */
2187
2177
  function hasChildren(node) {
2188
2178
  return Object.prototype.hasOwnProperty.call(node, "children");
@@ -2220,7 +2210,7 @@
2220
2210
  }
2221
2211
  else if (isCDATA(node)) {
2222
2212
  var children = recursive ? cloneChildren(node.children) : [];
2223
- var clone_2 = new NodeWithChildren(domelementtype_1.ElementType.CDATA, children);
2213
+ var clone_2 = new CDATA(children);
2224
2214
  children.forEach(function (child) { return (child.parent = clone_2); });
2225
2215
  result = clone_2;
2226
2216
  }
@@ -2264,181 +2254,10 @@
2264
2254
  return node;
2265
2255
  }
2266
2256
 
2267
- var constants = constants$1;
2268
- var domhandler = requireNode();
2269
-
2270
- var CASE_SENSITIVE_TAG_NAMES = constants.CASE_SENSITIVE_TAG_NAMES;
2271
-
2272
- var Comment = domhandler.Comment;
2273
- var Element = domhandler.Element;
2274
- var ProcessingInstruction = domhandler.ProcessingInstruction;
2275
- var Text = domhandler.Text;
2276
-
2277
- var caseSensitiveTagNamesMap = {};
2278
- var tagName;
2279
-
2280
- for (var i = 0, len = CASE_SENSITIVE_TAG_NAMES.length; i < len; i++) {
2281
- tagName = CASE_SENSITIVE_TAG_NAMES[i];
2282
- caseSensitiveTagNamesMap[tagName.toLowerCase()] = tagName;
2283
- }
2284
-
2285
- /**
2286
- * Gets case-sensitive tag name.
2287
- *
2288
- * @param {string} tagName - Tag name in lowercase.
2289
- * @return {string|undefined} - Case-sensitive tag name.
2290
- */
2291
- function getCaseSensitiveTagName(tagName) {
2292
- return caseSensitiveTagNamesMap[tagName];
2293
- }
2294
-
2295
- /**
2296
- * Formats DOM attributes to a hash map.
2297
- *
2298
- * @param {NamedNodeMap} attributes - List of attributes.
2299
- * @return {object} - Map of attribute name to value.
2300
- */
2301
- function formatAttributes(attributes) {
2302
- var result = {};
2303
- var attribute;
2304
- // `NamedNodeMap` is array-like
2305
- for (var i = 0, len = attributes.length; i < len; i++) {
2306
- attribute = attributes[i];
2307
- result[attribute.name] = attribute.value;
2308
- }
2309
- return result;
2310
- }
2311
-
2312
- /**
2313
- * Corrects the tag name if it is case-sensitive (SVG).
2314
- * Otherwise, returns the lowercase tag name (HTML).
2315
- *
2316
- * @param {string} tagName - Lowercase tag name.
2317
- * @return {string} - Formatted tag name.
2318
- */
2319
- function formatTagName(tagName) {
2320
- tagName = tagName.toLowerCase();
2321
- var caseSensitiveTagName = getCaseSensitiveTagName(tagName);
2322
- if (caseSensitiveTagName) {
2323
- return caseSensitiveTagName;
2324
- }
2325
- return tagName;
2326
- }
2327
-
2328
- /**
2329
- * Transforms DOM nodes to `domhandler` nodes.
2330
- *
2331
- * @param {NodeList} nodes - DOM nodes.
2332
- * @param {Element|null} [parent=null] - Parent node.
2333
- * @param {string} [directive] - Directive.
2334
- * @return {Array<Comment|Element|ProcessingInstruction|Text>}
2335
- */
2336
- function formatDOM$1(nodes, parent, directive) {
2337
- parent = parent || null;
2338
- var result = [];
2339
-
2340
- for (var index = 0, len = nodes.length; index < len; index++) {
2341
- var node = nodes[index];
2342
- var current;
2343
-
2344
- // set the node data given the type
2345
- switch (node.nodeType) {
2346
- case 1:
2347
- // script, style, or tag
2348
- current = new Element(
2349
- formatTagName(node.nodeName),
2350
- formatAttributes(node.attributes)
2351
- );
2352
- current.children = formatDOM$1(node.childNodes, current);
2353
- break;
2354
-
2355
- case 3:
2356
- current = new Text(node.nodeValue);
2357
- break;
2358
-
2359
- case 8:
2360
- current = new Comment(node.nodeValue);
2361
- break;
2362
-
2363
- default:
2364
- continue;
2365
- }
2366
-
2367
- // set previous node next
2368
- var prev = result[index - 1] || null;
2369
- if (prev) {
2370
- prev.next = current;
2371
- }
2372
-
2373
- // set properties for current node
2374
- current.parent = parent;
2375
- current.prev = prev;
2376
- current.next = null;
2377
-
2378
- result.push(current);
2379
- }
2380
-
2381
- if (directive) {
2382
- current = new ProcessingInstruction(
2383
- directive.substring(0, directive.indexOf(' ')).toLowerCase(),
2384
- directive
2385
- );
2386
- current.next = result[0] || null;
2387
- current.parent = parent;
2388
- result.unshift(current);
2389
-
2390
- if (result[1]) {
2391
- result[1].prev = result[0];
2392
- }
2393
- }
2394
-
2395
- return result;
2396
- }
2397
-
2398
- var utilities = {
2399
- formatAttributes: formatAttributes,
2400
- formatDOM: formatDOM$1
2401
- };
2402
-
2403
- var domparser = domparser_1;
2404
- var formatDOM = utilities.formatDOM;
2405
-
2406
- var DIRECTIVE_REGEX = /<(![a-zA-Z\s]+)>/; // e.g., <!doctype html>
2407
-
2408
- /**
2409
- * Parses HTML string to DOM nodes in browser.
2410
- *
2411
- * @param {string} html - HTML markup.
2412
- * @return {DomElement[]} - DOM elements.
2413
- */
2414
- function HTMLDOMParser(html) {
2415
- if (typeof html !== 'string') {
2416
- throw new TypeError('First argument must be a string');
2417
- }
2418
-
2419
- if (html === '') {
2420
- return [];
2421
- }
2422
-
2423
- // match directive
2424
- var match = html.match(DIRECTIVE_REGEX);
2425
- var directive;
2426
-
2427
- if (match && match[1]) {
2428
- directive = match[1];
2429
- }
2430
-
2431
- return formatDOM(domparser(html), null, directive);
2432
- }
2433
-
2434
- var htmlToDom = HTMLDOMParser;
2435
-
2436
- var lib = {};
2437
-
2438
2257
  var hasRequiredLib;
2439
2258
 
2440
2259
  function requireLib () {
2441
- if (hasRequiredLib) return lib;
2260
+ if (hasRequiredLib) return lib$1;
2442
2261
  hasRequiredLib = 1;
2443
2262
  (function (exports) {
2444
2263
  var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
@@ -2458,12 +2277,10 @@
2458
2277
  Object.defineProperty(exports, "__esModule", { value: true });
2459
2278
  exports.DomHandler = void 0;
2460
2279
  var domelementtype_1 = requireLib$1();
2461
- var node_1 = requireNode();
2280
+ var node_js_1 = requireNode();
2462
2281
  __exportStar(requireNode(), exports);
2463
- var reWhitespace = /\s+/g;
2464
2282
  // Default options
2465
2283
  var defaultOpts = {
2466
- normalizeWhitespace: false,
2467
2284
  withStartIndices: false,
2468
2285
  withEndIndices: false,
2469
2286
  xmlMode: false,
@@ -2478,7 +2295,7 @@
2478
2295
  /** The elements of the DOM */
2479
2296
  this.dom = [];
2480
2297
  /** The root element for the DOM */
2481
- this.root = new node_1.Document(this.dom);
2298
+ this.root = new node_js_1.Document(this.dom);
2482
2299
  /** Indicated whether parsing has been completed. */
2483
2300
  this.done = false;
2484
2301
  /** Stack of open tags. */
@@ -2506,7 +2323,7 @@
2506
2323
  // Resets the handler back to starting state
2507
2324
  DomHandler.prototype.onreset = function () {
2508
2325
  this.dom = [];
2509
- this.root = new node_1.Document(this.dom);
2326
+ this.root = new node_js_1.Document(this.dom);
2510
2327
  this.done = false;
2511
2328
  this.tagStack = [this.root];
2512
2329
  this.lastNode = null;
@@ -2534,29 +2351,20 @@
2534
2351
  };
2535
2352
  DomHandler.prototype.onopentag = function (name, attribs) {
2536
2353
  var type = this.options.xmlMode ? domelementtype_1.ElementType.Tag : undefined;
2537
- var element = new node_1.Element(name, attribs, undefined, type);
2354
+ var element = new node_js_1.Element(name, attribs, undefined, type);
2538
2355
  this.addNode(element);
2539
2356
  this.tagStack.push(element);
2540
2357
  };
2541
2358
  DomHandler.prototype.ontext = function (data) {
2542
- var normalizeWhitespace = this.options.normalizeWhitespace;
2543
2359
  var lastNode = this.lastNode;
2544
2360
  if (lastNode && lastNode.type === domelementtype_1.ElementType.Text) {
2545
- if (normalizeWhitespace) {
2546
- lastNode.data = (lastNode.data + data).replace(reWhitespace, " ");
2547
- }
2548
- else {
2549
- lastNode.data += data;
2550
- }
2361
+ lastNode.data += data;
2551
2362
  if (this.options.withEndIndices) {
2552
2363
  lastNode.endIndex = this.parser.endIndex;
2553
2364
  }
2554
2365
  }
2555
2366
  else {
2556
- if (normalizeWhitespace) {
2557
- data = data.replace(reWhitespace, " ");
2558
- }
2559
- var node = new node_1.Text(data);
2367
+ var node = new node_js_1.Text(data);
2560
2368
  this.addNode(node);
2561
2369
  this.lastNode = node;
2562
2370
  }
@@ -2566,7 +2374,7 @@
2566
2374
  this.lastNode.data += data;
2567
2375
  return;
2568
2376
  }
2569
- var node = new node_1.Comment(data);
2377
+ var node = new node_js_1.Comment(data);
2570
2378
  this.addNode(node);
2571
2379
  this.lastNode = node;
2572
2380
  };
@@ -2574,8 +2382,8 @@
2574
2382
  this.lastNode = null;
2575
2383
  };
2576
2384
  DomHandler.prototype.oncdatastart = function () {
2577
- var text = new node_1.Text("");
2578
- var node = new node_1.NodeWithChildren(domelementtype_1.ElementType.CDATA, [text]);
2385
+ var text = new node_js_1.Text("");
2386
+ var node = new node_js_1.CDATA([text]);
2579
2387
  this.addNode(node);
2580
2388
  text.parent = node;
2581
2389
  this.lastNode = text;
@@ -2584,7 +2392,7 @@
2584
2392
  this.lastNode = null;
2585
2393
  };
2586
2394
  DomHandler.prototype.onprocessinginstruction = function (name, data) {
2587
- var node = new node_1.ProcessingInstruction(name, data);
2395
+ var node = new node_js_1.ProcessingInstruction(name, data);
2588
2396
  this.addNode(node);
2589
2397
  };
2590
2398
  DomHandler.prototype.handleCallback = function (error) {
@@ -2616,10 +2424,219 @@
2616
2424
  }());
2617
2425
  exports.DomHandler = DomHandler;
2618
2426
  exports.default = DomHandler;
2619
- } (lib));
2620
- return lib;
2427
+ } (lib$1));
2428
+ return lib$1;
2429
+ }
2430
+
2431
+ var constants$1 = {};
2432
+
2433
+ /**
2434
+ * SVG elements are case-sensitive.
2435
+ *
2436
+ * @see {@link https://developer.mozilla.org/docs/Web/SVG/Element#svg_elements_a_to_z}
2437
+ */
2438
+
2439
+ constants$1.CASE_SENSITIVE_TAG_NAMES = [
2440
+ 'animateMotion',
2441
+ 'animateTransform',
2442
+ 'clipPath',
2443
+ 'feBlend',
2444
+ 'feColorMatrix',
2445
+ 'feComponentTransfer',
2446
+ 'feComposite',
2447
+ 'feConvolveMatrix',
2448
+ 'feDiffuseLighting',
2449
+ 'feDisplacementMap',
2450
+ 'feDropShadow',
2451
+ 'feFlood',
2452
+ 'feFuncA',
2453
+ 'feFuncB',
2454
+ 'feFuncG',
2455
+ 'feFuncR',
2456
+ 'feGaussainBlur',
2457
+ 'feImage',
2458
+ 'feMerge',
2459
+ 'feMergeNode',
2460
+ 'feMorphology',
2461
+ 'feOffset',
2462
+ 'fePointLight',
2463
+ 'feSpecularLighting',
2464
+ 'feSpotLight',
2465
+ 'feTile',
2466
+ 'feTurbulence',
2467
+ 'foreignObject',
2468
+ 'linearGradient',
2469
+ 'radialGradient',
2470
+ 'textPath'
2471
+ ];
2472
+
2473
+ var domhandler = requireLib();
2474
+ var constants = constants$1;
2475
+
2476
+ var CASE_SENSITIVE_TAG_NAMES = constants.CASE_SENSITIVE_TAG_NAMES;
2477
+
2478
+ var Comment = domhandler.Comment;
2479
+ var Element = domhandler.Element;
2480
+ var ProcessingInstruction = domhandler.ProcessingInstruction;
2481
+ var Text = domhandler.Text;
2482
+
2483
+ var caseSensitiveTagNamesMap = {};
2484
+ var tagName;
2485
+
2486
+ for (var i = 0, len = CASE_SENSITIVE_TAG_NAMES.length; i < len; i++) {
2487
+ tagName = CASE_SENSITIVE_TAG_NAMES[i];
2488
+ caseSensitiveTagNamesMap[tagName.toLowerCase()] = tagName;
2489
+ }
2490
+
2491
+ /**
2492
+ * Gets case-sensitive tag name.
2493
+ *
2494
+ * @param {string} tagName - Tag name in lowercase.
2495
+ * @returns {string|undefined} - Case-sensitive tag name.
2496
+ */
2497
+ function getCaseSensitiveTagName(tagName) {
2498
+ return caseSensitiveTagNamesMap[tagName];
2499
+ }
2500
+
2501
+ /**
2502
+ * Formats DOM attributes to a hash map.
2503
+ *
2504
+ * @param {NamedNodeMap} attributes - List of attributes.
2505
+ * @returns {object} - Map of attribute name to value.
2506
+ */
2507
+ function formatAttributes(attributes) {
2508
+ var result = {};
2509
+ var attribute;
2510
+ // `NamedNodeMap` is array-like
2511
+ for (var i = 0, len = attributes.length; i < len; i++) {
2512
+ attribute = attributes[i];
2513
+ result[attribute.name] = attribute.value;
2514
+ }
2515
+ return result;
2516
+ }
2517
+
2518
+ /**
2519
+ * Corrects the tag name if it is case-sensitive (SVG).
2520
+ * Otherwise, returns the lowercase tag name (HTML).
2521
+ *
2522
+ * @param {string} tagName - Lowercase tag name.
2523
+ * @returns {string} - Formatted tag name.
2524
+ */
2525
+ function formatTagName(tagName) {
2526
+ tagName = tagName.toLowerCase();
2527
+ var caseSensitiveTagName = getCaseSensitiveTagName(tagName);
2528
+ if (caseSensitiveTagName) {
2529
+ return caseSensitiveTagName;
2530
+ }
2531
+ return tagName;
2621
2532
  }
2622
2533
 
2534
+ /**
2535
+ * Transforms DOM nodes to `domhandler` nodes.
2536
+ *
2537
+ * @param {NodeList} nodes - DOM nodes.
2538
+ * @param {Element|null} [parent=null] - Parent node.
2539
+ * @param {string} [directive] - Directive.
2540
+ * @returns {Array<Comment|Element|ProcessingInstruction|Text>}
2541
+ */
2542
+ function formatDOM$1(nodes, parent, directive) {
2543
+ parent = parent || null;
2544
+ var result = [];
2545
+
2546
+ for (var index = 0, len = nodes.length; index < len; index++) {
2547
+ var node = nodes[index];
2548
+ var current;
2549
+
2550
+ // set the node data given the type
2551
+ switch (node.nodeType) {
2552
+ case 1:
2553
+ // script, style, or tag
2554
+ current = new Element(
2555
+ formatTagName(node.nodeName),
2556
+ formatAttributes(node.attributes)
2557
+ );
2558
+ current.children = formatDOM$1(node.childNodes, current);
2559
+ break;
2560
+
2561
+ case 3:
2562
+ current = new Text(node.nodeValue);
2563
+ break;
2564
+
2565
+ case 8:
2566
+ current = new Comment(node.nodeValue);
2567
+ break;
2568
+
2569
+ default:
2570
+ continue;
2571
+ }
2572
+
2573
+ // set previous node next
2574
+ var prev = result[index - 1] || null;
2575
+ if (prev) {
2576
+ prev.next = current;
2577
+ }
2578
+
2579
+ // set properties for current node
2580
+ current.parent = parent;
2581
+ current.prev = prev;
2582
+ current.next = null;
2583
+
2584
+ result.push(current);
2585
+ }
2586
+
2587
+ if (directive) {
2588
+ current = new ProcessingInstruction(
2589
+ directive.substring(0, directive.indexOf(' ')).toLowerCase(),
2590
+ directive
2591
+ );
2592
+ current.next = result[0] || null;
2593
+ current.parent = parent;
2594
+ result.unshift(current);
2595
+
2596
+ if (result[1]) {
2597
+ result[1].prev = result[0];
2598
+ }
2599
+ }
2600
+
2601
+ return result;
2602
+ }
2603
+
2604
+ utilities.formatAttributes = formatAttributes;
2605
+ utilities.formatDOM = formatDOM$1;
2606
+
2607
+ var domparser = domparser_1;
2608
+ var formatDOM = utilities.formatDOM;
2609
+
2610
+ var DIRECTIVE_REGEX = /<(![a-zA-Z\s]+)>/; // e.g., <!doctype html>
2611
+
2612
+ /**
2613
+ * Parses HTML string to DOM nodes in browser.
2614
+ *
2615
+ * @param {string} html - HTML markup.
2616
+ * @return {DomElement[]} - DOM elements.
2617
+ */
2618
+ function HTMLDOMParser(html) {
2619
+ if (typeof html !== 'string') {
2620
+ throw new TypeError('First argument must be a string');
2621
+ }
2622
+
2623
+ if (html === '') {
2624
+ return [];
2625
+ }
2626
+
2627
+ // match directive
2628
+ var match = html.match(DIRECTIVE_REGEX);
2629
+ var directive;
2630
+
2631
+ if (match && match[1]) {
2632
+ directive = match[1];
2633
+ }
2634
+
2635
+ return formatDOM(domparser(html), null, directive);
2636
+ }
2637
+
2638
+ var htmlToDom = HTMLDOMParser;
2639
+
2623
2640
  var domToReact = domToReact_1;
2624
2641
  var attributesToProps = attributesToProps$2;
2625
2642
  var htmlToDOM = htmlToDom;