html-react-parser 0.9.1 → 0.9.2

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.
@@ -1206,46 +1206,46 @@
1206
1206
  var domToReact_1 = domToReact;
1207
1207
 
1208
1208
  /**
1209
- * SVG elements, unlike HTML elements, are case-sensitive.
1209
+ * SVG elements are case-sensitive.
1210
1210
  *
1211
1211
  * @see {@link https://developer.mozilla.org/docs/Web/SVG/Element#SVG_elements_A_to_Z}
1212
1212
  */
1213
1213
  var CASE_SENSITIVE_TAG_NAMES = [
1214
- 'animateMotion',
1215
- 'animateTransform',
1216
- 'clipPath',
1217
- 'feBlend',
1218
- 'feColorMatrix',
1219
- 'feComponentTransfer',
1220
- 'feComposite',
1221
- 'feConvolveMatrix',
1222
- 'feDiffuseLighting',
1223
- 'feDisplacementMap',
1224
- 'feDropShadow',
1225
- 'feFlood',
1226
- 'feFuncA',
1227
- 'feFuncB',
1228
- 'feFuncG',
1229
- 'feFuncR',
1230
- 'feGaussainBlur',
1231
- 'feImage',
1232
- 'feMerge',
1233
- 'feMergeNode',
1234
- 'feMorphology',
1235
- 'feOffset',
1236
- 'fePointLight',
1237
- 'feSpecularLighting',
1238
- 'feSpotLight',
1239
- 'feTile',
1240
- 'feTurbulence',
1241
- 'foreignObject',
1242
- 'linearGradient',
1243
- 'radialGradient',
1244
- 'textPath'
1214
+ 'animateMotion',
1215
+ 'animateTransform',
1216
+ 'clipPath',
1217
+ 'feBlend',
1218
+ 'feColorMatrix',
1219
+ 'feComponentTransfer',
1220
+ 'feComposite',
1221
+ 'feConvolveMatrix',
1222
+ 'feDiffuseLighting',
1223
+ 'feDisplacementMap',
1224
+ 'feDropShadow',
1225
+ 'feFlood',
1226
+ 'feFuncA',
1227
+ 'feFuncB',
1228
+ 'feFuncG',
1229
+ 'feFuncR',
1230
+ 'feGaussainBlur',
1231
+ 'feImage',
1232
+ 'feMerge',
1233
+ 'feMergeNode',
1234
+ 'feMorphology',
1235
+ 'feOffset',
1236
+ 'fePointLight',
1237
+ 'feSpecularLighting',
1238
+ 'feSpotLight',
1239
+ 'feTile',
1240
+ 'feTurbulence',
1241
+ 'foreignObject',
1242
+ 'linearGradient',
1243
+ 'radialGradient',
1244
+ 'textPath'
1245
1245
  ];
1246
1246
 
1247
1247
  var constants = {
1248
- CASE_SENSITIVE_TAG_NAMES: CASE_SENSITIVE_TAG_NAMES
1248
+ CASE_SENSITIVE_TAG_NAMES: CASE_SENSITIVE_TAG_NAMES
1249
1249
  };
1250
1250
 
1251
1251
  var CASE_SENSITIVE_TAG_NAMES$1 = constants.CASE_SENSITIVE_TAG_NAMES;
@@ -1253,8 +1253,8 @@
1253
1253
  var caseSensitiveTagNamesMap = {};
1254
1254
  var tagName;
1255
1255
  for (var i = 0, len = CASE_SENSITIVE_TAG_NAMES$1.length; i < len; i++) {
1256
- tagName = CASE_SENSITIVE_TAG_NAMES$1[i];
1257
- caseSensitiveTagNamesMap[tagName.toLowerCase()] = tagName;
1256
+ tagName = CASE_SENSITIVE_TAG_NAMES$1[i];
1257
+ caseSensitiveTagNamesMap[tagName.toLowerCase()] = tagName;
1258
1258
  }
1259
1259
 
1260
1260
  /**
@@ -1264,7 +1264,7 @@
1264
1264
  * @return {String|undefined}
1265
1265
  */
