html-react-parser 4.2.2 → 4.2.4

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.
@@ -4,10 +4,6 @@
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.HTMLReactParser = factory(global.React));
5
5
  })(this, (function (require$$0) { 'use strict';
6
6
 
7
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
-
9
- var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0);
10
-
11
7
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
12
8
 
13
9
  function getDefaultExportFromCjs (x) {
@@ -212,7 +208,7 @@
212
208
  /**
213
209
  * Text within the document.
214
210
  */
215
- var Text$1 = /** @class */ (function (_super) {
211
+ var Text = /** @class */ (function (_super) {
216
212
  __extends(Text, _super);
217
213
  function Text() {
218
214
  var _this = _super !== null && _super.apply(this, arguments) || this;
@@ -228,11 +224,11 @@
228
224
  });
229
225
  return Text;
230
226
  }(DataNode));
231
- node.Text = Text$1;
227
+ node.Text = Text;
232
228
  /**
233
229
  * Comments within the document.
234
230
  */
235
- var Comment$1 = /** @class */ (function (_super) {
231
+ var Comment = /** @class */ (function (_super) {
236
232
  __extends(Comment, _super);
237
233
  function Comment() {
238
234
  var _this = _super !== null && _super.apply(this, arguments) || this;
@@ -248,11 +244,11 @@
248
244
  });
249
245
  return Comment;
250
246
  }(DataNode));
251
- node.Comment = Comment$1;
247
+ node.Comment = Comment;
252
248
  /**
253
249
  * Processing instructions, including doc types.
254
250
  */
255
- var ProcessingInstruction$1 = /** @class */ (function (_super) {
251
+ var ProcessingInstruction = /** @class */ (function (_super) {
256
252
  __extends(ProcessingInstruction, _super);
257
253
  function ProcessingInstruction(name, data) {
258
254
  var _this = _super.call(this, data) || this;
@@ -269,7 +265,7 @@
269
265
  });
270
266
  return ProcessingInstruction;
271
267
  }(DataNode));
272
- node.ProcessingInstruction = ProcessingInstruction$1;
268
+ node.ProcessingInstruction = ProcessingInstruction;
273
269
  /**
274
270
  * A `Node` that can have children.
275
271
  */
@@ -360,7 +356,7 @@
360
356
  /**
361
357
  * An element within the DOM.
362
358
  */
363
- var Element$1 = /** @class */ (function (_super) {
359
+ var Element = /** @class */ (function (_super) {
364
360
  __extends(Element, _super);
365
361
  /**
366
362
  * @param name Name of the tag, eg. `div`, `span`.
@@ -420,7 +416,7 @@
420
416
  });
421
417
  return Element;
422
418
  }(NodeWithChildren));
423
- node.Element = Element$1;
419
+ node.Element = Element;
424
420
  /**
425
421
  * @param node Node to check.
426
422
  * @returns `true` if the node is a `Element`, `false` otherwise.
@@ -487,14 +483,14 @@
487
483
  if (recursive === void 0) { recursive = false; }
488
484
  var result;
489
485
  if (isText(node)) {
490
- result = new Text$1(node.data);
486
+ result = new Text(node.data);
491
487
  }
492
488
  else if (isComment(node)) {
493
- result = new Comment$1(node.data);
489
+ result = new Comment(node.data);
494
490
  }
495
491
  else if (isTag(node)) {
496
492
  var children = recursive ? cloneChildren(node.children) : [];
497
- var clone_1 = new Element$1(node.name, __assign({}, node.attribs), children);
493
+ var clone_1 = new Element(node.name, __assign({}, node.attribs), children);
498
494
  children.forEach(function (child) { return (child.parent = clone_1); });
499
495
  if (node.namespace != null) {
500
496
  clone_1.namespace = node.namespace;
@@ -523,7 +519,7 @@
523
519
  result = clone_3;
524
520
  }
525
521
  else if (isDirective(node)) {
526
- var instruction = new ProcessingInstruction$1(node.name, node.data);
522
+ var instruction = new ProcessingInstruction(node.name, node.data);
527
523
  if (node["x-name"] != null) {
528
524
  instruction["x-name"] = node["x-name"];
529
525
  instruction["x-publicId"] = node["x-publicId"];
@@ -718,6 +714,11 @@
718
714
  exports.default = DomHandler;
719
715
  } (lib$2));
720
716
 
717
+ var htmlToDom = {};
718
+
719
+ var domparser$1 = {};
720
+
721
+ Object.defineProperty(domparser$1, "__esModule", { value: true });
721
722
  // constants
722
723
  var HTML = 'html';
723
724
  var HEAD = 'head';
@@ -726,377 +727,319 @@
726
727
  // match-all-characters in case of newlines (DOTALL)
727
728
  var HEAD_TAG_REGEX = /<head[^]*>/i;
728
729
  var BODY_TAG_REGEX = /<body[^]*>/i;
729
-
730
730
  // falls back to `parseFromString` if `createHTMLDocument` cannot be used
731
- var parseFromDocument = function () {
732
- throw new Error(
733
- 'This browser does not support `document.implementation.createHTMLDocument`'
734
- );
731
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
732
+ var parseFromDocument = function (html, tagName) {
733
+ /* istanbul ignore next */
734
+ throw new Error('This browser does not support `document.implementation.createHTMLDocument`');
735
735
  };
736
-
737
- var parseFromString = function () {
738
- throw new Error(
739
- 'This browser does not support `DOMParser.prototype.parseFromString`'
740
- );
736
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
737
+ var parseFromString = function (html, tagName) {
738
+ /* istanbul ignore next */
739
+ throw new Error('This browser does not support `DOMParser.prototype.parseFromString`');
741
740
  };
742
-
743
741
  var DOMParser = typeof window === 'object' && window.DOMParser;
744
-
745
742
  /**
746
743
  * DOMParser (performance: slow).
747
744
  *
748
745
  * @see https://developer.mozilla.org/docs/Web/API/DOMParser#Parsing_an_SVG_or_HTML_document
749
746
  */
750
747
  if (typeof DOMParser === 'function') {
751
- var domParser = new DOMParser();
752
- var mimeType = 'text/html';
753
-
754
- /**
755
- * Creates an HTML document using `DOMParser.parseFromString`.
756
- *
757
- * @param {string} html - The HTML string.
758
- * @param {string} [tagName] - The element to render the HTML (with 'body' as fallback).
759
- * @return {HTMLDocument}
760
- */
761
- parseFromString = function (html, tagName) {
762
- if (tagName) {
763
- html = '<' + tagName + '>' + html + '</' + tagName + '>';
764
- }
765
-
766
- return domParser.parseFromString(html, mimeType);
767
- };
768
-
769
- parseFromDocument = parseFromString;
748
+ var domParser_1 = new DOMParser();
749
+ var mimeType_1 = 'text/html';
750
+ /**
751
+ * Creates an HTML document using `DOMParser.parseFromString`.
752
+ *
753
+ * @param html - The HTML string.
754
+ * @param tagName - The element to render the HTML (with 'body' as fallback).
755
+ * @returns - Document.
756
+ */
757
+ parseFromString = function (html, tagName) {
758
+ if (tagName) {
759
+ html = "<".concat(tagName, ">").concat(html, "</").concat(tagName, ">");
760
+ }
761
+ return domParser_1.parseFromString(html, mimeType_1);
762
+ };
763
+ parseFromDocument = parseFromString;
770
764
  }
771
-
772
765
  /**
773
766
  * DOMImplementation (performance: fair).
774
767
  *
775
768
  * @see https://developer.mozilla.org/docs/Web/API/DOMImplementation/createHTMLDocument
776
769
  */
777
770
  if (typeof document === 'object' && document.implementation) {
778
- var doc = document.implementation.createHTMLDocument();
779
-
780
- /**
781
- * Use HTML document created by `document.implementation.createHTMLDocument`.
782
- *
783
- * @param {string} html - The HTML string.
784
- * @param {string} [tagName] - The element to render the HTML (with 'body' as fallback).
785
- * @return {HTMLDocument}
786
- */
787
- parseFromDocument = function (html, tagName) {
788
- if (tagName) {
789
- var element = doc.documentElement.querySelector(tagName);
790
- element.innerHTML = html;
791
- return doc;
792
- }
793
-
794
- doc.documentElement.innerHTML = html;
795
- return doc;
796
- };
771
+ var htmlDocument_1 = document.implementation.createHTMLDocument();
772
+ /**
773
+ * Use HTML document created by `document.implementation.createHTMLDocument`.
774
+ *
775
+ * @param html - The HTML string.
776
+ * @param tagName - The element to render the HTML (with 'body' as fallback).
777
+ * @returns - Document
778
+ */
779
+ parseFromDocument = function (html, tagName) {
780
+ if (tagName) {
781
+ var element = htmlDocument_1.documentElement.querySelector(tagName);
782
+ if (element) {
783
+ element.innerHTML = html;
784
+ }
785
+ return htmlDocument_1;
786
+ }
787
+ htmlDocument_1.documentElement.innerHTML = html;
788
+ return htmlDocument_1;
789
+ };
797
790
  }
798
-
799
791
  /**
800
792
  * Template (performance: fast).
801
793
  *
802
794
  * @see https://developer.mozilla.org/docs/Web/HTML/Element/template
803
795
  */
804
- var template =
805
- typeof document === 'object' ? document.createElement('template') : {};
806
-
796
+ var template = typeof document === 'object' && document.createElement('template');
797
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
807
798
  var parseFromTemplate;
808
-
809
- if (template.content) {
810
- /**
811
- * Uses a template element (content fragment) to parse HTML.
812
- *
813
- * @param {string} html - The HTML string.
814
- * @return {NodeList}
815
- */
816
- parseFromTemplate = function (html) {
817
- template.innerHTML = html;
818
- return template.content.childNodes;
819
- };
799
+ if (template && template.content) {
800
+ /**
801
+ * Uses a template element (content fragment) to parse HTML.
802
+ *
803
+ * @param html - HTML string.
804
+ * @returns - Nodes.
805
+ */
806
+ parseFromTemplate = function (html) {
807
+ template.innerHTML = html;
808
+ return template.content.childNodes;
809
+ };
820
810
  }
821
-
822
811
  /**
823
812
  * Parses HTML string to DOM nodes.
824
813
  *
825
- * @param {string} html - HTML markup.
826
- * @return {NodeList}
814
+ * @param html - HTML markup.
815
+ * @returns - DOM nodes.
827
816
  */
828
- function domparser$1(html) {
829
- var firstTagName;
830
- var match = html.match(FIRST_TAG_REGEX);
831
-
832
- if (match && match[1]) {
833
- firstTagName = match[1].toLowerCase();
834
- }
835
-
836
- var doc;
837
- var element;
838
- var elements;
839
-
840
- switch (firstTagName) {
841
- case HTML:
842
- doc = parseFromString(html);
843
-
844
- // the created document may come with filler head/body elements,
845
- // so make sure to remove them if they don't actually exist
846
- if (!HEAD_TAG_REGEX.test(html)) {
847
- element = doc.querySelector(HEAD);
848
- if (element) {
849
- element.parentNode.removeChild(element);
817
+ function domparser(html) {
818
+ var _a, _b;
819
+ var match = html.match(FIRST_TAG_REGEX);
820
+ var firstTagName = match && match[1] ? match[1].toLowerCase() : '';
821
+ switch (firstTagName) {
822
+ case HTML: {
823
+ var doc = parseFromString(html);
824
+ // the created document may come with filler head/body elements,
825
+ // so make sure to remove them if they don't actually exist
826
+ if (!HEAD_TAG_REGEX.test(html)) {
827
+ var element = doc.querySelector(HEAD);
828
+ (_a = element === null || element === void 0 ? void 0 : element.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(element);
829
+ }
830
+ if (!BODY_TAG_REGEX.test(html)) {
831
+ var element = doc.querySelector(BODY);
832
+ (_b = element === null || element === void 0 ? void 0 : element.parentNode) === null || _b === void 0 ? void 0 : _b.removeChild(element);
833
+ }
834
+ return doc.querySelectorAll(HTML);
850
835
  }
851
- }
852
-
853
- if (!BODY_TAG_REGEX.test(html)) {
854
- element = doc.querySelector(BODY);
855
- if (element) {
856
- element.parentNode.removeChild(element);
836
+ case HEAD:
837
+ case BODY: {
838
+ var elements = parseFromDocument(html).querySelectorAll(firstTagName);
839
+ // if there's a sibling element, then return both elements
840
+ if (BODY_TAG_REGEX.test(html) && HEAD_TAG_REGEX.test(html)) {
841
+ return elements[0].parentNode.childNodes;
842
+ }
843
+ return elements;
857
844
  }
858
- }
859
-
860
- return doc.querySelectorAll(HTML);
861
-
862
- case HEAD:
863
- case BODY:
864
- doc = parseFromDocument(html);
865
- elements = doc.querySelectorAll(firstTagName);
866
-
867
- // if there's a sibling element, then return both elements
868
- if (BODY_TAG_REGEX.test(html) && HEAD_TAG_REGEX.test(html)) {
869
- return elements[0].parentNode.childNodes;
870
- }
871
- return elements;
872
-
873
- // low-level tag or text
874
- default:
875
- if (parseFromTemplate) {
876
- return parseFromTemplate(html);
877
- }
878
- element = parseFromDocument(html, BODY).querySelector(BODY);
879
- return element.childNodes;
880
- }
845
+ // low-level tag or text
846
+ default: {
847
+ if (parseFromTemplate) {
848
+ return parseFromTemplate(html);
849
+ }
850
+ var element = parseFromDocument(html, BODY).querySelector(BODY);
851
+ return element.childNodes;
852
+ }
853
+ }
881
854
  }
855
+ domparser$1.default = domparser;
882
856
 
883
- var domparser_1 = domparser$1;
884
-
885
- var utilities$5 = {};
857
+ var utilities$4 = {};
886
858
 
887
- var constants$1 = {};
888
-
889
- /**
890
- * SVG elements are case-sensitive.
891
- *
892
- * @see {@link https://developer.mozilla.org/docs/Web/SVG/Element#svg_elements_a_to_z}
893
- */
894
-
895
- constants$1.CASE_SENSITIVE_TAG_NAMES = [
896
- 'animateMotion',
897
- 'animateTransform',
898
- 'clipPath',
899
- 'feBlend',
900
- 'feColorMatrix',
901
- 'feComponentTransfer',
902
- 'feComposite',
903
- 'feConvolveMatrix',
904
- 'feDiffuseLighting',
905
- 'feDisplacementMap',
906
- 'feDropShadow',
907
- 'feFlood',
908
- 'feFuncA',
909
- 'feFuncB',
910
- 'feFuncG',
911
- 'feFuncR',
912
- 'feGaussianBlur',
913
- 'feImage',
914
- 'feMerge',
915
- 'feMergeNode',
916
- 'feMorphology',
917
- 'feOffset',
918
- 'fePointLight',
919
- 'feSpecularLighting',
920
- 'feSpotLight',
921
- 'feTile',
922
- 'feTurbulence',
923
- 'foreignObject',
924
- 'linearGradient',
925
- 'radialGradient',
926
- 'textPath'
927
- ];
928
-
929
- var domhandler$1 = lib$2;
930
- var constants = constants$1;
931
-
932
- var CASE_SENSITIVE_TAG_NAMES = constants.CASE_SENSITIVE_TAG_NAMES;
933
-
934
- var Comment = domhandler$1.Comment;
935
- var Element = domhandler$1.Element;
936
- var ProcessingInstruction = domhandler$1.ProcessingInstruction;
937
- var Text = domhandler$1.Text;
938
-
939
- var caseSensitiveTagNamesMap = {};
940
- var tagName;
941
-
942
- for (var i = 0, len = CASE_SENSITIVE_TAG_NAMES.length; i < len; i++) {
943
- tagName = CASE_SENSITIVE_TAG_NAMES[i];
944
- caseSensitiveTagNamesMap[tagName.toLowerCase()] = tagName;
945
- }
859
+ var constants = {};
946
860
 
861
+ (function (exports) {
862
+ Object.defineProperty(exports, "__esModule", { value: true });
863
+ exports.CASE_SENSITIVE_TAG_NAMES_MAP = exports.CASE_SENSITIVE_TAG_NAMES = void 0;
864
+ /**
865
+ * SVG elements are case-sensitive.
866
+ *
867
+ * @see https://developer.mozilla.org/docs/Web/SVG/Element#svg_elements_a_to_z
868
+ */
869
+ exports.CASE_SENSITIVE_TAG_NAMES = [
870
+ 'animateMotion',
871
+ 'animateTransform',
872
+ 'clipPath',
873
+ 'feBlend',
874
+ 'feColorMatrix',
875
+ 'feComponentTransfer',
876
+ 'feComposite',
877
+ 'feConvolveMatrix',
878
+ 'feDiffuseLighting',
879
+ 'feDisplacementMap',
880
+ 'feDropShadow',
881
+ 'feFlood',
882
+ 'feFuncA',
883
+ 'feFuncB',
884
+ 'feFuncG',
885
+ 'feFuncR',
886
+ 'feGaussianBlur',
887
+ 'feImage',
888
+ 'feMerge',
889
+ 'feMergeNode',
890
+ 'feMorphology',
891
+ 'feOffset',
892
+ 'fePointLight',
893
+ 'feSpecularLighting',
894
+ 'feSpotLight',
895
+ 'feTile',
896
+ 'feTurbulence',
897
+ 'foreignObject',
898
+ 'linearGradient',
899
+ 'radialGradient',
900
+ 'textPath',
901
+ ];
902
+ exports.CASE_SENSITIVE_TAG_NAMES_MAP = exports.CASE_SENSITIVE_TAG_NAMES.reduce(function (accumulator, tagName) {
903
+ accumulator[tagName.toLowerCase()] = tagName;
904
+ return accumulator;
905
+ }, {});
906
+
907
+ } (constants));
908
+
909
+ Object.defineProperty(utilities$4, "__esModule", { value: true });
910
+ utilities$4.formatDOM = utilities$4.formatAttributes = void 0;
911
+ var domhandler_1 = lib$2;
912
+ var constants_1 = constants;
947
913
  /**
948
914
  * Gets case-sensitive tag name.
949
915
  *
950
- * @param {string} tagName - Tag name in lowercase.
951
- * @returns {string|undefined} - Case-sensitive tag name.
916
+ * @param tagName - Tag name in lowercase.
917
+ * @returns - Case-sensitive tag name.
952
918
  */
953
919
  function getCaseSensitiveTagName(tagName) {
954
- return caseSensitiveTagNamesMap[tagName];
920
+ return constants_1.CASE_SENSITIVE_TAG_NAMES_MAP[tagName];
955
921
  }
956
-
957
922
  /**
958
923
  * Formats DOM attributes to a hash map.
959
924
  *
960
- * @param {NamedNodeMap} attributes - List of attributes.
961
- * @returns {object} - Map of attribute name to value.
925
+ * @param attributes - List of attributes.
926
+ * @returns - Map of attribute name to value.
962
927
  */
963
928
  function formatAttributes(attributes) {
964
- var result = {};
965
- var attribute;
966
- // `NamedNodeMap` is array-like
967
- for (var i = 0, len = attributes.length; i < len; i++) {
968
- attribute = attributes[i];
969
- result[attribute.name] = attribute.value;
970
- }
971
- return result;
929
+ var map = {};
930
+ var index = 0;
931
+ var attributesLength = attributes.length;
932
+ // `NamedNodeMap` is array-like
933
+ for (; index < attributesLength; index++) {
934
+ var attribute = attributes[index];
935
+ map[attribute.name] = attribute.value;
936
+ }
937
+ return map;
972
938
  }
973
-
939
+ utilities$4.formatAttributes = formatAttributes;
974
940
  /**
975
941
  * Corrects the tag name if it is case-sensitive (SVG).
976
942
  * Otherwise, returns the lowercase tag name (HTML).
977
943
  *
978
- * @param {string} tagName - Lowercase tag name.
979
- * @returns {string} - Formatted tag name.
944
+ * @param tagName - Lowercase tag name.
945
+ * @returns - Formatted tag name.
980
946
  */
981
947
  function formatTagName(tagName) {
982
- tagName = tagName.toLowerCase();
983
- var caseSensitiveTagName = getCaseSensitiveTagName(tagName);
984
- if (caseSensitiveTagName) {
985
- return caseSensitiveTagName;
986
- }
987
- return tagName;
948
+ tagName = tagName.toLowerCase();
949
+ var caseSensitiveTagName = getCaseSensitiveTagName(tagName);
950
+ if (caseSensitiveTagName) {
951
+ return caseSensitiveTagName;
952
+ }
953
+ return tagName;
988
954
  }
989
-
990
955
  /**
991
956
  * Transforms DOM nodes to `domhandler` nodes.
992
957
  *
993
- * @param {NodeList} nodes - DOM nodes.
994
- * @param {Element|null} [parent=null] - Parent node.
995
- * @param {string} [directive] - Directive.
996
- * @returns {Array<Comment|Element|ProcessingInstruction|Text>}
958
+ * @param nodes - DOM nodes.
959
+ * @param parent - Parent node.
960
+ * @param directive - Directive.
961
+ * @returns - Nodes.
997
962
  */
998
- function formatDOM$1(nodes, parent, directive) {
999
- parent = parent || null;
1000
- var result = [];
1001
- var tagName;
1002
-
1003
- for (var index = 0, len = nodes.length; index < len; index++) {
1004
- var node = nodes[index];
963
+ function formatDOM(nodes, parent, directive) {
964
+ if (parent === void 0) { parent = null; }
965
+ var result = [];
1005
966
  var current;
1006
-
1007
- // set the node data given the type
1008
- switch (node.nodeType) {
1009
- case 1:
1010
- tagName = formatTagName(node.nodeName);
1011
- // script, style, or tag
1012
- current = new Element(tagName, formatAttributes(node.attributes));
1013
- current.children = formatDOM$1(
1014
- // template children are on content
1015
- tagName === 'template' ? node.content.childNodes : node.childNodes,
1016
- current
1017
- );
1018
- break;
1019
-
1020
- case 3:
1021
- current = new Text(node.nodeValue);
1022
- break;
1023
-
1024
- case 8:
1025
- current = new Comment(node.nodeValue);
1026
- break;
1027
-
1028
- default:
1029
- continue;
1030
- }
1031
-
1032
- // set previous node next
1033
- var prev = result[index - 1] || null;
1034
- if (prev) {
1035
- prev.next = current;
967
+ var index = 0;
968
+ var nodesLength = nodes.length;
969
+ for (; index < nodesLength; index++) {
970
+ var node = nodes[index];
971
+ // set the node data given the type
972
+ switch (node.nodeType) {
973
+ case 1: {
974
+ var tagName = formatTagName(node.nodeName);
975
+ // script, style, or tag
976
+ current = new domhandler_1.Element(tagName, formatAttributes(node.attributes));
977
+ current.children = formatDOM(
978
+ // template children are on content
979
+ tagName === 'template'
980
+ ? node.content.childNodes
981
+ : node.childNodes, current);
982
+ break;
983
+ }
984
+ case 3:
985
+ current = new domhandler_1.Text(node.nodeValue);
986
+ break;
987
+ case 8:
988
+ current = new domhandler_1.Comment(node.nodeValue);
989
+ break;
990
+ default:
991
+ continue;
992
+ }
993
+ // set previous node next
994
+ var prev = result[index - 1] || null;
995
+ if (prev) {
996
+ prev.next = current;
997
+ }
998
+ // set properties for current node
999
+ current.parent = parent;
1000
+ current.prev = prev;
1001
+ current.next = null;
1002
+ result.push(current);
1036
1003
  }
1037
-
1038
- // set properties for current node
1039
- current.parent = parent;
1040
- current.prev = prev;
1041
- current.next = null;
1042
-
1043
- result.push(current);
1044
- }
1045
-
1046
- if (directive) {
1047
- current = new ProcessingInstruction(
1048
- directive.substring(0, directive.indexOf(' ')).toLowerCase(),
1049
- directive
1050
- );
1051
- current.next = result[0] || null;
1052
- current.parent = parent;
1053
- result.unshift(current);
1054
-
1055
- if (result[1]) {
1056
- result[1].prev = result[0];
1004
+ if (directive) {
1005
+ current = new domhandler_1.ProcessingInstruction(directive.substring(0, directive.indexOf(' ')).toLowerCase(), directive);
1006
+ current.next = result[0] || null;
1007
+ current.parent = parent;
1008
+ result.unshift(current);
1009
+ if (result[1]) {
1010
+ result[1].prev = result[0];
1011
+ }
1057
1012
  }
1058
- }
1059
-
1060
- return result;
1013
+ return result;
1061
1014
  }
1015
+ utilities$4.formatDOM = formatDOM;
1062
1016
 
1063
- utilities$5.formatAttributes = formatAttributes;
1064
- utilities$5.formatDOM = formatDOM$1;
1065
-
1066
- var domparser = domparser_1;
1067
- var utilities$4 = utilities$5;
1068
-
1069
- var formatDOM = utilities$4.formatDOM;
1070
-
1017
+ var __importDefault$1 = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
1018
+ return (mod && mod.__esModule) ? mod : { "default": mod };
1019
+ };
1020
+ Object.defineProperty(htmlToDom, "__esModule", { value: true });
1021
+ var domparser_1 = __importDefault$1(domparser$1);
1022
+ var utilities_1$1 = utilities$4;
1071
1023
  var DIRECTIVE_REGEX = /<(![a-zA-Z\s]+)>/; // e.g., <!doctype html>
1072
-
1073
1024
  /**
1074
1025
  * Parses HTML string to DOM nodes in browser.
1075
1026
  *
1076
- * @param {string} html - HTML markup.
1077
- * @return {DomElement[]} - DOM elements.
1027
+ * @param html - HTML markup.
1028
+ * @returns - DOM elements.
1078
1029
  */
1079
1030
  function HTMLDOMParser(html) {
1080
- if (typeof html !== 'string') {
1081
- throw new TypeError('First argument must be a string');
1082
- }
1083
-
1084
- if (html === '') {
1085
- return [];
1086
- }
1087
-
1088
- // match directive
1089
- var match = html.match(DIRECTIVE_REGEX);
1090
- var directive;
1091
-
1092
- if (match && match[1]) {
1093
- directive = match[1];
1094
- }
1095
-
1096
- return formatDOM(domparser(html), null, directive);
1031
+ if (typeof html !== 'string') {
1032
+ throw new TypeError('First argument must be a string');
1033
+ }
1034
+ if (html === '') {
1035
+ return [];
1036
+ }
1037
+ // match directive
1038
+ var match = html.match(DIRECTIVE_REGEX);
1039
+ var directive = match ? match[1] : undefined;
1040
+ return (0, utilities_1$1.formatDOM)((0, domparser_1.default)(html), null, directive);
1097
1041
  }
1098
-
1099
- var htmlToDom = HTMLDOMParser;
1042
+ htmlToDom.default = HTMLDOMParser;
1100
1043
 
1101
1044
  var lib = {};
1102
1045
 
@@ -2274,7 +2217,7 @@
2274
2217
  }
2275
2218
  cjs.default = StyleToJS;
2276
2219
 
2277
- var React$1 = require$$0__default["default"];
2220
+ var React$1 = require$$0;
2278
2221
  var styleToJS = cjs.default;
2279
2222
 
2280
2223
  /**
@@ -2509,7 +2452,7 @@
2509
2452
  return reactProperty.possibleStandardNames[attributeName];
2510
2453
  }
2511
2454
 
2512
- var React = require$$0__default["default"];
2455
+ var React = require$$0;
2513
2456
  var attributesToProps$1 = attributesToProps$2;
2514
2457
  var utilities = utilities$2;
2515
2458
 
@@ -2652,7 +2595,7 @@
2652
2595
  var domToReact_1 = domToReact$1;
2653
2596
 
2654
2597
  var domhandler = lib$2;
2655
- var htmlToDOM = htmlToDom;
2598
+ var htmlToDOM = htmlToDom.default;
2656
2599
 
2657
2600
  var attributesToProps = attributesToProps$2;
2658
2601
  var domToReact = domToReact_1;