html-react-parser 3.0.0 → 3.0.1

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/README.md CHANGED
@@ -62,6 +62,7 @@ parse('<p>Hello, World!</p>'); // React.createElement('p', {}, 'Hello, World!')
62
62
  - [Financial Contributors](#financial-contributors)
63
63
  - [Individuals](#individuals)
64
64
  - [Organizations](#organizations)
65
+ - [Enterprise](#enterprise)
65
66
  - [Support](#support)
66
67
  - [License](#license)
67
68
 
@@ -540,6 +541,12 @@ Support this project with your organization. Your logo will show up here with a
540
541
  [![Financial Contributors - Organization 8](https://opencollective.com/html-react-parser/organization/8/avatar.svg)](https://opencollective.com/html-react-parser/organization/8/website)
541
542
  [![Financial Contributors - Organization 9](https://opencollective.com/html-react-parser/organization/9/avatar.svg)](https://opencollective.com/html-react-parser/organization/9/website)
542
543
 
544
+ ## Enterprise
545
+
546
+ Available as part of the Tidelift Subscription.
547
+
548
+ The maintainers of html-react-parser and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source packages you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact packages you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-html-react-parser?utm_source=npm-html-react-parser&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
549
+
543
550
  ## Support
544
551
 
545
552
  - [GitHub Sponsors](https://b.remarkabl.org/github-sponsors)
@@ -1548,8 +1548,9 @@
1548
1548
  var HEAD = 'head';
1549
1549
  var BODY = 'body';
1550
1550
  var FIRST_TAG_REGEX = /<([a-zA-Z]+[0-9]?)/; // e.g., <h1>
1551
- var HEAD_TAG_REGEX = /<head.*>/i;
1552
- var BODY_TAG_REGEX = /<body.*>/i;
1551
+ // match-all-characters in case of newlines (DOTALL)
1552
+ var HEAD_TAG_REGEX = /<head[^]*>/i;
1553
+ var BODY_TAG_REGEX = /<body[^]*>/i;
1553
1554
 
1554
1555
  // falls back to `parseFromString` if `createHTMLDocument` cannot be used
1555
1556
  var parseFromDocument = function () {
@@ -1608,7 +1609,8 @@
1608
1609
  */
1609
1610
  parseFromDocument = function (html, tagName) {
1610
1611
  if (tagName) {
1611
- doc.documentElement.getElementsByTagName(tagName)[0].innerHTML = html;
1612
+ var element = doc.documentElement.querySelector(tagName);
1613
+ element.innerHTML = html;
1612
1614
  return doc;
1613
1615
  }
1614
1616
 
@@ -1663,24 +1665,25 @@
1663
1665
  // the created document may come with filler head/body elements,
1664
1666
  // so make sure to remove them if they don't actually exist
1665
1667
  if (!HEAD_TAG_REGEX.test(html)) {
1666
- element = doc.getElementsByTagName(HEAD)[0];
1668
+ element = doc.querySelector(HEAD);
1667
1669
  if (element) {
1668
1670
  element.parentNode.removeChild(element);
1669
1671
  }
1670
1672
  }
1671
1673
 
1672
1674
  if (!BODY_TAG_REGEX.test(html)) {
1673
- element = doc.getElementsByTagName(BODY)[0];
1675
+ element = doc.querySelector(BODY);
1674
1676
  if (element) {
1675
1677
  element.parentNode.removeChild(element);
1676
1678
  }
1677
1679
  }
1678
1680
 
1679
- return doc.getElementsByTagName(HTML);
1681
+ return doc.querySelectorAll(HTML);
1680
1682
 
1681
1683
  case HEAD:
1682
1684
  case BODY:
1683
- elements = parseFromDocument(html).getElementsByTagName(firstTagName);
1685
+ doc = parseFromDocument(html);
1686
+ elements = doc.querySelectorAll(firstTagName);
1684
1687
 
1685
1688
  // if there's a sibling element, then return both elements
1686
1689
  if (BODY_TAG_REGEX.test(html) && HEAD_TAG_REGEX.test(html)) {
@@ -1693,9 +1696,8 @@
1693
1696
  if (parseFromTemplate) {
1694
1697
  return parseFromTemplate(html);
1695
1698
  }
1696
-
1697
- return parseFromDocument(html, BODY).getElementsByTagName(BODY)[0]
1698
- .childNodes;
1699
+ element = parseFromDocument(html, BODY).querySelector(BODY);
1700
+ return element.childNodes;
1699
1701
  }
1700
1702
  }
1701
1703