happy-dom 9.10.9 → 9.11.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.

Potentially problematic release.


This version of happy-dom might be problematic. Click here for more details.

Files changed (56) hide show
  1. package/lib/config/PlainTextElements.d.ts +4 -1
  2. package/lib/config/PlainTextElements.d.ts.map +1 -1
  3. package/lib/config/PlainTextElements.js +4 -1
  4. package/lib/config/PlainTextElements.js.map +1 -1
  5. package/lib/config/UnnestableElements.d.ts +18 -1
  6. package/lib/config/UnnestableElements.d.ts.map +1 -1
  7. package/lib/config/UnnestableElements.js +18 -18
  8. package/lib/config/UnnestableElements.js.map +1 -1
  9. package/lib/config/VoidElements.d.ts +16 -1
  10. package/lib/config/VoidElements.d.ts.map +1 -1
  11. package/lib/config/VoidElements.js +16 -17
  12. package/lib/config/VoidElements.js.map +1 -1
  13. package/lib/dom-parser/DOMParser.js +2 -2
  14. package/lib/dom-parser/DOMParser.js.map +1 -1
  15. package/lib/nodes/document/Document.d.ts.map +1 -1
  16. package/lib/nodes/document/Document.js +19 -18
  17. package/lib/nodes/document/Document.js.map +1 -1
  18. package/lib/nodes/element/Element.d.ts.map +1 -1
  19. package/lib/nodes/element/Element.js +1 -3
  20. package/lib/nodes/element/Element.js.map +1 -1
  21. package/lib/nodes/html-template-element/HTMLTemplateElement.d.ts.map +1 -1
  22. package/lib/nodes/html-template-element/HTMLTemplateElement.js +2 -4
  23. package/lib/nodes/html-template-element/HTMLTemplateElement.js.map +1 -1
  24. package/lib/nodes/parent-node/ParentNodeUtility.d.ts +3 -3
  25. package/lib/nodes/parent-node/ParentNodeUtility.d.ts.map +1 -1
  26. package/lib/nodes/parent-node/ParentNodeUtility.js +1 -4
  27. package/lib/nodes/parent-node/ParentNodeUtility.js.map +1 -1
  28. package/lib/nodes/shadow-root/ShadowRoot.d.ts.map +1 -1
  29. package/lib/nodes/shadow-root/ShadowRoot.js +1 -3
  30. package/lib/nodes/shadow-root/ShadowRoot.js.map +1 -1
  31. package/lib/range/Range.js.map +1 -1
  32. package/lib/xml-parser/XMLParser.d.ts +14 -38
  33. package/lib/xml-parser/XMLParser.d.ts.map +1 -1
  34. package/lib/xml-parser/XMLParser.js +222 -200
  35. package/lib/xml-parser/XMLParser.js.map +1 -1
  36. package/lib/xml-serializer/XMLSerializer.d.ts.map +1 -1
  37. package/lib/xml-serializer/XMLSerializer.js +11 -7
  38. package/lib/xml-serializer/XMLSerializer.js.map +1 -1
  39. package/package.json +1 -1
  40. package/src/config/PlainTextElements.ts +4 -1
  41. package/src/config/UnnestableElements.ts +18 -18
  42. package/src/config/VoidElements.ts +16 -17
  43. package/src/dom-parser/DOMParser.ts +2 -2
  44. package/src/nodes/document/Document.ts +19 -18
  45. package/src/nodes/element/Element.ts +1 -3
  46. package/src/nodes/html-template-element/HTMLTemplateElement.ts +2 -4
  47. package/src/nodes/parent-node/ParentNodeUtility.ts +13 -11
  48. package/src/nodes/shadow-root/ShadowRoot.ts +1 -3
  49. package/src/range/Range.ts +1 -1
  50. package/src/xml-parser/XMLParser.ts +280 -226
  51. package/src/xml-serializer/XMLSerializer.ts +12 -7
  52. package/lib/config/ChildLessElements.d.ts +0 -3
  53. package/lib/config/ChildLessElements.d.ts.map +0 -1
  54. package/lib/config/ChildLessElements.js +0 -4
  55. package/lib/config/ChildLessElements.js.map +0 -1
  56. package/src/config/ChildLessElements.ts +0 -1
@@ -5,16 +5,48 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const VoidElements_1 = __importDefault(require("../config/VoidElements"));
7
7
  const UnnestableElements_1 = __importDefault(require("../config/UnnestableElements"));