1266
1266
  function getCaseSensitiveTagName(tagName) {
1267
- return caseSensitiveTagNamesMap[tagName];
1267
+ return caseSensitiveTagNamesMap[tagName];
1268
1268
  }
1269
1269
 
1270
1270
  /**
@@ -1274,14 +1274,14 @@
1274
1274
  * @return {Object} - A map of attribute name to value.
1275
1275
  */
1276
1276
  function formatAttributes(attributes) {
1277
- var result = {};
1278
- var attribute;
1279
- // `NamedNodeMap` is array-like
1280
- for (var i = 0, len = attributes.length; i < len; i++) {
1281
- attribute = attributes[i];
1282
- result[attribute.name] = attribute.value;
1283
- }
1284
- return result;
1277
+ var result = {};
1278
+ var attribute;
1279
+ // `NamedNodeMap` is array-like
1280
+ for (var i = 0, len = attributes.length; i < len; i++) {
1281
+ attribute = attributes[i];
1282
+ result[attribute.name] = attribute.value;
1283
+ }
1284
+ return result;
1285
1285
  }
1286
1286
 
1287
1287
  /**
@@ -1292,12 +1292,12 @@
1292
1292
  * @return {String} - The formatted tag name.
1293
1293
  */
1294
1294
  function formatTagName(tagName) {
1295
- tagName = tagName.toLowerCase();
1296
- var caseSensitiveTagName = getCaseSensitiveTagName(tagName);
1297
- if (caseSensitiveTagName) {
1298
- return caseSensitiveTagName;
1299
- }
1300
- return tagName;
1295
+ tagName = tagName.toLowerCase();
1296
+ var caseSensitiveTagName = getCaseSensitiveTagName(tagName);
1297
+ if (caseSensitiveTagName) {
1298
+ return caseSensitiveTagName;
1299
+ }
1300
+ return tagName;
1301
1301
  }
1302
1302
 
1303
1303
  /**
@@ -1309,87 +1309,85 @@
1309
1309
  * @return {Object[]} - The formatted DOM object.
1310
1310
  */