8
- const ChildLessElements_1 = __importDefault(require("../config/ChildLessElements"));
9
- const he_1 = require("he");
10
8
  const NamespaceURI_1 = __importDefault(require("../config/NamespaceURI"));
11
9
  const PlainTextElements_1 = __importDefault(require("../config/PlainTextElements"));
12
- const CONDITION_COMMENT_REGEXP = /<!(--)?\[if (!|le|lt|lte|gt|gte|\(.*\)|&|\|| |IE|WindowsEdition|Contoso|true|false|\d+\.?(\d+)?|)*\]>/gi;
13
- const CONDITION_COMMENT_END_REGEXP = /<!\[endif\](--)?>/gi;
14
- const MARKUP_REGEXP = /<(\/?)([a-z][-.0-9_a-z]*)\s*([^<>]*?)(\/?)>/gi;
15
- const COMMENT_REGEXP = /<!--(.*?)-->|<([!?])([^>]*)>/gi;
10
+ const he_1 = require("he");
11
+ /**
12
+ * Markup RegExp.
13
+ *
14
+ * Group 1: Beginning of start tag (e.g. "div" in "<div").
15
+ * Group 2: End tag (e.g. "div" in "</div>").
16
+ * Group 3: Comment with ending "--" (e.g. " Comment 1 " in "<!-- Comment 1 -->").
17
+ * Group 4: Comment without ending "--" (e.g. " Comment 1 " in "<!-- Comment 1 >").
18
+ * Group 5: Exclamation mark comment (e.g. "DOCTYPE html" in "<!DOCTYPE html>").
19
+ * Group 6: Processing instruction (e.g. "xml version="1.0"?" in "<?xml version="1.0"?>").
20
+ * Group 7: End of self closing start tag (e.g. "/>" in "<img/>").
21
+ * Group 8: End of start tag (e.g. ">" in "<div>").
22
+ */
23
+ const MARKUP_REGEXP = /<([a-zA-Z0-9-]+)|<\/([a-zA-Z0-9-]+)>|<!--([^-]+)-->|<!--([^>]+)>|<!([^>]+)>|<\?([^>]+)>|(\/>)|(>)/gm;
24
+ /**
25
+ * Attribute RegExp.
26
+ *
27
+ * Group 1: Attribute name when the attribute has a value using double apostrophe (e.g. "name" in "<div name="value">").
28
+ * Group 2: Attribute apostrophe value using double apostrophe (e.g. "value" in "<div name="value">").
29
+ * Group 3: Attribute value when the attribute has a value using double apostrophe (e.g. "value" in "<div name="value">").
30
+ * Group 4: Attribute apostrophe when the attribute has a value using double apostrophe (e.g. "value" in "<div name="value">").
31
+ * Group 5: Attribute name when the attribute has a value using single apostrophe (e.g. "name" in "<div name='value'>").
32
+ * Group 6: Attribute apostrophe when the attribute has a value using single apostrophe (e.g. "name" in "<div name='value'>").
33
+ * Group 7: Attribute value when the attribute has a value using single apostrophe (e.g. "value" in "<div name='value'>").
34
+ * Group 8: Attribute apostrophe when the attribute has a value using single apostrophe (e.g. "name" in "<div name='value'>").
35
+ * Group 9: Attribute name when the attribute has no value (e.g. "disabled" in "<div disabled>").
36
+ */
37
+ const ATTRIBUTE_REGEXP = /\s*([a-zA-Z0-9-_:]+) *= *("{0,1})([^"]*)("{0,1})|\s*([a-zA-Z0-9-_:]+) *= *('{0,1})([^']*)('{0,1})|\s*([a-zA-Z0-9-_:]+)/gm;
38
+ var MarkupReadStateEnum;
39
+ (function (MarkupReadStateEnum) {
40
+ MarkupReadStateEnum["startOrEndTag"] = "startOrEndTag";
41
+ MarkupReadStateEnum["insideStartTag"] = "insideStartTag";
42
+ MarkupReadStateEnum["plainTextContent"] = "plainTextContent";
43
+ })(MarkupReadStateEnum || (MarkupReadStateEnum = {}));
44
+ /**
45
+ * Document type attribute RegExp.
46
+ *
47
+ * Group 1: Attribute value.
48
+ */
16
49
  const DOCUMENT_TYPE_ATTRIBUTE_REGEXP = /"([^"]+)"/gm;
17
- const ATTRIBUTE_REGEXP = /([^\s=]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|(\S+)))/gms;
18
50
  /**
19
51
  * XML parser.
20
52
  */