1311
1311
  function formatDOM(nodes, parentObj, directive) {
1312
- parentObj = parentObj || null;
1313
-
1314
- var result = [];
1315
- var node;
1316
- var prevNode;
1317
- var nodeObj;
1318
-
1319
- // `NodeList` is array-like
1320
- for (var i = 0, len = nodes.length; i < len; i++) {
1321
- node = nodes[i];
1322
- // reset
1323
- nodeObj = {
1324
- next: null,
1325
- prev: result[i - 1] || null,
1326
- parent: parentObj
1327
- };
1312
+ parentObj = parentObj || null;
1328
1313
 
1329
- // set the next node for the previous node (if applicable)
1330
- prevNode = result[i - 1];
1331
- if (prevNode) {
1332
- prevNode.next = nodeObj;
1333
- }
1314
+ var result = [];
1315
+ var node;
1316
+ var prevNode;
1317
+ var nodeObj;
1334
1318
 
1335
- // set the node name if it's not "#text" or "#comment"
1336
- // e.g., "div"
1337
- if (node.nodeName[0] !== '#') {
1338
- nodeObj.name = formatTagName(node.nodeName);
1339
- // also, nodes of type "tag" have "attribs"
1340
- nodeObj.attribs = {}; // default
1341
- if (node.attributes && node.attributes.length) {
1342
- nodeObj.attribs = formatAttributes(node.attributes);
1343
- }
1344
- }
1319
+ // `NodeList` is array-like
1320
+ for (var i = 0, len = nodes.length; i < len; i++) {
1321
+ node = nodes[i];
1322
+ // reset
1323
+ nodeObj = {
1324
+ next: null,
1325
+ prev: result[i - 1] || null,
1326
+ parent: parentObj
1327
+ };
1345
1328
 
1346
- // set the node type
1347
- // e.g., "tag"
1348
- switch (node.nodeType) {
1349
- // 1 = element
1350
- case 1:
1351
- if (nodeObj.name === 'script' || nodeObj.name === 'style') {
1352
- nodeObj.type = nodeObj.name;
1353
- } else {
1354
- nodeObj.type = 'tag';
1355
- }
1356
- // recursively format the children
1357
- nodeObj.children = formatDOM(node.childNodes, nodeObj);
1358
- break;
1359
- // 2 = attribute
1360
- // 3 = text
1361
- case 3:
1362
- nodeObj.type = 'text';
1363
- nodeObj.data = node.nodeValue;
1364
- break;
1365
- // 8 = comment
1366
- case 8:
1367
- nodeObj.type = 'comment';
1368
- nodeObj.data = node.nodeValue;
1369
- break;
1370
- default:
1371
- break;
1372
- }
1329
+ // set the next node for the previous node (if applicable)
1330
+ prevNode = result[i - 1];
1331
+ if (prevNode) {
1332
+ prevNode.next = nodeObj;
1333
+ }
1373
1334
 
1374
- result.push(nodeObj);
1335
+ // set the node name if it's not "#text" or "#comment"
1336
+ // e.g., "div"
1337
+ if (node.nodeName[0] !== '#') {
1338
+ nodeObj.name = formatTagName(node.nodeName);
1339
+ // also, nodes of type "tag" have "attribs"
1340
+ nodeObj.attribs = {}; // default
1341
+ if (node.attributes && node.attributes.length) {
1342
+ nodeObj.attribs = formatAttributes(node.attributes);
1343
+ }
1375
1344
  }
1376
1345
 
1377
- if (directive) {
1378
- result.unshift({
1379
- name: directive.substring(0, directive.indexOf(' ')).toLowerCase(),
1380
- data: directive,
1381
- type: 'directive',
1382
- next: result[0] ? result[0] : null,
1383
- prev: null,
1384
- parent: parentObj
1385
- });
1386
-
1387
- if (result[1]) {
1388
- result[1].prev = result[0];
1346
+ // set the node type
1347
+ // e.g., "tag"
1348
+ switch (node.nodeType) {
1349
+ // 1 = element
1350
+ case 1:
1351
+ if (nodeObj.name === 'script' || nodeObj.name === 'style') {
1352
+ nodeObj.type = nodeObj.name;
1353
+ } else {
1354
+ nodeObj.type = 'tag';
1389
1355
  }
1356
+ // recursively format the children
1357
+ nodeObj.children = formatDOM(node.childNodes, nodeObj);
1358
+ break;
1359
+ // 2 = attribute
1360
+ // 3 = text
1361
+ case 3:
1362
+ nodeObj.type = 'text';
1363
+ nodeObj.data = node.nodeValue;
1364
+ break;
1365
+ // 8 = comment
1366
+ case 8:
1367
+ nodeObj.type = 'comment';
1368
+ nodeObj.data = node.nodeValue;
1369
+ break;
1390
1370
  }
1391
1371
 
1392
- return result;
1372
+ result.push(nodeObj);
1373
+ }
1374
+
1375
+ if (directive) {
1376
+ result.unshift({
1377
+ name: directive.substring(0, directive.indexOf(' ')).toLowerCase(),
1378
+ data: directive,
1379
+ type: 'directive',
1380
+ next: result[0] ? result[0] : null,
1381
+ prev: null,
1382
+ parent: parentObj
1383
+ });
1384
+
1385
+ if (result[1]) {
1386
+ result[1].prev = result[0];
1387
+ }
1388
+ }
1389
+
1390
+ return result;
1393
1391
  }
1394
1392
 
1395
1393
  /**
@@ -1399,218 +1397,209 @@
1399
1397
  * @return {Boolean} - Whether IE or the version has been detected.
1400
1398
  */
1401
1399
  function isIE(version) {
1402
- if (version) {
1403
- return document.documentMode === version;
1404
- }
1405
- return /(MSIE |Trident\/|Edge\/)/.test(navigator.userAgent);
1400
+ if (version) {
1401
+ return document.documentMode === version;
1402
+ }
1403
+ return /(MSIE |Trident\/|Edge\/)/.test(navigator.userAgent);
1406
1404
  }
1407
1405
 
1408
- /**
1409
- * Export utilities.
1410
- */
1411
1406
  var utilities$1 = {
1412
- formatAttributes: formatAttributes,
1413
- formatDOM: formatDOM,
1414
- isIE: isIE
1407
+ formatAttributes: formatAttributes,
1408
+ formatDOM: formatDOM,
1409
+ isIE: isIE
1415
1410
  };
1416
1411
 
1417
- /**
1418
- * Module dependencies.
1419
- */
1420
-
1421
- var detectIE = utilities$1.isIE;
1422
-
1423
- /**
1424
- * Constants.
1425
- */
1426
- var HTML_TAG_NAME = 'html';
1427
- var BODY_TAG_NAME = 'body';
1428
- var HEAD_TAG_NAME = 'head';
1412
+ // constants
1413
+ var HTML = 'html';
1414
+ var HEAD = 'head';
1415
+ var BODY = 'body';
1429
1416
  var FIRST_TAG_REGEX = /<([a-zA-Z]+[0-9]?)/; // e.g., <h1>
1430
- var HEAD_REGEX = /<\/head>/i;
1431
- var BODY_REGEX = /<\/body>/i;
1417
+ var HEAD_TAG_REGEX = /<head.*>/i;
1418
+ var BODY_TAG_REGEX = /<body.*>/i;
1432
1419
  // http://www.w3.org/TR/html/syntax.html#void-elements
1433
1420
  var VOID_ELEMENTS_REGEX = /<(area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)(.*?)\/?>/gi;
1434
1421
 
1435
- // browser support
1436
- var isIE$1 = detectIE();
1437
- var isIE9 = detectIE(9);
1422
+ // detect IE browser
1423
+ var isIE9 = utilities$1.isIE(9);
1424
+ var isIE$1 = isIE9 || utilities$1.isIE();
1438
1425
 
1439
1426
  /**
1440
1427
  * DOMParser (performance: slow).
1441
1428
  *
1442
- * https://developer.mozilla.org/docs/Web/API/DOMParser#Parsing_an_SVG_or_HTML_document
1429
+ * @see https://developer.mozilla.org/docs/Web/API/DOMParser#Parsing_an_SVG_or_HTML_document
1443
1430
  */
1444
1431
  var parseFromString;
1432
+
1445
1433
  if (typeof window.DOMParser === 'function') {
1446
- var domParser = new window.DOMParser();
1447
- // IE9 does not support 'text/html' MIME type
1448
- // https://msdn.microsoft.com/en-us/library/ff975278(v=vs.85).aspx
1449
- var MIME_TYPE = isIE9 ? 'text/xml' : 'text/html';
1450
-
1451
- /**
1452
- * Creates an HTML document using `DOMParser.parseFromString`.
1453
- *
1454
- * @param {String} html - The HTML string.
1455
- * @param {String} [tagName] - The element to render the HTML (with 'body' as fallback).
1456
- * @return {HTMLDocument}
1457
- */
1458
- parseFromString = function domStringParser(html, tagName) {
1459
- if (tagName) {
1460
- html = ['<', tagName, '>', html, '</', tagName, '>'].join('');
1461
- }
1462
- // because IE9 only supports MIME type 'text/xml', void elements need to be self-closed
1463
- if (isIE9) {
1464
- html = html.replace(VOID_ELEMENTS_REGEX, '<$1$2$3/>');
1465
- }
1466
- return domParser.parseFromString(html, MIME_TYPE);
1467
- };
1434
+ var domParser = new window.DOMParser();
1435
+
1436
+ // IE9 does not support 'text/html' MIME type
1437
+ // https://msdn.microsoft.com/en-us/library/ff975278(v=vs.85).aspx
1438
+ var mimeType = isIE9 ? 'text/xml' : 'text/html';
1439
+
1440
+ /**
1441
+ * Creates an HTML document using `DOMParser.parseFromString`.
1442
+ *
1443
+ * @param {string} html - The HTML string.
1444
+ * @param {string} [tagName] - The element to render the HTML (with 'body' as fallback).
1445
+ * @return {HTMLDocument}
1446
+ */
1447
+ parseFromString = function domStringParser(html, tagName) {
1448
+ if (tagName) {
1449
+ html = '<' + tagName + '>' + html + '</' + tagName + '>';
1450
+ }
1451
+
1452
+ // because IE9 only supports MIME type 'text/xml', void elements need to be self-closed
1453
+ if (isIE9) {
1454
+ html = html.replace(VOID_ELEMENTS_REGEX, '<$1$2$3/>');
1455
+ }
1456
+
1457
+ return domParser.parseFromString(html, mimeType);
1458
+ };
1468
1459
  }
1469
1460
 
1470
1461
  /**
1471
1462
  * DOMImplementation (performance: fair).
1472
1463
  *
1473
- * https://developer.mozilla.org/docs/Web/API/DOMImplementation/createHTMLDocument
1464
+ * @see https://developer.mozilla.org/docs/Web/API/DOMImplementation/createHTMLDocument
1474
1465
  */
1475
1466
  var parseFromDocument;
1467
+
1476
1468
  if (typeof document.implementation === 'object') {
1477
- // title parameter is required in IE
1478
- // https://msdn.microsoft.com/en-us/library/ff975457(v=vs.85).aspx
1479
- var doc = document.implementation.createHTMLDocument(isIE$1 ? 'HTML_DOM_PARSER_TITLE' : undefined);
1480
-
1481
- /**
1482
- * Use HTML document created by `document.implementation.createHTMLDocument`.
1483
- *
1484
- * @param {String} html - The HTML string.
1485
- * @param {String} [tagName] - The element to render the HTML (with 'body' as fallback).
1486
- * @return {HTMLDocument}
1487
- */
1488
- parseFromDocument = function createHTMLDocument(html, tagName) {
1489
- if (tagName) {
1490
- doc.documentElement.getElementsByTagName(tagName)[0].innerHTML = html;
1491
- return doc;
1492
- }
1469
+ // title parameter is required in IE
1470
+ // https://msdn.microsoft.com/en-us/library/ff975457(v=vs.85).aspx
1471
+ var doc = document.implementation.createHTMLDocument(
1472
+ isIE$1 ? 'HTML_DOM_PARSER_TITLE' : undefined
1473
+ );
1493
1474
 
1494
- try {
1495
- doc.documentElement.innerHTML = html;
1496
- return doc;
1497
- // fallback when certain elements in `documentElement` are read-only (IE9)
1498
- } catch (err) {
1499
- if (parseFromString) return parseFromString(html);
1500
- }
1501
- };
1475
+ /**
1476
+ * Use HTML document created by `document.implementation.createHTMLDocument`.
1477
+ *
1478
+ * @param {string} html - The HTML string.
1479
+ * @param {string} [tagName] - The element to render the HTML (with 'body' as fallback).
1480
+ * @return {HTMLDocument}
1481
+ */
1482
+ parseFromDocument = function createHTMLDocument(html, tagName) {
1483
+ if (tagName) {
1484
+ doc.documentElement.getElementsByTagName(tagName)[0].innerHTML = html;
1485
+ return doc;
1486
+ }
1487
+
1488
+ try {
1489
+ doc.documentElement.innerHTML = html;
1490
+ return doc;
1491
+ // fallback when certain elements in `documentElement` are read-only (IE9)
1492
+ } catch (err) {
1493
+ if (parseFromString) {
1494
+ return parseFromString(html);
1495
+ }
1496
+ }
1497
+ };
1502
1498
  }
1503
1499
 
1504
1500
  /**
1505
1501
  * Template (performance: fast).
1506
1502
  *
1507
- * https://developer.mozilla.org/docs/Web/HTML/Element/template
1503
+ * @see https://developer.mozilla.org/docs/Web/HTML/Element/template
1508
1504
  */
1509
1505
  var parseFromTemplate;
1510
1506
  var template = document.createElement('template');
1511
- if (template.content) {
1512
1507
 
1513
- /**
1514
- * Uses a template element (content fragment) to parse HTML.
1515
- *
1516
- * @param {String} html - The HTML string.
1517
- * @return {NodeList}
1518
- */
1519
- parseFromTemplate = function templateParser(html) {
1520
- template.innerHTML = html;
1521
- return template.content.childNodes;
1522
- };
1508
+ if (template.content) {
1509
+ /**
1510
+ * Uses a template element (content fragment) to parse HTML.
1511
+ *
1512
+ * @param {string} html - The HTML string.
1513
+ * @return {NodeList}
1514
+ */
1515
+ parseFromTemplate = function templateParser(html) {
1516
+ template.innerHTML = html;
1517
+ return template.content.childNodes;
1518
+ };
1523
1519
  }
1524
1520
 
1525
- /** Fallback document parser. */
1521
+ // fallback document parser
1526
1522
  var parseWithFallback = parseFromDocument || parseFromString;
1527
1523
 
1528
1524
  /**
1529
1525
  * Parses HTML string to DOM nodes.
1530
1526
  *
1531
- * @param {String} html - The HTML string.
1532
- * @param {String} [tagName] - The tag name.
1527
+ * @param {string} html - The HTML string.
1533
1528
  * @return {NodeList|Array}
1534
1529
  */
1535
- var domparser = function domparser(html) {
1536
- // try to match first tag
1537
- var tagName;
1538
- var match = html.match(FIRST_TAG_REGEX);
1539
- if (match && match[1]) {
1540
- tagName = match[1].toLowerCase();
1541
- }
1530
+ function domparser(html) {
1531
+ var firstTagName;
1532
+ var match = html.match(FIRST_TAG_REGEX);
1542
1533
 
1543
- var doc;
1544
- var element;
1545
- var elements;
1546
-
1547
- switch (tagName) {
1548
- case HTML_TAG_NAME:
1549
- if (parseFromString) {
1550
- doc = parseFromString(html);
1551
-
1552
- // the created document may come with filler head/body elements,
1553
- // so ake sure to remove them if they don't actually exist
1554
- if (!HEAD_REGEX.test(html)) {
1555
- element = doc.getElementsByTagName(HEAD_TAG_NAME)[0];
1556
- if (element) element.parentNode.removeChild(element);
1557
- }
1558
- if (!BODY_REGEX.test(html)) {
1559
- element = doc.getElementsByTagName(BODY_TAG_NAME)[0];
1560
- if (element) element.parentNode.removeChild(element);
1561
- }
1562
-
1563
- return doc.getElementsByTagName(HTML_TAG_NAME);
1564
- }
1565
- break;
1566
-
1567
- case HEAD_TAG_NAME:
1568
- if (parseWithFallback) {
1569
- elements = parseWithFallback(html).getElementsByTagName(HEAD_TAG_NAME);
1570
-
1571
- // account for possibility of sibling
1572
- if (BODY_REGEX.test(html)) {
1573
- return elements[0].parentNode.childNodes;
1574
- }
1575
- return elements;
1576
- }
1577
- break;
1578
-
1579
- case BODY_TAG_NAME:
1580
- if (parseWithFallback) {
1581
- elements = parseWithFallback(html).getElementsByTagName(BODY_TAG_NAME);
1582
-
1583
- // account for possibility of sibling (return both body and head)
1584
- if (HEAD_REGEX.test(html)) {
1585
- return elements[0].parentNode.childNodes;
1586
- }
1587
- return elements;
1588
- }
1589
- break;
1590
-
1591
- // low-level tag or text
1592
- default:
1593
- if (parseFromTemplate) return parseFromTemplate(html);
1594
- if (parseWithFallback) {
1595
- return parseWithFallback(html, BODY_TAG_NAME).getElementsByTagName(BODY_TAG_NAME)[0].childNodes;
1596
- }
1597
- break;
1598
- }
1534
+ if (match && match[1]) {
1535
+ firstTagName = match[1].toLowerCase();
1536
+ }
1599
1537
 
1600
- return [];
1601
- };
1538
+ var doc;
1539
+ var element;
1540
+ var elements;
1541
+
1542
+ switch (firstTagName) {
1543
+ case HTML:
1544
+ if (parseFromString) {
1545
+ doc = parseFromString(html);
1546
+
1547
+ // the created document may come with filler head/body elements,
1548
+ // so make sure to remove them if they don't actually exist
1549
+ if (!HEAD_TAG_REGEX.test(html)) {
1550
+ element = doc.getElementsByTagName(HEAD)[0];
1551
+ if (element) {
1552
+ element.parentNode.removeChild(element);
1553
+ }
1554
+ }
1602
1555
 
1603
- /**
1604
- * Module dependencies.
1605
- */
1556
+ if (!BODY_TAG_REGEX.test(html)) {
1557
+ element = doc.getElementsByTagName(BODY)[0];
1558
+ if (element) {
1559
+ element.parentNode.removeChild(element);
1560
+ }
1561
+ }
1562
+
1563
+ return doc.getElementsByTagName(HTML);
1564
+ }
1565
+ break;
1566
+
1567
+ case HEAD:
1568
+ case BODY:
1569
+ if (parseWithFallback) {
1570
+ elements = parseWithFallback(html).getElementsByTagName(firstTagName);
1571
+
1572
+ // account for possibility of sibling
1573
+ if (BODY_TAG_REGEX.test(html) && HEAD_TAG_REGEX.test(html)) {
1574
+ return elements[0].parentNode.childNodes;
1575
+ }
1576
+
1577
+ return elements;
1578
+ }
1579
+ break;
1580
+
1581
+ // low-level tag or text
1582
+ default:
1583
+ if (parseFromTemplate) {
1584
+ return parseFromTemplate(html);
1585
+ }
1586
+
1587
+ if (parseWithFallback) {
1588
+ return parseWithFallback(html, BODY).getElementsByTagName(BODY)[0]
1589
+ .childNodes;
1590
+ }
1591
+
1592
+ break;
1593
+ }
1594
+
1595
+ return [];
1596
+ }
1606
1597
 
1598
+ var domparser_1 = domparser;
1607
1599
 
1608
1600
  var formatDOM$1 = utilities$1.formatDOM;
1609
1601
  var isIE9$1 = utilities$1.isIE(9);
1610
1602
 
1611
- /**
1612
- * Constants.
1613
- */
1614
1603
  var DIRECTIVE_REGEX = /<(![a-zA-Z\s]+)>/; // e.g., <!doctype html>
1615
1604
 
1616
1605
  /**
@@ -1619,27 +1608,33 @@
1619
1608
  * @param {String} html - The HTML string.
1620
1609
  * @return {Array} - The formatted DOM nodes.
1621
1610
  */
1622
- var htmlToDomClient = function parseDOM(html) {
1623
- if (typeof html !== 'string') {
1624
- throw new TypeError('First argument must be a string.');
1625
- }
1626
- if (!html) return [];
1627
-
1628
- // match directive
1629
- var match = html.match(DIRECTIVE_REGEX);
1630
- var directive;
1631
- if (match && match[1]) {
1632
- directive = match[1];
1633
-
1634
- // remove directive in IE9 because DOMParser uses
1635
- // MIME type 'text/xml' instead of 'text/html'
1636
- if (isIE9$1) {
1637
- html = html.replace(match[0], '');
1638
- }
1611
+ function parseDOM(html) {
1612
+ if (typeof html !== 'string') {
1613
+ throw new TypeError('First argument must be a string');
1614
+ }
1615
+
1616
+ if (!html) {
1617
+ return [];
1618
+ }
1619
+
1620
+ // match directive
1621
+ var match = html.match(DIRECTIVE_REGEX);
1622
+ var directive;
1623
+
1624
+ if (match && match[1]) {
1625
+ directive = match[1];
1626
+
1627
+ // remove directive in IE9 because DOMParser uses
1628
+ // MIME type 'text/xml' instead of 'text/html'
1629
+ if (isIE9$1) {
1630
+ html = html.replace(match[0], '');
1639
1631
  }
1632
+ }
1640
1633
 
1641
- return formatDOM$1(domparser(html), null, directive);
1642
- };
1634
+ return formatDOM$1(domparser_1(html), null, directive);
1635
+ }
1636
+
1637
+ var htmlToDomClient = parseDOM;
1643
1638
 
1644
1639
  /**
1645
1640
  * Converts HTML string to React elements.