@@ -23,221 +55,211 @@ class XMLParser {
23
55
  * Parses XML/HTML and returns a root element.
24
56
  *
25
57
  * @param document Document.
26
- * @param data HTML data.
27
- * @param [evaluateScripts = false] Set to "true" to enable script execution.
28
- * @returns Root element.
58
+ * @param xml XML/HTML string.
59
+ * @param [options] Options.
60
+ * @param [options.rootNode] Node to append elements to. Otherwise a new DocumentFragment is created.
61
+ * @param [options.evaluateScripts = false] Set to "true" to enable script execution.
62
+ * @returns Root node.
29
63
  */
30
- static parse(document, data, evaluateScripts = false) {
31
- const root = document.createDocumentFragment();
64
+ static parse(document, xml, options) {
65
+ const root = options && options.rootNode ? options.rootNode : document.createDocumentFragment();
32
66
  const stack = [root];
33
- const markupRegexp = new RegExp(MARKUP_REGEXP, 'gi');
34
- let parent = root;
35
- let parentTagName = null;
36
- let parentUnnestableTagName = null;
37
- let lastTextIndex = 0;
67
+ const markupRegexp = new RegExp(MARKUP_REGEXP, 'gm');
68
+ const { evaluateScripts = false } = options || {};
69
+ const unnestableTagNames = [];
70
+ let currentNode = root;
38
71
  let match;
39
- if (data !== null && data !== undefined) {
40
- data = String(data);
41
- while ((match = markupRegexp.exec(data))) {
42
- const tagName = match[2].toLowerCase();
43
- const isStartTag = !match[1];
44
- if (parent && match.index !== lastTextIndex) {
45
- const text = data.substring(lastTextIndex, match.index);
46
- if (parentTagName && PlainTextElements_1.default.includes(parentTagName)) {
47
- parent.appendChild(document.createTextNode(text));
48
- }
49
- else {
50
- let condCommMatch;
51
- let condCommEndMatch;
52
- const condCommRegexp = new RegExp(CONDITION_COMMENT_REGEXP, 'gi');
53
- const condCommEndRegexp = new RegExp(CONDITION_COMMENT_END_REGEXP, 'gi');
54
- // @Refer: https://learn.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/?redirectedfrom=MSDN
55
- if (isStartTag &&
56
- (condCommMatch = condCommRegexp.exec(text)) &&
57
- condCommMatch[0] &&
58
- (condCommEndMatch = condCommEndRegexp.exec(data.substring(markupRegexp.lastIndex))) &&
59
- condCommEndMatch[0]) {
60
- markupRegexp.lastIndex += condCommEndRegexp.lastIndex;
61
- continue;
72
+ let plainTextTagName = null;
73
+ let readState = MarkupReadStateEnum.startOrEndTag;
74
+ let startTagIndex = 0;
75
+ let lastIndex = 0;
76
+ if (xml !== null && xml !== undefined) {
77
+ xml = String(xml);
78
+ while ((match = markupRegexp.exec(xml))) {
79
+ switch (readState) {
80
+ case MarkupReadStateEnum.startOrEndTag:
81
+ if (match.index !== lastIndex &&
82
+ (match[1] || match[2] || match[3] || match[4] || match[5] || match[6])) {
83
+ // Plain text between tags.
84
+ currentNode.appendChild(document.createTextNode(xml.substring(lastIndex, match.index)));
85
+ }
86
+ if (match[1]) {
87
+ // Start tag.
88
+ const tagName = match[1].toUpperCase();
89
+ // Some elements are not allowed to be nested (e.g. "<a><a></a></a>" is not allowed.).
90
+ // Therefore we need to auto-close the tag, so that it become valid (e.g. "<a></a><a></a>").
91
+ const unnestableTagNameIndex = unnestableTagNames.indexOf(tagName);
92
+ if (unnestableTagNameIndex !== -1) {
93
+ unnestableTagNames.splice(unnestableTagNameIndex, 1);
94
+ while (currentNode !== root) {
95
+ if (currentNode.tagName === tagName) {
96
+ stack.pop();
97
+ currentNode = stack[stack.length - 1] || root;
98
+ break;
99
+ }
100
+ stack.pop();
101
+ currentNode = stack[stack.length - 1] || root;
102
+ }
103
+ }
104
+ // NamespaceURI is inherited from the parent element.
105
+ // It should default to SVG for SVG elements.
106
+ const namespaceURI = tagName === 'SVG'
107
+ ? NamespaceURI_1.default.svg
108
+ : currentNode.namespaceURI || NamespaceURI_1.default.html;
109
+ const newElement = document.createElementNS(namespaceURI, tagName);
110
+ currentNode.appendChild(newElement);
111
+ currentNode = newElement;
112
+ stack.push(currentNode);
113
+ readState = MarkupReadStateEnum.insideStartTag;
114
+ startTagIndex = markupRegexp.lastIndex;
115
+ }
116
+ else if (match[2]) {
117
+ // End tag.
118
+ if (match[2].toUpperCase() === currentNode.tagName) {
119
+ // Some elements are not allowed to be nested (e.g. "<a><a></a></a>" is not allowed.).
120
+ // Therefore we need to auto-close the tag, so that it become valid (e.g. "<a></a><a></a>").
121
+ const unnestableTagNameIndex = unnestableTagNames.indexOf(currentNode.tagName);
122
+ if (unnestableTagNameIndex !== -1) {
123
+ unnestableTagNames.splice(unnestableTagNameIndex, 1);
124
+ }
125
+ stack.pop();
126
+ currentNode = stack[stack.length - 1] || root;
127
+ }
128
+ }
129
+ else if (match[3] ||
130
+ match[4] ||
131
+ (match[6] && currentNode.namespaceURI === NamespaceURI_1.default.html)) {
132
+ // Comment.
133
+ currentNode.appendChild(document.createComment((match[6] ? '?' : '') + (match[3] || match[4] || match[6])));
134
+ }
135
+ else if (match[5]) {
136
+ // Exclamation mark comment (usually <!DOCTYPE>).
137
+ currentNode.appendChild(this.getDocumentTypeNode(document, match[5]) || document.createComment(match[5]));
138
+ }
139
+ else if (match[6]) {
140
+ // Processing instruction (not supported by HTML).
141
+ // TODO: Add support for processing instructions.
62
142
  }
63
143
  else {
64
- this.appendTextAndCommentNodes(document, parent, text);
144
+ // Plain text between tags, including the match as it is not a valid start or end tag.
145
+ currentNode.appendChild(document.createTextNode(xml.substring(lastIndex, markupRegexp.lastIndex)));
65
146
  }
66
- }
67
- }
68
- if (isStartTag) {
69
- const namespaceURI = tagName === 'svg'
70
- ? NamespaceURI_1.default.svg
71
- : parent.namespaceURI || NamespaceURI_1.default.html;
72
- const newElement = document.createElementNS(namespaceURI, tagName);
73
- // Scripts are not allowed to be executed when they are parsed using innerHTML, outerHTML, replaceWith() etc.
74
- // However, they are allowed to be executed when document.write() is used.
75
- // See: https://developer.mozilla.org/en-US/docs/Web/API/HTMLScriptElement
76
- if (tagName === 'script') {
77
- newElement._evaluateScript = evaluateScripts;
78
- }
79
- // An assumption that the same rule should be applied for the HTMLLinkElement is made here.
80
- if (tagName === 'link') {
81
- newElement._evaluateCSS = evaluateScripts;
82
- }
83
- this.setAttributes(newElement, match[3]);
84
- if (!match[4] && !VoidElements_1.default.includes(tagName)) {
85
- // Some elements are not allowed to be nested (e.g. "<a><a></a></a>" is not allowed.).
86
- // Therefore we will auto-close the tag.
87
- if (parentUnnestableTagName === tagName) {
88
- stack.pop();
89
- parent = parent.parentNode || root;
147
+ break;
148
+ case MarkupReadStateEnum.insideStartTag:
149
+ // End of start tag
150
+ if (match[7] || match[8]) {
151
+ // End of start tag.
152
+ // Attribute name and value.
153
+ const attributeString = xml.substring(startTagIndex, match.index);
154
+ let hasAttributeStringEnded = true;
155
+ if (!!attributeString) {
156
+ const attributeRegexp = new RegExp(ATTRIBUTE_REGEXP, 'gm');
157
+ let attributeMatch;
158
+ while ((attributeMatch = attributeRegexp.exec(attributeString))) {
159
+ if ((attributeMatch[1] && attributeMatch[2] === attributeMatch[4]) ||
160
+ (attributeMatch[5] && attributeMatch[6] === attributeMatch[8]) ||
161
+ attributeMatch[9]) {
162
+ // Valid attribute name and value.
163
+ const name = attributeMatch[1] || attributeMatch[5] || attributeMatch[9] || '';
164
+ const rawValue = attributeMatch[3] || attributeMatch[7] || '';
165
+ const value = rawValue ? (0, he_1.decode)(rawValue) : '';
166
+ const namespaceURI = currentNode.tagName === 'SVG' && name === 'xmlns' ? value : null;
167
+ currentNode.setAttributeNS(namespaceURI, name, value);
168
+ startTagIndex += attributeMatch[0].length;
169
+ }
170
+ else if (!attributeMatch[4] && !attributeMatch[8]) {
171
+ // End attribute apostrophe is missing (e.g. "attr='value" or 'attr="value').
172
+ hasAttributeStringEnded = false;
173
+ break;
174
+ }
175
+ }
176
+ }
177
+ // We need to check if the attribute string is read completely.
178
+ // The attribute string can potentially contain "/>" or ">".
179
+ if (hasAttributeStringEnded) {
180
+ // Checks if the tag is a self closing tag (ends with "/>") or void element.
181
+ // When it is a self closing tag or void element it should be closed immediately.
182
+ // Self closing tags are not allowed in the HTML namespace, but the parser should still allow it for void elements.
183
+ // Self closing tags is supported in the SVG namespace.
184
+ if (VoidElements_1.default[currentNode.tagName] ||
185
+ (match[7] && currentNode.namespaceURI === NamespaceURI_1.default.svg)) {
186
+ stack.pop();
187
+ currentNode = stack[stack.length - 1] || root;
188
+ readState = MarkupReadStateEnum.startOrEndTag;
189
+ }
190
+ else {
191
+ // Plain text elements such as <script> and <style> should only contain text.
192
+ plainTextTagName = PlainTextElements_1.default[currentNode.tagName]
193
+ ? currentNode.tagName
194
+ : null;
195
+ readState = !!plainTextTagName
196
+ ? MarkupReadStateEnum.plainTextContent
197
+ : MarkupReadStateEnum.startOrEndTag;
198
+ if (UnnestableElements_1.default[currentNode.tagName]) {
199
+ unnestableTagNames.push(currentNode.tagName);
200
+ }
201
+ }
202
+ startTagIndex = markupRegexp.lastIndex;
203
+ }
90
204
  }
91
- parent = parent.appendChild(newElement);
92
- parentTagName = tagName;
93
- parentUnnestableTagName = this.getUnnestableTagName(parent);
94
- stack.push(parent);
95
- }
96
- else {
97
- parent.appendChild(newElement);
98
- }
99
- lastTextIndex = markupRegexp.lastIndex;
100
- // Tags which contain non-parsed content
101
- // For example: <script> JavaScript should not be parsed
102
- if (ChildLessElements_1.default.includes(tagName)) {
103
- let childLessMatch = null;
104
- while ((childLessMatch = markupRegexp.exec(data))) {
105
- if (childLessMatch[2].toLowerCase() === tagName && childLessMatch[1]) {
106
- markupRegexp.lastIndex -= childLessMatch[0].length;
107
- break;
205
+ break;
206
+ case MarkupReadStateEnum.plainTextContent:
207
+ if (match[2] && match[2].toUpperCase() === plainTextTagName) {
208
+ // End of plain text tag.
209
+ // Scripts are not allowed to be executed when they are parsed using innerHTML, outerHTML, replaceWith() etc.
210
+ // However, they are allowed to be executed when document.write() is used.
211
+ // See: https://developer.mozilla.org/en-US/docs/Web/API/HTMLScriptElement
212
+ if (plainTextTagName === 'SCRIPT') {
213
+ currentNode._evaluateScript = evaluateScripts;
108
214
  }
215
+ else if (plainTextTagName === 'LINK') {
216
+ // An assumption that the same rule should be applied for the HTMLLinkElement is made here.
217
+ currentNode._evaluateCSS = evaluateScripts;
218
+ }
219
+ // Plain text elements such as <script> and <style> should only contain text.
220
+ currentNode.appendChild(document.createTextNode(xml.substring(startTagIndex, match.index)));
221
+ stack.pop();
222
+ currentNode = stack[stack.length - 1] || root;
223
+ plainTextTagName = null;
224
+ readState = MarkupReadStateEnum.startOrEndTag;
109
225
  }
110
- }
111
- }
112
- else {
113
- stack.pop();
114
- parent = stack[stack.length - 1] || root;
115
- parentTagName = parent.tagName
116
- ? parent.tagName.toLowerCase()
117
- : null;
118
- parentUnnestableTagName = this.getUnnestableTagName(parent);
119
- lastTextIndex = markupRegexp.lastIndex;
226
+ break;
120
227
  }
228
+ lastIndex = markupRegexp.lastIndex;
121
229
  }
122
- // Text after last element
123
- if ((!match && data.length > 0) || (match && lastTextIndex !== match.index)) {
124
- const text = data.substring(lastTextIndex);
125
- this.appendTextAndCommentNodes(document, parent || root, text);
230
+ if (lastIndex !== xml.length) {
231
+ // Plain text after tags.
232
+ currentNode.appendChild(document.createTextNode(xml.substring(lastIndex)));
126
233
  }
127
234
  }
128
235
  return root;
129
236
  }
130
237
  /**
131
- * Returns a tag name if element is unnestable.
132
- *
133
- * @param element Element.
134
- * @returns Tag name if element is unnestable.
135
- */
136
- static getUnnestableTagName(element) {
137
- const tagName = element.tagName ? element.tagName.toLowerCase() : null;
138
- return tagName && UnnestableElements_1.default.includes(tagName) ? tagName : null;
139
- }
140
- /**
141
- * Appends text and comment nodes.
142
- *
143
- * @param document Document.
144
- * @param node Node.
145
- * @param text Text to search in.
146
- */
147
- static appendTextAndCommentNodes(document, node, text) {
148
- for (const innerNode of this.getTextAndCommentNodes(document, text)) {
149
- node.appendChild(innerNode);
150
- }
151
- }
152
- /**
153
- * Returns text and comment nodes from a text.
238
+ * Returns document type node.
154
239
  *
155
240
  * @param document Document.
156
- * @param text Text to search in.
157
- * @returns Nodes.
241
+ * @param value Value.
242
+ * @returns Document type node.
158
243
  */
159
- static getTextAndCommentNodes(document, text) {
160
- const nodes = [];
161
- const commentRegExp = new RegExp(COMMENT_REGEXP, 'gms');
162
- let hasDocumentType = false;
163
- let lastIndex = 0;
164
- let match;
165
- while ((match = commentRegExp.exec(text))) {
166
- if (match.index > 0 && lastIndex !== match.index) {
167
- const textNode = document.createTextNode(text.substring(lastIndex, match.index));
168
- nodes.push(textNode);
169
- }
170
- if (match[3] && match[3].toUpperCase().startsWith('DOCTYPE')) {
171
- const docTypeSplit = match[3].split(' ');
172
- if (docTypeSplit.length > 1) {
173
- const docTypeString = docTypeSplit.slice(1).join(' ');
174
- const attributes = [];
175
- const attributeRegExp = new RegExp(DOCUMENT_TYPE_ATTRIBUTE_REGEXP, 'gm');
176
- const isPublic = docTypeString.includes('PUBLIC');
177
- let attributeMatch;
178
- while ((attributeMatch = attributeRegExp.exec(docTypeString))) {
179
- attributes.push(attributeMatch[1]);
180
- }
181
- const publicId = isPublic ? attributes[0] || '' : '';
182
- const systemId = isPublic ? attributes[1] || '' : attributes[0] || '';
183
- const documentTypeNode = document.implementation.createDocumentType(docTypeSplit[1], publicId, systemId);
184
- nodes.push(documentTypeNode);
185
- hasDocumentType = true;
186
- }
187
- }
188
- else {
189
- const comment = match[1] ? match[1] : match[2] === '?' ? '?' + match[3] : match[3];
190
- const commentNode = document.createComment(comment);
191
- nodes.push(commentNode);
192
- lastIndex = match.index + match[0].length;
193
- }
244
+ static getDocumentTypeNode(document, value) {
245
+ if (!value.toUpperCase().startsWith('DOCTYPE')) {
246
+ return null;
194
247
  }
195
- if (!hasDocumentType && lastIndex < text.length) {
196
- const textNode = document.createTextNode(text.substring(lastIndex));
197
- nodes.push(textNode);
248
+ const docTypeSplit = value.split(' ');
249
+ if (docTypeSplit.length <= 1) {
250
+ return null;
198
251
  }
199
- return nodes;
200
- }
201
- /**
202
- * Sets raw attributes.
203
- *
204
- * @param element Element.
205
- * @param attributesString Raw attributes.
206
- */
207
- static setAttributes(element, attributesString) {
208
- const attributes = attributesString.trim();
209
- if (attributes) {
210
- const regExp = new RegExp(ATTRIBUTE_REGEXP, 'gi');
211
- let match;
212
- // Attributes with value
213
- while ((match = regExp.exec(attributes))) {
214
- if (match[1]) {
215
- const value = (0, he_1.decode)(match[2] || match[3] || match[4] || '');
216
- const name = this._getAttributeName(element.namespaceURI, match[1]);
217
- const namespaceURI = element.tagName === 'SVG' && name === 'xmlns' ? value : null;
218
- element.setAttributeNS(namespaceURI, name, value);
219
- }
220
- }
221
- // Attributes with no value
222
- for (const name of attributes.replace(ATTRIBUTE_REGEXP, '').trim().split(' ')) {
223
- if (name) {
224
- element.setAttribute(this._getAttributeName(element.namespaceURI, name), '');
225
- }
226
- }
227
- }
228
- }
229
- /**
230
- * Returns attribute name.
231
- *
232
- * @param namespaceURI Namespace URI.
233
- * @param name Name.
234
- * @returns Attribute name based on namespace.
235
- */
236
- static _getAttributeName(namespaceURI, name) {
237
- if (namespaceURI === NamespaceURI_1.default.svg) {
238
- return name;
252
+ const docTypeString = docTypeSplit.slice(1).join(' ');
253
+ const attributes = [];
254
+ const attributeRegExp = new RegExp(DOCUMENT_TYPE_ATTRIBUTE_REGEXP, 'gm');
255
+ const isPublic = docTypeString.toUpperCase().includes('PUBLIC');
256
+ let attributeMatch;
257
+ while ((attributeMatch = attributeRegExp.exec(docTypeString))) {
258
+ attributes.push(attributeMatch[1]);
239
259
  }
240
- return name.toLowerCase();
260
+ const publicId = isPublic ? attributes[0] || '' : '';
261
+ const systemId = isPublic ? attributes[1] || '' : attributes[0] || '';
262
+ return document.implementation.createDocumentType(docTypeSplit[1].toLowerCase(), publicId, systemId);
241
263
  }
242
264
  }
243
265
  exports.default = XMLParser;
@@ -1 +1 @@
1
- {"version":3,"file":"XMLParser.js","sourceRoot":"","sources":["../../src/xml-parser/XMLParser.ts"],"names":[],"mappings":";;;;;AAGA,0EAAkD;AAClD,sFAA8D;AAC9D,oFAA4D;AAC5D,2BAA4B;AAC5B,0EAAkD;AAMlD,oFAA4D;AAE5D,MAAM,wBAAwB,GAC7B,yGAAyG,CAAC;AAC3G,MAAM,4BAA4B,GAAG,qBAAqB,CAAC;AAC3D,MAAM,aAAa,GAAG,+CAA+C,CAAC;AACtE,MAAM,cAAc,GAAG,gCAAgC,CAAC;AACxD,MAAM,8BAA8B,GAAG,aAAa,CAAC;AACrD,MAAM,gBAAgB,GAAG,sDAAsD,CAAC;AAEhF;;GAEG;AACH,MAAqB,SAAS;IAC7B;;;;;;;OAOG;IACI,MAAM,CAAC,KAAK,CAClB,QAAmB,EACnB,IAAY,EACZ,eAAe,GAAG,KAAK;QAEvB,MAAM,IAAI,GAAG,QAAQ,CAAC,sBAAsB,EAAE,CAAC;QAC/C,MAAM,KAAK,GAAwC,CAAC,IAAI,CAAC,CAAC;QAC1D,MAAM,YAAY,GAAG,IAAI,MAAM,CAAC,aAAa,EAAE,IAAI,CA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AU,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACrD,MAAM,QAAQ,GAAG,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QAEtE,OAAO,QAAQ,CAAC,cAAc,CAAC,kBAAkB,CAChD,YAAY,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,EAC7B,QAAQ,EACR,QAAQ,CACR,CAAC;IACH,CAAC;CACD;AAnRD,4BAmRC"}
@@ -1 +1 @@
1
- {"version":3,"file":"XMLSerializer.d.ts","sourceRoot":"","sources":["../../src/xml-serializer/XMLSerializer.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,MAAM,qBAAqB,CAAC;AAIxC;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,aAAa;IACjC;;;;;;;OAOG;IACI,iBAAiB,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,EAAE;QAAE,kBAAkB,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,MAAM;IAqDzF;;;;;OAKG;IACH,OAAO,CAAC,cAAc;CActB"}
1
+ {"version":3,"file":"XMLSerializer.d.ts","sourceRoot":"","sources":["../../src/xml-serializer/XMLSerializer.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,MAAM,qBAAqB,CAAC;AAMxC;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,aAAa;IACjC;;;;;;;OAOG;IACI,iBAAiB,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,EAAE;QAAE,kBAAkB,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,MAAM;IAwDzF;;;;;OAKG;IACH,OAAO,CAAC,cAAc;CActB"}
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const Node_1 = __importDefault(require("../nodes/node/Node"));
7
7
  const VoidElements_1 = __importDefault(require("../config/VoidElements"));
8
8
  const he_1 = require("he");
9
+ const NodeTypeEnum_1 = __importDefault(require("../nodes/node/NodeTypeEnum"));
9
10
  /**
10
11
  * Utility for converting an element to string.
11
12
  */
@@ -20,13 +21,13 @@ class XMLSerializer {
20
21
  */
21
22
  serializeToString(root, options) {
22
23
  switch (root.nodeType) {
23
- case Node_1.default.ELEMENT_NODE:
24
+ case NodeTypeEnum_1.default.elementNode:
24
25
  const element = root;
25
26
  const tagName = element.tagName.toLowerCase();
26
- if (VoidElements_1.default.includes(tagName)) {
27
+ if (VoidElements_1.default[element.tagName]) {
27
28
  return `<${tagName}${this._getAttributes(element)}>`;
28
29
  }
29
- const childNodes = element.tagName === 'TEMPLATE'
30
+ const childNodes = tagName === 'template'
30
31
  ? root.content.childNodes
31
32
  : root.childNodes;
32
33
  let innerHTML = '';
@@ -48,11 +49,14 @@ class XMLSerializer {
48
49
  html += this.serializeToString(node, options);
49
50
  }
50
51
  return html;
51
- case Node_1.default.COMMENT_NODE:
52
+ case NodeTypeEnum_1.default.commentNode:
52
53
  return `<!--${root.textContent}-->`;
53
- case Node_1.default.TEXT_NODE:
54
- return root['textContent'];
55
- case Node_1.default.DOCUMENT_TYPE_NODE:
54
+ case NodeTypeEnum_1.default.processingInstructionNode:
55
+ // TODO: Add support for processing instructions.
56
+ return `<!--?${root.target} ${root.textContent}?-->`;
57
+ case NodeTypeEnum_1.default.textNode:
58
+ return root.textContent;
59
+ case NodeTypeEnum_1.default.documentTypeNode:
56
60
  const doctype = root;
57
61
  const identifier = doctype.publicId ? ' PUBLIC' : doctype.systemId ? ' SYSTEM' : '';
58
62
  const publicId = doctype.publicId ? ` "${doctype.publicId}"` : '';
@@ -1 +1 @@
1
- {"version":3,"file":"XMLSerializer.js","sourceRoot":"","sources":["../../src/xml-serializer/XMLSerializer.ts"],"names":[],"mappings":";;;;;AACA,8DAAsC;AACtC,0EAAkD;AAElD,2BAA4B;AAK5B;;GAEG;AACH,MAAqB,aAAa;IACjC;;;;;;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AQ,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;gBAClE,OAAO,aAAa,OAAO,CAAC,IAAI,GAAG,UAAU,GAAG,QAAQ,GAAG,QAAQ,GAAG,CAAC;SACxE;QAED,OAAO,EAAE,CAAC;IACX,CAAC;IAED;;;;;OAKG;IACK,cAAc,CAAC,OAAiB;QACvC,IAAI,eAAe,GAAG,EAAE,CAAC;QAEzB,IAAI,CAAW,OAAQ,CAAC,WAAW,CAAC,EAAE,IAAc,OAAQ,CAAC,QAAQ,EAAE;YACtE,eAAe,IAAI,OAAO,GAAG,IAAA,WAAM,EAAW,OAAQ,CAAC,QAAQ,CAAC,GAAG,GAAG,CAAC;SACvE;QAED,KAAK,MAAM,SAAS,IAAI,MAAM,CAAC,MAAM,CAAW,OAAQ,CAAC,WAAW,CAAC,EAAE;YACtE,IAAI,SAAS,CAAC,KAAK,KAAK,IAAI,EAAE;gBAC7B,eAAe,IAAI,GAAG,GAAG,SAAS,CAAC,IAAI,GAAG,IAAI,GAAG,IAAA,WAAM,EAAC,SAAS,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC;aAC/E;SACD;QACD,OAAO,eAAe,CAAC;IACxB,CAAC;CACD;AArFD,gCAqFC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "happy-dom",
3
- "version": "9.10.9",
3
+ "version": "9.11.0",
4
4
  "license": "MIT",
5
5
  "homepage": "https://github.com/capricorn86/happy-dom",
6
6
  "repository": "https://github.com/capricorn86/happy-dom",
@@ -1 +1,4 @@
1
- export default ['style', 'script'];
1
+ export default {
2
+ STYLE: true,
3
+ SCRIPT: true
4
+ };