happy-dom 15.11.7 → 16.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.
Files changed (476) hide show
  1. package/cjs/PropertySymbol.cjs +12 -9
  2. package/cjs/PropertySymbol.cjs.map +1 -1
  3. package/cjs/PropertySymbol.d.ts +4 -1
  4. package/cjs/PropertySymbol.d.ts.map +1 -1
  5. package/cjs/config/HTMLElementConfig.cjs +42 -16
  6. package/cjs/config/HTMLElementConfig.cjs.map +1 -1
  7. package/cjs/config/HTMLElementConfig.d.ts +7 -0
  8. package/cjs/config/HTMLElementConfig.d.ts.map +1 -1
  9. package/cjs/config/HTMLElementConfigContentModelEnum.cjs +3 -0
  10. package/cjs/config/HTMLElementConfigContentModelEnum.cjs.map +1 -1
  11. package/cjs/config/HTMLElementConfigContentModelEnum.d.ts +3 -0
  12. package/cjs/config/HTMLElementConfigContentModelEnum.d.ts.map +1 -1
  13. package/cjs/config/NamespaceURI.cjs +2 -0
  14. package/cjs/config/NamespaceURI.cjs.map +1 -1
  15. package/cjs/config/NamespaceURI.d.ts +2 -0
  16. package/cjs/config/NamespaceURI.d.ts.map +1 -1
  17. package/cjs/css/declaration/CSSStyleDeclaration.cjs +1 -1
  18. package/cjs/css/declaration/CSSStyleDeclaration.cjs.map +1 -1
  19. package/cjs/css/declaration/CSSStyleDeclaration.d.ts.map +1 -1
  20. package/cjs/css/declaration/computed-style/CSSStyleDeclarationComputedStyle.cjs +2 -2
  21. package/cjs/css/declaration/computed-style/CSSStyleDeclarationComputedStyle.cjs.map +1 -1
  22. package/cjs/css/declaration/computed-style/CSSStyleDeclarationComputedStyle.d.ts.map +1 -1
  23. package/cjs/custom-element/CustomElementReactionStack.cjs +100 -0
  24. package/cjs/custom-element/CustomElementReactionStack.cjs.map +1 -0
  25. package/cjs/custom-element/CustomElementReactionStack.d.ts +27 -0
  26. package/cjs/custom-element/CustomElementReactionStack.d.ts.map +1 -0
  27. package/cjs/custom-element/CustomElementRegistry.cjs +32 -45
  28. package/cjs/custom-element/CustomElementRegistry.cjs.map +1 -1
  29. package/cjs/custom-element/CustomElementRegistry.d.ts +2 -6
  30. package/cjs/custom-element/CustomElementRegistry.d.ts.map +1 -1
  31. package/cjs/custom-element/CustomElementUtility.cjs +35 -0
  32. package/cjs/custom-element/CustomElementUtility.cjs.map +1 -0
  33. package/cjs/custom-element/CustomElementUtility.d.ts +14 -0
  34. package/cjs/custom-element/CustomElementUtility.d.ts.map +1 -0
  35. package/cjs/custom-element/ICustomElementDefinition.cjs +3 -0
  36. package/cjs/custom-element/ICustomElementDefinition.cjs.map +1 -0
  37. package/cjs/custom-element/ICustomElementDefinition.d.ts +12 -0
  38. package/cjs/custom-element/ICustomElementDefinition.d.ts.map +1 -0
  39. package/cjs/dom/DOMStringMap.cjs +8 -8
  40. package/cjs/dom/DOMStringMap.cjs.map +1 -1
  41. package/cjs/dom/DOMStringMap.d.ts.map +1 -1
  42. package/cjs/dom/DOMTokenList.cjs +1 -1
  43. package/cjs/dom/DOMTokenList.cjs.map +1 -1
  44. package/cjs/dom-parser/DOMParser.cjs +5 -67
  45. package/cjs/dom-parser/DOMParser.cjs.map +1 -1
  46. package/cjs/dom-parser/DOMParser.d.ts +0 -1
  47. package/cjs/dom-parser/DOMParser.d.ts.map +1 -1
  48. package/cjs/exception/DOMExceptionNameEnum.cjs +1 -0
  49. package/cjs/exception/DOMExceptionNameEnum.cjs.map +1 -1
  50. package/cjs/exception/DOMExceptionNameEnum.d.ts +2 -1
  51. package/cjs/exception/DOMExceptionNameEnum.d.ts.map +1 -1
  52. package/cjs/history/History.cjs +6 -6
  53. package/cjs/history/History.cjs.map +1 -1
  54. package/cjs/html-parser/HTMLParser.cjs +726 -0
  55. package/cjs/html-parser/HTMLParser.cjs.map +1 -0
  56. package/cjs/html-parser/HTMLParser.d.ts +91 -0
  57. package/cjs/html-parser/HTMLParser.d.ts.map +1 -0
  58. package/cjs/html-serializer/HTMLSerializer.cjs +152 -0
  59. package/cjs/html-serializer/HTMLSerializer.cjs.map +1 -0
  60. package/cjs/html-serializer/HTMLSerializer.d.ts +36 -0
  61. package/cjs/html-serializer/HTMLSerializer.d.ts.map +1 -0
  62. package/cjs/nodes/document/Document.cjs +105 -121
  63. package/cjs/nodes/document/Document.cjs.map +1 -1
  64. package/cjs/nodes/document/Document.d.ts +8 -0
  65. package/cjs/nodes/document/Document.d.ts.map +1 -1
  66. package/cjs/nodes/element/Element.cjs +35 -53
  67. package/cjs/nodes/element/Element.cjs.map +1 -1
  68. package/cjs/nodes/element/Element.d.ts +2 -12
  69. package/cjs/nodes/element/Element.d.ts.map +1 -1
  70. package/cjs/nodes/element/HTMLCollection.cjs +5 -9
  71. package/cjs/nodes/element/HTMLCollection.cjs.map +1 -1
  72. package/cjs/nodes/element/HTMLCollection.d.ts.map +1 -1
  73. package/cjs/nodes/element/NamedNodeMap.cjs +39 -52
  74. package/cjs/nodes/element/NamedNodeMap.cjs.map +1 -1
  75. package/cjs/nodes/element/NamedNodeMap.d.ts +1 -16
  76. package/cjs/nodes/element/NamedNodeMap.d.ts.map +1 -1
  77. package/cjs/nodes/element/NamedNodeMapProxyFactory.cjs +12 -14
  78. package/cjs/nodes/element/NamedNodeMapProxyFactory.cjs.map +1 -1
  79. package/cjs/nodes/element/NamedNodeMapProxyFactory.d.ts.map +1 -1
  80. package/cjs/nodes/html-button-element/HTMLButtonElement.cjs +1 -1
  81. package/cjs/nodes/html-button-element/HTMLButtonElement.cjs.map +1 -1
  82. package/cjs/nodes/html-button-element/HTMLButtonElement.d.ts.map +1 -1
  83. package/cjs/nodes/html-document/HTMLDocument.cjs +33 -2
  84. package/cjs/nodes/html-document/HTMLDocument.cjs.map +1 -1
  85. package/cjs/nodes/html-document/HTMLDocument.d.ts +10 -0
  86. package/cjs/nodes/html-document/HTMLDocument.d.ts.map +1 -1
  87. package/cjs/nodes/html-element/HTMLElement.cjs +52 -22
  88. package/cjs/nodes/html-element/HTMLElement.cjs.map +1 -1
  89. package/cjs/nodes/html-element/HTMLElement.d.ts +34 -0
  90. package/cjs/nodes/html-element/HTMLElement.d.ts.map +1 -1
  91. package/cjs/nodes/html-field-set-element/HTMLFieldSetElement.cjs +1 -1
  92. package/cjs/nodes/html-field-set-element/HTMLFieldSetElement.cjs.map +1 -1
  93. package/cjs/nodes/html-field-set-element/HTMLFieldSetElement.d.ts.map +1 -1
  94. package/cjs/nodes/html-form-element/HTMLFormElement.cjs +5 -8
  95. package/cjs/nodes/html-form-element/HTMLFormElement.cjs.map +1 -1
  96. package/cjs/nodes/html-form-element/HTMLFormElement.d.ts.map +1 -1
  97. package/cjs/nodes/html-iframe-element/HTMLIFrameElement.cjs +1 -1
  98. package/cjs/nodes/html-iframe-element/HTMLIFrameElement.cjs.map +1 -1
  99. package/cjs/nodes/html-input-element/HTMLInputElement.cjs +1 -1
  100. package/cjs/nodes/html-input-element/HTMLInputElement.cjs.map +1 -1
  101. package/cjs/nodes/html-input-element/HTMLInputElement.d.ts.map +1 -1
  102. package/cjs/nodes/html-media-element/TextTrackList.cjs +1 -1
  103. package/cjs/nodes/html-media-element/TextTrackList.cjs.map +1 -1
  104. package/cjs/nodes/html-object-element/HTMLObjectElement.cjs +1 -1
  105. package/cjs/nodes/html-object-element/HTMLObjectElement.cjs.map +1 -1
  106. package/cjs/nodes/html-object-element/HTMLObjectElement.d.ts.map +1 -1
  107. package/cjs/nodes/html-output-element/HTMLOutputElement.cjs +1 -1
  108. package/cjs/nodes/html-output-element/HTMLOutputElement.cjs.map +1 -1
  109. package/cjs/nodes/html-output-element/HTMLOutputElement.d.ts.map +1 -1
  110. package/cjs/nodes/html-script-element/HTMLScriptElement.cjs +3 -1
  111. package/cjs/nodes/html-script-element/HTMLScriptElement.cjs.map +1 -1
  112. package/cjs/nodes/html-script-element/HTMLScriptElement.d.ts.map +1 -1
  113. package/cjs/nodes/html-select-element/HTMLSelectElement.cjs +2 -2
  114. package/cjs/nodes/html-select-element/HTMLSelectElement.cjs.map +1 -1
  115. package/cjs/nodes/html-select-element/HTMLSelectElement.d.ts.map +1 -1
  116. package/cjs/nodes/html-table-element/HTMLTableElement.cjs +9 -1
  117. package/cjs/nodes/html-table-element/HTMLTableElement.cjs.map +1 -1
  118. package/cjs/nodes/html-table-element/HTMLTableElement.d.ts.map +1 -1
  119. package/cjs/nodes/html-table-row-element/HTMLTableRowElement.cjs +1 -1
  120. package/cjs/nodes/html-template-element/HTMLTemplateElement.cjs +15 -17
  121. package/cjs/nodes/html-template-element/HTMLTemplateElement.cjs.map +1 -1
  122. package/cjs/nodes/html-template-element/HTMLTemplateElement.d.ts +2 -2
  123. package/cjs/nodes/html-template-element/HTMLTemplateElement.d.ts.map +1 -1
  124. package/cjs/nodes/html-text-area-element/HTMLTextAreaElement.cjs +1 -1
  125. package/cjs/nodes/html-text-area-element/HTMLTextAreaElement.cjs.map +1 -1
  126. package/cjs/nodes/html-text-area-element/HTMLTextAreaElement.d.ts.map +1 -1
  127. package/cjs/nodes/node/Node.cjs +44 -48
  128. package/cjs/nodes/node/Node.cjs.map +1 -1
  129. package/cjs/nodes/node/Node.d.ts +2 -10
  130. package/cjs/nodes/node/Node.d.ts.map +1 -1
  131. package/cjs/nodes/node/NodeList.cjs +1 -1
  132. package/cjs/nodes/node/NodeList.cjs.map +1 -1
  133. package/cjs/nodes/node/NodeUtility.cjs +4 -3
  134. package/cjs/nodes/node/NodeUtility.cjs.map +1 -1
  135. package/cjs/nodes/node/NodeUtility.d.ts.map +1 -1
  136. package/cjs/nodes/parent-node/ParentNodeUtility.cjs +5 -2
  137. package/cjs/nodes/parent-node/ParentNodeUtility.cjs.map +1 -1
  138. package/cjs/nodes/parent-node/ParentNodeUtility.d.ts.map +1 -1
  139. package/cjs/nodes/shadow-root/ShadowRoot.cjs +8 -8
  140. package/cjs/nodes/shadow-root/ShadowRoot.cjs.map +1 -1
  141. package/cjs/nodes/shadow-root/ShadowRoot.d.ts.map +1 -1
  142. package/cjs/nodes/xml-document/XMLDocument.cjs +26 -0
  143. package/cjs/nodes/xml-document/XMLDocument.cjs.map +1 -1
  144. package/cjs/nodes/xml-document/XMLDocument.d.ts +2 -0
  145. package/cjs/nodes/xml-document/XMLDocument.d.ts.map +1 -1
  146. package/cjs/query-selector/SelectorItem.cjs +1 -2
  147. package/cjs/query-selector/SelectorItem.cjs.map +1 -1
  148. package/cjs/query-selector/SelectorItem.d.ts.map +1 -1
  149. package/cjs/range/Range.cjs +3 -3
  150. package/cjs/range/Range.cjs.map +1 -1
  151. package/cjs/range/Range.d.ts.map +1 -1
  152. package/cjs/storage/Storage.cjs +1 -1
  153. package/cjs/storage/Storage.cjs.map +1 -1
  154. package/cjs/svg/SVGLengthList.cjs +1 -1
  155. package/cjs/svg/SVGLengthList.cjs.map +1 -1
  156. package/cjs/svg/SVGNumberList.cjs +1 -1
  157. package/cjs/svg/SVGNumberList.cjs.map +1 -1
  158. package/cjs/svg/SVGPointList.cjs +1 -1
  159. package/cjs/svg/SVGPointList.cjs.map +1 -1
  160. package/cjs/svg/SVGStringList.cjs +1 -1
  161. package/cjs/svg/SVGStringList.cjs.map +1 -1
  162. package/cjs/svg/SVGTransformList.cjs +1 -1
  163. package/cjs/svg/SVGTransformList.cjs.map +1 -1
  164. package/cjs/tree-walker/NodeIterator.cjs +63 -6
  165. package/cjs/tree-walker/NodeIterator.cjs.map +1 -1
  166. package/cjs/tree-walker/NodeIterator.d.ts +18 -3
  167. package/cjs/tree-walker/NodeIterator.d.ts.map +1 -1
  168. package/cjs/tree-walker/TreeWalker.cjs +6 -6
  169. package/cjs/tree-walker/TreeWalker.cjs.map +1 -1
  170. package/cjs/tree-walker/TreeWalker.d.ts +2 -1
  171. package/cjs/tree-walker/TreeWalker.d.ts.map +1 -1
  172. package/cjs/utilities/ClassMethodBinder.cjs.map +1 -0
  173. package/cjs/utilities/ClassMethodBinder.d.ts.map +1 -0
  174. package/cjs/utilities/StringUtility.cjs.map +1 -0
  175. package/cjs/utilities/StringUtility.d.ts.map +1 -0
  176. package/cjs/utilities/XMLEncodeUtility.cjs +119 -0
  177. package/cjs/utilities/XMLEncodeUtility.cjs.map +1 -0
  178. package/cjs/utilities/XMLEncodeUtility.d.ts +48 -0
  179. package/cjs/utilities/XMLEncodeUtility.d.ts.map +1 -0
  180. package/cjs/window/BrowserWindow.cjs +9 -3
  181. package/cjs/window/BrowserWindow.cjs.map +1 -1
  182. package/cjs/window/BrowserWindow.d.ts +2 -0
  183. package/cjs/window/BrowserWindow.d.ts.map +1 -1
  184. package/cjs/window/WindowErrorUtility.cjs +1 -1
  185. package/cjs/window/WindowErrorUtility.cjs.map +1 -1
  186. package/cjs/xml-http-request/XMLHttpRequest.cjs +2 -1
  187. package/cjs/xml-http-request/XMLHttpRequest.cjs.map +1 -1
  188. package/cjs/xml-http-request/XMLHttpRequest.d.ts.map +1 -1
  189. package/cjs/xml-http-request/XMLHttpRequestResponseDataParser.cjs +1 -1
  190. package/cjs/xml-http-request/XMLHttpRequestResponseDataParser.cjs.map +1 -1
  191. package/cjs/xml-parser/XMLParser.cjs +531 -242
  192. package/cjs/xml-parser/XMLParser.cjs.map +1 -1
  193. package/cjs/xml-parser/XMLParser.d.ts +89 -19
  194. package/cjs/xml-parser/XMLParser.d.ts.map +1 -1
  195. package/cjs/xml-serializer/XMLSerializer.cjs +136 -40
  196. package/cjs/xml-serializer/XMLSerializer.cjs.map +1 -1
  197. package/cjs/xml-serializer/XMLSerializer.d.ts +6 -17
  198. package/cjs/xml-serializer/XMLSerializer.d.ts.map +1 -1
  199. package/lib/PropertySymbol.d.ts +4 -1
  200. package/lib/PropertySymbol.d.ts.map +1 -1
  201. package/lib/PropertySymbol.js +4 -1
  202. package/lib/PropertySymbol.js.map +1 -1
  203. package/lib/config/HTMLElementConfig.d.ts +7 -0
  204. package/lib/config/HTMLElementConfig.d.ts.map +1 -1
  205. package/lib/config/HTMLElementConfig.js +42 -16
  206. package/lib/config/HTMLElementConfig.js.map +1 -1
  207. package/lib/config/HTMLElementConfigContentModelEnum.d.ts +3 -0
  208. package/lib/config/HTMLElementConfigContentModelEnum.d.ts.map +1 -1
  209. package/lib/config/HTMLElementConfigContentModelEnum.js +3 -0
  210. package/lib/config/HTMLElementConfigContentModelEnum.js.map +1 -1
  211. package/lib/config/NamespaceURI.d.ts +2 -0
  212. package/lib/config/NamespaceURI.d.ts.map +1 -1
  213. package/lib/config/NamespaceURI.js +2 -0
  214. package/lib/config/NamespaceURI.js.map +1 -1
  215. package/lib/css/declaration/CSSStyleDeclaration.d.ts.map +1 -1
  216. package/lib/css/declaration/CSSStyleDeclaration.js +1 -1
  217. package/lib/css/declaration/CSSStyleDeclaration.js.map +1 -1
  218. package/lib/css/declaration/computed-style/CSSStyleDeclarationComputedStyle.d.ts.map +1 -1
  219. package/lib/css/declaration/computed-style/CSSStyleDeclarationComputedStyle.js +2 -2
  220. package/lib/css/declaration/computed-style/CSSStyleDeclarationComputedStyle.js.map +1 -1
  221. package/lib/custom-element/CustomElementReactionStack.d.ts +27 -0
  222. package/lib/custom-element/CustomElementReactionStack.d.ts.map +1 -0
  223. package/lib/custom-element/CustomElementReactionStack.js +71 -0
  224. package/lib/custom-element/CustomElementReactionStack.js.map +1 -0
  225. package/lib/custom-element/CustomElementRegistry.d.ts +2 -6
  226. package/lib/custom-element/CustomElementRegistry.d.ts.map +1 -1
  227. package/lib/custom-element/CustomElementRegistry.js +32 -45
  228. package/lib/custom-element/CustomElementRegistry.js.map +1 -1
  229. package/lib/custom-element/CustomElementUtility.d.ts +14 -0
  230. package/lib/custom-element/CustomElementUtility.d.ts.map +1 -0
  231. package/lib/custom-element/CustomElementUtility.js +32 -0
  232. package/lib/custom-element/CustomElementUtility.js.map +1 -0
  233. package/lib/custom-element/ICustomElementDefinition.d.ts +12 -0
  234. package/lib/custom-element/ICustomElementDefinition.d.ts.map +1 -0
  235. package/lib/custom-element/ICustomElementDefinition.js +2 -0
  236. package/lib/custom-element/ICustomElementDefinition.js.map +1 -0
  237. package/lib/dom/DOMStringMap.d.ts.map +1 -1
  238. package/lib/dom/DOMStringMap.js +8 -8
  239. package/lib/dom/DOMStringMap.js.map +1 -1
  240. package/lib/dom/DOMTokenList.js +1 -1
  241. package/lib/dom/DOMTokenList.js.map +1 -1
  242. package/lib/dom-parser/DOMParser.d.ts +0 -1
  243. package/lib/dom-parser/DOMParser.d.ts.map +1 -1
  244. package/lib/dom-parser/DOMParser.js +5 -67
  245. package/lib/dom-parser/DOMParser.js.map +1 -1
  246. package/lib/exception/DOMExceptionNameEnum.d.ts +2 -1
  247. package/lib/exception/DOMExceptionNameEnum.d.ts.map +1 -1
  248. package/lib/exception/DOMExceptionNameEnum.js +1 -0
  249. package/lib/exception/DOMExceptionNameEnum.js.map +1 -1
  250. package/lib/history/History.js +6 -6
  251. package/lib/history/History.js.map +1 -1
  252. package/lib/html-parser/HTMLParser.d.ts +91 -0
  253. package/lib/html-parser/HTMLParser.d.ts.map +1 -0
  254. package/lib/html-parser/HTMLParser.js +697 -0
  255. package/lib/html-parser/HTMLParser.js.map +1 -0
  256. package/lib/html-serializer/HTMLSerializer.d.ts +36 -0
  257. package/lib/html-serializer/HTMLSerializer.d.ts.map +1 -0
  258. package/lib/html-serializer/HTMLSerializer.js +123 -0
  259. package/lib/html-serializer/HTMLSerializer.js.map +1 -0
  260. package/lib/nodes/document/Document.d.ts +8 -0
  261. package/lib/nodes/document/Document.d.ts.map +1 -1
  262. package/lib/nodes/document/Document.js +106 -122
  263. package/lib/nodes/document/Document.js.map +1 -1
  264. package/lib/nodes/element/Element.d.ts +2 -12
  265. package/lib/nodes/element/Element.d.ts.map +1 -1
  266. package/lib/nodes/element/Element.js +35 -53
  267. package/lib/nodes/element/Element.js.map +1 -1
  268. package/lib/nodes/element/HTMLCollection.d.ts.map +1 -1
  269. package/lib/nodes/element/HTMLCollection.js +5 -9
  270. package/lib/nodes/element/HTMLCollection.js.map +1 -1
  271. package/lib/nodes/element/NamedNodeMap.d.ts +1 -16
  272. package/lib/nodes/element/NamedNodeMap.d.ts.map +1 -1
  273. package/lib/nodes/element/NamedNodeMap.js +39 -52
  274. package/lib/nodes/element/NamedNodeMap.js.map +1 -1
  275. package/lib/nodes/element/NamedNodeMapProxyFactory.d.ts.map +1 -1
  276. package/lib/nodes/element/NamedNodeMapProxyFactory.js +12 -14
  277. package/lib/nodes/element/NamedNodeMapProxyFactory.js.map +1 -1
  278. package/lib/nodes/html-button-element/HTMLButtonElement.d.ts.map +1 -1
  279. package/lib/nodes/html-button-element/HTMLButtonElement.js +1 -1
  280. package/lib/nodes/html-button-element/HTMLButtonElement.js.map +1 -1
  281. package/lib/nodes/html-document/HTMLDocument.d.ts +10 -0
  282. package/lib/nodes/html-document/HTMLDocument.d.ts.map +1 -1
  283. package/lib/nodes/html-document/HTMLDocument.js +33 -2
  284. package/lib/nodes/html-document/HTMLDocument.js.map +1 -1
  285. package/lib/nodes/html-element/HTMLElement.d.ts +34 -0
  286. package/lib/nodes/html-element/HTMLElement.d.ts.map +1 -1
  287. package/lib/nodes/html-element/HTMLElement.js +52 -22
  288. package/lib/nodes/html-element/HTMLElement.js.map +1 -1
  289. package/lib/nodes/html-field-set-element/HTMLFieldSetElement.d.ts.map +1 -1
  290. package/lib/nodes/html-field-set-element/HTMLFieldSetElement.js +1 -1
  291. package/lib/nodes/html-field-set-element/HTMLFieldSetElement.js.map +1 -1
  292. package/lib/nodes/html-form-element/HTMLFormElement.d.ts.map +1 -1
  293. package/lib/nodes/html-form-element/HTMLFormElement.js +5 -8
  294. package/lib/nodes/html-form-element/HTMLFormElement.js.map +1 -1
  295. package/lib/nodes/html-iframe-element/HTMLIFrameElement.js +1 -1
  296. package/lib/nodes/html-iframe-element/HTMLIFrameElement.js.map +1 -1
  297. package/lib/nodes/html-input-element/HTMLInputElement.d.ts.map +1 -1
  298. package/lib/nodes/html-input-element/HTMLInputElement.js +1 -1
  299. package/lib/nodes/html-input-element/HTMLInputElement.js.map +1 -1
  300. package/lib/nodes/html-media-element/TextTrackList.js +1 -1
  301. package/lib/nodes/html-media-element/TextTrackList.js.map +1 -1
  302. package/lib/nodes/html-object-element/HTMLObjectElement.d.ts.map +1 -1
  303. package/lib/nodes/html-object-element/HTMLObjectElement.js +1 -1
  304. package/lib/nodes/html-object-element/HTMLObjectElement.js.map +1 -1
  305. package/lib/nodes/html-output-element/HTMLOutputElement.d.ts.map +1 -1
  306. package/lib/nodes/html-output-element/HTMLOutputElement.js +1 -1
  307. package/lib/nodes/html-output-element/HTMLOutputElement.js.map +1 -1
  308. package/lib/nodes/html-script-element/HTMLScriptElement.d.ts.map +1 -1
  309. package/lib/nodes/html-script-element/HTMLScriptElement.js +3 -1
  310. package/lib/nodes/html-script-element/HTMLScriptElement.js.map +1 -1
  311. package/lib/nodes/html-select-element/HTMLSelectElement.d.ts.map +1 -1
  312. package/lib/nodes/html-select-element/HTMLSelectElement.js +2 -2
  313. package/lib/nodes/html-select-element/HTMLSelectElement.js.map +1 -1
  314. package/lib/nodes/html-table-element/HTMLTableElement.d.ts.map +1 -1
  315. package/lib/nodes/html-table-element/HTMLTableElement.js +9 -1
  316. package/lib/nodes/html-table-element/HTMLTableElement.js.map +1 -1
  317. package/lib/nodes/html-table-row-element/HTMLTableRowElement.js +1 -1
  318. package/lib/nodes/html-template-element/HTMLTemplateElement.d.ts +2 -2
  319. package/lib/nodes/html-template-element/HTMLTemplateElement.d.ts.map +1 -1
  320. package/lib/nodes/html-template-element/HTMLTemplateElement.js +15 -17
  321. package/lib/nodes/html-template-element/HTMLTemplateElement.js.map +1 -1
  322. package/lib/nodes/html-text-area-element/HTMLTextAreaElement.d.ts.map +1 -1
  323. package/lib/nodes/html-text-area-element/HTMLTextAreaElement.js +1 -1
  324. package/lib/nodes/html-text-area-element/HTMLTextAreaElement.js.map +1 -1
  325. package/lib/nodes/node/Node.d.ts +2 -10
  326. package/lib/nodes/node/Node.d.ts.map +1 -1
  327. package/lib/nodes/node/Node.js +44 -48
  328. package/lib/nodes/node/Node.js.map +1 -1
  329. package/lib/nodes/node/NodeList.js +1 -1
  330. package/lib/nodes/node/NodeList.js.map +1 -1
  331. package/lib/nodes/node/NodeUtility.d.ts.map +1 -1
  332. package/lib/nodes/node/NodeUtility.js +4 -3
  333. package/lib/nodes/node/NodeUtility.js.map +1 -1
  334. package/lib/nodes/parent-node/ParentNodeUtility.d.ts.map +1 -1
  335. package/lib/nodes/parent-node/ParentNodeUtility.js +5 -2
  336. package/lib/nodes/parent-node/ParentNodeUtility.js.map +1 -1
  337. package/lib/nodes/shadow-root/ShadowRoot.d.ts.map +1 -1
  338. package/lib/nodes/shadow-root/ShadowRoot.js +8 -8
  339. package/lib/nodes/shadow-root/ShadowRoot.js.map +1 -1
  340. package/lib/nodes/xml-document/XMLDocument.d.ts +2 -0
  341. package/lib/nodes/xml-document/XMLDocument.d.ts.map +1 -1
  342. package/lib/nodes/xml-document/XMLDocument.js +3 -0
  343. package/lib/nodes/xml-document/XMLDocument.js.map +1 -1
  344. package/lib/query-selector/SelectorItem.d.ts.map +1 -1
  345. package/lib/query-selector/SelectorItem.js +1 -2
  346. package/lib/query-selector/SelectorItem.js.map +1 -1
  347. package/lib/range/Range.d.ts.map +1 -1
  348. package/lib/range/Range.js +3 -3
  349. package/lib/range/Range.js.map +1 -1
  350. package/lib/storage/Storage.js +1 -1
  351. package/lib/storage/Storage.js.map +1 -1
  352. package/lib/svg/SVGLengthList.js +1 -1
  353. package/lib/svg/SVGLengthList.js.map +1 -1
  354. package/lib/svg/SVGNumberList.js +1 -1
  355. package/lib/svg/SVGNumberList.js.map +1 -1
  356. package/lib/svg/SVGPointList.js +1 -1
  357. package/lib/svg/SVGPointList.js.map +1 -1
  358. package/lib/svg/SVGStringList.js +1 -1
  359. package/lib/svg/SVGStringList.js.map +1 -1
  360. package/lib/svg/SVGTransformList.js +1 -1
  361. package/lib/svg/SVGTransformList.js.map +1 -1
  362. package/lib/tree-walker/NodeIterator.d.ts +18 -3
  363. package/lib/tree-walker/NodeIterator.d.ts.map +1 -1
  364. package/lib/tree-walker/NodeIterator.js +40 -6
  365. package/lib/tree-walker/NodeIterator.js.map +1 -1
  366. package/lib/tree-walker/TreeWalker.d.ts +2 -1
  367. package/lib/tree-walker/TreeWalker.d.ts.map +1 -1
  368. package/lib/tree-walker/TreeWalker.js +6 -6
  369. package/lib/tree-walker/TreeWalker.js.map +1 -1
  370. package/lib/utilities/ClassMethodBinder.d.ts.map +1 -0
  371. package/lib/utilities/ClassMethodBinder.js.map +1 -0
  372. package/lib/utilities/StringUtility.d.ts.map +1 -0
  373. package/lib/utilities/StringUtility.js.map +1 -0
  374. package/lib/utilities/XMLEncodeUtility.d.ts +48 -0
  375. package/lib/utilities/XMLEncodeUtility.d.ts.map +1 -0
  376. package/lib/utilities/XMLEncodeUtility.js +116 -0
  377. package/lib/utilities/XMLEncodeUtility.js.map +1 -0
  378. package/lib/window/BrowserWindow.d.ts +2 -0
  379. package/lib/window/BrowserWindow.d.ts.map +1 -1
  380. package/lib/window/BrowserWindow.js +9 -3
  381. package/lib/window/BrowserWindow.js.map +1 -1
  382. package/lib/window/WindowErrorUtility.js +1 -1
  383. package/lib/window/WindowErrorUtility.js.map +1 -1
  384. package/lib/xml-http-request/XMLHttpRequest.d.ts.map +1 -1
  385. package/lib/xml-http-request/XMLHttpRequest.js +2 -1
  386. package/lib/xml-http-request/XMLHttpRequest.js.map +1 -1
  387. package/lib/xml-http-request/XMLHttpRequestResponseDataParser.js +1 -1
  388. package/lib/xml-http-request/XMLHttpRequestResponseDataParser.js.map +1 -1
  389. package/lib/xml-parser/XMLParser.d.ts +89 -19
  390. package/lib/xml-parser/XMLParser.d.ts.map +1 -1
  391. package/lib/xml-parser/XMLParser.js +531 -242
  392. package/lib/xml-parser/XMLParser.js.map +1 -1
  393. package/lib/xml-serializer/XMLSerializer.d.ts +6 -17
  394. package/lib/xml-serializer/XMLSerializer.d.ts.map +1 -1
  395. package/lib/xml-serializer/XMLSerializer.js +136 -40
  396. package/lib/xml-serializer/XMLSerializer.js.map +1 -1
  397. package/package.json +1 -2
  398. package/src/PropertySymbol.ts +4 -1
  399. package/src/config/HTMLElementConfig.ts +53 -17
  400. package/src/config/HTMLElementConfigContentModelEnum.ts +3 -0
  401. package/src/config/NamespaceURI.ts +2 -0
  402. package/src/css/declaration/CSSStyleDeclaration.ts +1 -4
  403. package/src/css/declaration/computed-style/CSSStyleDeclarationComputedStyle.ts +2 -4
  404. package/src/custom-element/CustomElementReactionStack.ts +81 -0
  405. package/src/custom-element/CustomElementRegistry.ts +35 -54
  406. package/src/custom-element/CustomElementUtility.ts +34 -0
  407. package/src/custom-element/ICustomElementDefinition.ts +16 -0
  408. package/src/dom/DOMStringMap.ts +12 -10
  409. package/src/dom/DOMTokenList.ts +1 -1
  410. package/src/dom-parser/DOMParser.ts +5 -75
  411. package/src/exception/DOMExceptionNameEnum.ts +2 -1
  412. package/src/history/History.ts +6 -6
  413. package/src/html-parser/HTMLParser.ts +864 -0
  414. package/src/html-serializer/HTMLSerializer.ts +162 -0
  415. package/src/nodes/document/Document.ts +118 -137
  416. package/src/nodes/element/Element.ts +48 -95
  417. package/src/nodes/element/HTMLCollection.ts +5 -30
  418. package/src/nodes/element/NamedNodeMap.ts +58 -72
  419. package/src/nodes/element/NamedNodeMapProxyFactory.ts +12 -15
  420. package/src/nodes/html-button-element/HTMLButtonElement.ts +1 -4
  421. package/src/nodes/html-document/HTMLDocument.ts +58 -2
  422. package/src/nodes/html-element/HTMLElement.ts +107 -25
  423. package/src/nodes/html-field-set-element/HTMLFieldSetElement.ts +1 -4
  424. package/src/nodes/html-form-element/HTMLFormElement.ts +5 -27
  425. package/src/nodes/html-iframe-element/HTMLIFrameElement.ts +1 -1
  426. package/src/nodes/html-input-element/HTMLInputElement.ts +1 -4
  427. package/src/nodes/html-media-element/TextTrackList.ts +1 -1
  428. package/src/nodes/html-object-element/HTMLObjectElement.ts +1 -4
  429. package/src/nodes/html-output-element/HTMLOutputElement.ts +1 -4
  430. package/src/nodes/html-script-element/HTMLScriptElement.ts +4 -1
  431. package/src/nodes/html-select-element/HTMLSelectElement.ts +2 -5
  432. package/src/nodes/html-table-element/HTMLTableElement.ts +8 -1
  433. package/src/nodes/html-table-row-element/HTMLTableRowElement.ts +1 -1
  434. package/src/nodes/html-template-element/HTMLTemplateElement.ts +23 -17
  435. package/src/nodes/html-text-area-element/HTMLTextAreaElement.ts +1 -4
  436. package/src/nodes/node/Node.ts +57 -70
  437. package/src/nodes/node/NodeList.ts +1 -1
  438. package/src/nodes/node/NodeUtility.ts +4 -3
  439. package/src/nodes/parent-node/ParentNodeUtility.ts +6 -6
  440. package/src/nodes/shadow-root/ShadowRoot.ts +8 -8
  441. package/src/nodes/xml-document/XMLDocument.ts +5 -1
  442. package/src/query-selector/SelectorItem.ts +1 -2
  443. package/src/range/Range.ts +3 -3
  444. package/src/storage/Storage.ts +1 -1
  445. package/src/svg/SVGLengthList.ts +1 -1
  446. package/src/svg/SVGNumberList.ts +1 -1
  447. package/src/svg/SVGPointList.ts +1 -1
  448. package/src/svg/SVGStringList.ts +1 -1
  449. package/src/svg/SVGTransformList.ts +1 -1
  450. package/src/tree-walker/NodeIterator.ts +44 -8
  451. package/src/tree-walker/TreeWalker.ts +6 -6
  452. package/src/utilities/XMLEncodeUtility.ts +127 -0
  453. package/src/window/BrowserWindow.ts +18 -5
  454. package/src/window/WindowErrorUtility.ts +1 -1
  455. package/src/xml-http-request/XMLHttpRequest.ts +3 -1
  456. package/src/xml-http-request/XMLHttpRequestResponseDataParser.ts +1 -1
  457. package/src/xml-parser/XMLParser.ts +627 -313
  458. package/src/xml-serializer/XMLSerializer.ts +204 -58
  459. package/cjs/ClassMethodBinder.cjs.map +0 -1
  460. package/cjs/ClassMethodBinder.d.ts.map +0 -1
  461. package/cjs/StringUtility.cjs.map +0 -1
  462. package/cjs/StringUtility.d.ts.map +0 -1
  463. package/lib/ClassMethodBinder.d.ts.map +0 -1
  464. package/lib/ClassMethodBinder.js.map +0 -1
  465. package/lib/StringUtility.d.ts.map +0 -1
  466. package/lib/StringUtility.js.map +0 -1
  467. /package/cjs/{ClassMethodBinder.cjs → utilities/ClassMethodBinder.cjs} +0 -0
  468. /package/cjs/{ClassMethodBinder.d.ts → utilities/ClassMethodBinder.d.ts} +0 -0
  469. /package/cjs/{StringUtility.cjs → utilities/StringUtility.cjs} +0 -0
  470. /package/cjs/{StringUtility.d.ts → utilities/StringUtility.d.ts} +0 -0
  471. /package/lib/{ClassMethodBinder.d.ts → utilities/ClassMethodBinder.d.ts} +0 -0
  472. /package/lib/{ClassMethodBinder.js → utilities/ClassMethodBinder.js} +0 -0
  473. /package/lib/{StringUtility.d.ts → utilities/StringUtility.d.ts} +0 -0
  474. /package/lib/{StringUtility.js → utilities/StringUtility.js} +0 -0
  475. /package/src/{ClassMethodBinder.ts → utilities/ClassMethodBinder.ts} +0 -0
  476. /package/src/{StringUtility.ts → utilities/StringUtility.ts} +0 -0
@@ -24,7 +24,6 @@ import HTMLFormElement from '../html-form-element/HTMLFormElement.js';
24
24
  import HTMLSelectElement from '../html-select-element/HTMLSelectElement.js';
25
25
  import HTMLTextAreaElement from '../html-text-area-element/HTMLTextAreaElement.js';
26
26
  import HTMLSlotElement from '../html-slot-element/HTMLSlotElement.js';
27
- import WindowBrowserContext from '../../window/WindowBrowserContext.js';
28
27
  import NodeFactory from '../NodeFactory.js';
29
28
  import SVGStyleElement from '../svg-style-element/SVGStyleElement.js';
30
29
 
@@ -315,16 +314,6 @@ export default class Node extends EventTarget {
315
314
  return this[PropertySymbol.window].location.href;
316
315
  }
317
316
 
318
- /**
319
- * Connected callback.
320
- */
321
- public connectedCallback?(): void;
322
-
323
- /**
324
- * Disconnected callback.
325
- */
326
- public disconnectedCallback?(): void;
327
-
328
317
  /**
329
318
  * Returns "true" if the node has child nodes.
330
319
  *
@@ -603,18 +592,31 @@ export default class Node extends EventTarget {
603
592
  *
604
593
  * @param newNode Node to insert.
605
594
  * @param referenceNode Node to insert before.
595
+ * @param [disableValidations=false] "true" to disable validations.
606
596
  * @returns Inserted node.
607
597
  */
608
- public [PropertySymbol.insertBefore](newNode: Node, referenceNode: Node | null): Node {
598
+ public [PropertySymbol.insertBefore](
599
+ newNode: Node,
600
+ referenceNode: Node | null,
601
+ disableValidations = false
602
+ ): Node {
609
603
  if (newNode === referenceNode) {
610
604
  return newNode;
611
605
  }
612
606
 
613
- if (NodeUtility.isInclusiveAncestor(newNode, this, true)) {
614
- throw new this[PropertySymbol.window].DOMException(
615
- "Failed to execute 'insertBefore' on 'Node': The new node is a parent of the node to insert to.",
616
- DOMExceptionNameEnum.domException
617
- );
607
+ if (!disableValidations) {
608
+ if (newNode === this) {
609
+ throw new this[PropertySymbol.window].DOMException(
610
+ "Failed to execute 'insertBefore' on 'Node': Not possible to insert a node as a child of itself."
611
+ );
612
+ }
613
+
614
+ if (NodeUtility.isInclusiveAncestor(newNode, this, true)) {
615
+ throw new this[PropertySymbol.window].DOMException(
616
+ "Failed to execute 'insertBefore' on 'Node': The new node is a parent of the node to insert to.",
617
+ DOMExceptionNameEnum.domException
618
+ );
619
+ }
618
620
  }
619
621
 
620
622
  // If the type is DocumentFragment, then the child nodes of if it should be moved instead of the actual node.
@@ -622,7 +624,7 @@ export default class Node extends EventTarget {
622
624
  if (newNode[PropertySymbol.nodeType] === NodeTypeEnum.documentFragmentNode) {
623
625
  const childNodes = (<Node>newNode)[PropertySymbol.nodeArray];
624
626
  while (childNodes.length > 0) {
625
- this.insertBefore(childNodes[0], referenceNode);
627
+ this[PropertySymbol.insertBefore](childNodes[0], referenceNode, true);
626
628
  }
627
629
  return newNode;
628
630
  }
@@ -630,7 +632,7 @@ export default class Node extends EventTarget {
630
632
  // If the referenceNode is null or undefined, then the newNode should be appended to the ancestorNode.
631
633
  // According to spec only null is valid, but browsers support undefined as well.
632
634
  if (!referenceNode) {
633
- this.appendChild(newNode);
635
+ this[PropertySymbol.appendChild](newNode, true);
634
636
  return newNode;
635
637
  }
636
638
 
@@ -907,8 +909,26 @@ export default class Node extends EventTarget {
907
909
  public [PropertySymbol.connectedToNode](): void {
908
910
  const parentNode = this[PropertySymbol.parentNode];
909
911
  const parent = parentNode || this[PropertySymbol.host];
912
+ let isConnected = false;
913
+ let isDisconnected = false;
914
+
915
+ if (!this[PropertySymbol.isConnected] && parent[PropertySymbol.isConnected]) {
916
+ this[PropertySymbol.isConnected] = true;
917
+ isConnected = true;
918
+ } else if (this[PropertySymbol.isConnected] && !parent[PropertySymbol.isConnected]) {
919
+ this[PropertySymbol.isConnected] = false;
920
+ isDisconnected = true;
921
+ }
922
+
923
+ this[PropertySymbol.ownerDocument] = parent[PropertySymbol.ownerDocument] || <Document>parent;
924
+ this[PropertySymbol.window] =
925
+ parent[PropertySymbol.window] || parent[PropertySymbol.defaultView];
910
926
 
911
927
  if (parentNode) {
928
+ if (this[PropertySymbol.nodeType] !== NodeTypeEnum.documentFragmentNode) {
929
+ this[PropertySymbol.rootNode] = parentNode[PropertySymbol.rootNode];
930
+ }
931
+
912
932
  if (parentNode[PropertySymbol.styleNode] && this[PropertySymbol.tagName] !== 'STYLE') {
913
933
  this[PropertySymbol.styleNode] = parentNode[PropertySymbol.styleNode];
914
934
  }
@@ -926,14 +946,9 @@ export default class Node extends EventTarget {
926
946
  }
927
947
  }
928
948
 
929
- if (!this[PropertySymbol.isConnected] && parent[PropertySymbol.isConnected]) {
930
- this[PropertySymbol.connectedToDocument]();
931
- } else if (this[PropertySymbol.isConnected] && !parent[PropertySymbol.isConnected]) {
932
- this[PropertySymbol.disconnectedFromDocument]();
933
- }
934
-
935
949
  const childNodes = this[PropertySymbol.nodeArray];
936
950
  for (let i = 0, max = childNodes.length; i < max; i++) {
951
+ childNodes[i][PropertySymbol.parentNode] = this;
937
952
  childNodes[i][PropertySymbol.connectedToNode]();
938
953
  }
939
954
 
@@ -942,14 +957,20 @@ export default class Node extends EventTarget {
942
957
  // eslint-disable-next-line
943
958
  (<any>this)[PropertySymbol.shadowRoot][PropertySymbol.connectedToNode]();
944
959
  }
960
+
961
+ if (isConnected) {
962
+ this[PropertySymbol.connectedToDocument]();
963
+ } else if (isDisconnected) {
964
+ this[PropertySymbol.disconnectedFromDocument]();
965
+ }
945
966
  }
946
967
 
947
968
  /**
948
969
  * Called when disconnected from a node.
949
970
  */
950
971
  public [PropertySymbol.disconnectedFromNode](): void {
951
- if (this[PropertySymbol.isConnected]) {
952
- this[PropertySymbol.disconnectedFromDocument]();
972
+ if (this[PropertySymbol.nodeType] !== NodeTypeEnum.documentFragmentNode) {
973
+ this[PropertySymbol.rootNode] = null;
953
974
  }
954
975
 
955
976
  if (this[PropertySymbol.tagName] !== 'STYLE') {
@@ -968,9 +989,14 @@ export default class Node extends EventTarget {
968
989
  this[PropertySymbol.selectNode] = null;
969
990
  }
970
991
 
992
+ if (this[PropertySymbol.isConnected]) {
993
+ this[PropertySymbol.isConnected] = false;
994
+ this[PropertySymbol.disconnectedFromDocument]();
995
+ }
996
+
971
997
  const childNodes = this[PropertySymbol.nodeArray];
972
998
  for (let i = 0, max = childNodes.length; i < max; i++) {
973
- childNodes[i][PropertySymbol.disconnectedFromNode]();
999
+ childNodes[i][PropertySymbol.connectedToNode]();
974
1000
  }
975
1001
 
976
1002
  // eslint-disable-next-line
@@ -984,52 +1010,17 @@ export default class Node extends EventTarget {
984
1010
  * Called when connected to document.
985
1011
  */
986
1012
  public [PropertySymbol.connectedToDocument](): void {
987
- this[PropertySymbol.isConnected] = true;
988
-
989
- if (this[PropertySymbol.nodeType] !== NodeTypeEnum.documentFragmentNode) {
990
- this[PropertySymbol.rootNode] = this[PropertySymbol.parentNode][PropertySymbol.rootNode];
991
- }
992
-
993
1013
  // eslint-disable-next-line
994
1014
  if ((<any>this)[PropertySymbol.shadowRoot]) {
995
1015
  // eslint-disable-next-line
996
1016
  (<any>this)[PropertySymbol.shadowRoot][PropertySymbol.connectedToDocument]();
997
1017
  }
998
-
999
- if (this.connectedCallback) {
1000
- const result = <void | Promise<void>>this.connectedCallback();
1001
-
1002
- /**
1003
- * It is common to import dependencies in the connectedCallback() method of web components.
1004
- * As Happy DOM doesn't have support for dynamic imports yet, this is a temporary solution to wait for imports in connectedCallback().
1005
- *
1006
- * @see https://github.com/capricorn86/happy-dom/issues/1442
1007
- */
1008
- if (result instanceof Promise) {
1009
- const asyncTaskManager = new WindowBrowserContext(
1010
- this[PropertySymbol.window]
1011
- ).getAsyncTaskManager();
1012
- if (asyncTaskManager) {
1013
- const taskID = asyncTaskManager.startTask();
1014
- result
1015
- .then(() => asyncTaskManager.endTask(taskID))
1016
- .catch(() => asyncTaskManager.endTask(taskID));
1017
- }
1018
- }
1019
- }
1020
1018
  }
1021
1019
 
1022
1020
  /**
1023
1021
  * Called when disconnected from document.
1024
- * @param e
1025
1022
  */
1026
1023
  public [PropertySymbol.disconnectedFromDocument](): void {
1027
- this[PropertySymbol.isConnected] = false;
1028
-
1029
- if (this[PropertySymbol.nodeType] !== NodeTypeEnum.documentFragmentNode) {
1030
- this[PropertySymbol.rootNode] = null;
1031
- }
1032
-
1033
1024
  if (this[PropertySymbol.ownerDocument][PropertySymbol.activeElement] === <unknown>this) {
1034
1025
  this[PropertySymbol.ownerDocument][PropertySymbol.clearCache]();
1035
1026
  this[PropertySymbol.ownerDocument][PropertySymbol.activeElement] = null;
@@ -1040,10 +1031,6 @@ export default class Node extends EventTarget {
1040
1031
  // eslint-disable-next-line
1041
1032
  (<any>this)[PropertySymbol.shadowRoot][PropertySymbol.disconnectedFromDocument]();
1042
1033
  }
1043
-
1044
- if (this.disconnectedCallback) {
1045
- this.disconnectedCallback();
1046
- }
1047
1034
  }
1048
1035
 
1049
1036
  /**
@@ -1095,13 +1082,13 @@ export default class Node extends EventTarget {
1095
1082
  /**
1096
1083
  * 5.2.1. For each attr in node2’s attribute list:
1097
1084
  */
1098
- for (const attr of Array.from(
1085
+ for (const attributes of Array.from(
1099
1086
  (<Element>node2)[PropertySymbol.attributes][PropertySymbol.namedItems].values()
1100
1087
  )) {
1101
1088
  /**
1102
1089
  * 5.2.1.1. If attr equals attr1, then return the result of adding DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC and DOCUMENT_POSITION_PRECEDING.
1103
1090
  */
1104
- if (NodeUtility.isEqualNode(<Attr>attr, attr1)) {
1091
+ if (NodeUtility.isEqualNode(attributes[0], attr1)) {
1105
1092
  return (
1106
1093
  Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC | Node.DOCUMENT_POSITION_PRECEDING
1107
1094
  );
@@ -1110,7 +1097,7 @@ export default class Node extends EventTarget {
1110
1097
  /**
1111
1098
  * 5.2.1.2. If attr equals attr2, then return the result of adding DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC and DOCUMENT_POSITION_FOLLOWING.
1112
1099
  */
1113
- if (NodeUtility.isEqualNode(<Attr>attr, attr2)) {
1100
+ if (NodeUtility.isEqualNode(attributes[0], attr2)) {
1114
1101
  return (
1115
1102
  Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC | Node.DOCUMENT_POSITION_FOLLOWING
1116
1103
  );
@@ -1,4 +1,4 @@
1
- import ClassMethodBinder from '../../ClassMethodBinder.js';
1
+ import ClassMethodBinder from '../../utilities/ClassMethodBinder.js';
2
2
  import * as PropertySymbol from '../../PropertySymbol.js';
3
3
  import Node from './Node.js';
4
4
 
@@ -209,9 +209,10 @@ export default class NodeUtility {
209
209
  let found = false;
210
210
  for (const attributeB of attributesB) {
211
211
  if (
212
- attributeA[PropertySymbol.namespaceURI] === attributeB[PropertySymbol.namespaceURI] &&
213
- attributeA.localName === attributeB.localName &&
214
- attributeA[PropertySymbol.value] === attributeB[PropertySymbol.value]
212
+ attributeA[0][PropertySymbol.namespaceURI] ===
213
+ attributeB[0][PropertySymbol.namespaceURI] &&
214
+ attributeA[0].localName === attributeB[0].localName &&
215
+ attributeA[0][PropertySymbol.value] === attributeB[0][PropertySymbol.value]
215
216
  ) {
216
217
  found = true;
217
218
  break;
@@ -161,7 +161,11 @@ export default class ParentNodeUtility {
161
161
  tagName: string
162
162
  ): HTMLCollection<Element> {
163
163
  // When the namespace is HTML, the tag name is case-insensitive.
164
- const formattedTagName = namespaceURI === NamespaceURI.html ? tagName.toUpperCase() : tagName;
164
+ const formattedTagName =
165
+ namespaceURI === NamespaceURI.html &&
166
+ parentNode[PropertySymbol.ownerDocument][PropertySymbol.contentType] === 'text/html'
167
+ ? tagName.toUpperCase()
168
+ : tagName;
165
169
  const includeAll = tagName === '*';
166
170
 
167
171
  const find = (
@@ -292,11 +296,7 @@ export default class ParentNodeUtility {
292
296
  for (const element of (<DocumentFragment>parent)[PropertySymbol.elementArray]) {
293
297
  element[PropertySymbol.affectsCache].push(cachedResult);
294
298
 
295
- if (
296
- element[PropertySymbol.attributes][PropertySymbol.namedItems].get('id')?.[
297
- PropertySymbol.value
298
- ] === id
299
- ) {
299
+ if (element.getAttribute('id') === id) {
300
300
  return <Element>element;
301
301
  }
302
302
 
@@ -1,13 +1,13 @@
1
1
  import DocumentFragment from '../document-fragment/DocumentFragment.js';
2
2
  import * as PropertySymbol from '../../PropertySymbol.js';
3
- import XMLParser from '../../xml-parser/XMLParser.js';
4
- import XMLSerializer from '../../xml-serializer/XMLSerializer.js';
5
3
  import Element from '../element/Element.js';
6
4
  import CSSStyleSheet from '../../css/CSSStyleSheet.js';
7
5
  import HTMLElement from '../../nodes/html-element/HTMLElement.js';
8
6
  import Event from '../../event/Event.js';
9
7
  import SVGElement from '../svg-element/SVGElement.js';
10
8
  import Document from '../document/Document.js';
9
+ import HTMLSerializer from '../../html-serializer/HTMLSerializer.js';
10
+ import HTMLParser from '../../html-parser/HTMLParser.js';
11
11
 
12
12
  /**
13
13
  * ShadowRoot.
@@ -119,12 +119,12 @@ export default class ShadowRoot extends DocumentFragment {
119
119
  * @returns HTML.
120
120
  */
121
121
  public get innerHTML(): string {
122
- const xmlSerializer = new XMLSerializer();
123
- let xml = '';
122
+ const serializer = new HTMLSerializer();
123
+ let html = '';
124
124
  for (const node of this[PropertySymbol.nodeArray]) {
125
- xml += xmlSerializer.serializeToString(node);
125
+ html += serializer.serializeToString(node);
126
126
  }
127
- return xml;
127
+ return html;
128
128
  }
129
129
 
130
130
  /**
@@ -139,7 +139,7 @@ export default class ShadowRoot extends DocumentFragment {
139
139
  this.removeChild(childNodes[0]);
140
140
  }
141
141
 
142
- XMLParser.parse(this[PropertySymbol.ownerDocument], html, { rootNode: this });
142
+ new HTMLParser(this[PropertySymbol.window]).parse(html, this);
143
143
  }
144
144
 
145
145
  /**
@@ -211,7 +211,7 @@ export default class ShadowRoot extends DocumentFragment {
211
211
  this.removeChild(childNodes[0]);
212
212
  }
213
213
 
214
- XMLParser.parse(this[PropertySymbol.ownerDocument], html, { rootNode: this });
214
+ new HTMLParser(this[PropertySymbol.window]).parse(html, this);
215
215
  }
216
216
 
217
217
  /**
@@ -1,6 +1,10 @@
1
1
  import Document from '../document/Document.js';
2
+ import * as PropertySymbol from '../../PropertySymbol.js';
2
3
 
3
4
  /**
4
5
  * Document.
5
6
  */
6
- export default class XMLDocument extends Document {}
7
+ export default class XMLDocument extends Document {
8
+ // Internal properties
9
+ public [PropertySymbol.contentType]: string = 'application/xml';
10
+ }
@@ -236,8 +236,7 @@ export default class SelectorItem {
236
236
  ? { priorityWeight: 10 }
237
237
  : null;
238
238
  case 'disabled':
239
- return 'disabled' in element &&
240
- element[PropertySymbol.attributes][PropertySymbol.namedItems].has('disabled')
239
+ return 'disabled' in element && element.hasAttribute('disabled')
241
240
  ? { priorityWeight: 10 }
242
241
  : null;
243
242
  case 'empty':
@@ -8,12 +8,12 @@ import DOMExceptionNameEnum from '../exception/DOMExceptionNameEnum.js';
8
8
  import RangeUtility from './RangeUtility.js';
9
9
  import NodeTypeEnum from '../nodes/node/NodeTypeEnum.js';
10
10
  import NodeUtility from '../nodes/node/NodeUtility.js';
11
- import XMLParser from '../xml-parser/XMLParser.js';
12
11
  import Comment from '../nodes/comment/Comment.js';
13
12
  import Text from '../nodes/text/Text.js';
14
13
  import DOMRectList from '../dom/DOMRectList.js';
15
14
  import IRangeBoundaryPoint from './IRangeBoundaryPoint.js';
16
15
  import BrowserWindow from '../window/BrowserWindow.js';
16
+ import HTMLParser from '../html-parser/HTMLParser.js';
17
17
 
18
18
  /**
19
19
  * Range.
@@ -433,8 +433,8 @@ export default class Range {
433
433
  * @returns Document fragment.
434
434
  */
435
435
  public createContextualFragment(tagString: string): DocumentFragment {
436
- // TODO: We only have support for HTML in the parser currently, so it is not necessary to check which context it is
437
- return <DocumentFragment>XMLParser.parse(this[PropertySymbol.ownerDocument], tagString);
436
+ // TODO: Implement support for checking which context to use
437
+ return <DocumentFragment>new HTMLParser(this[PropertySymbol.window]).parse(tagString);
438
438
  }
439
439
 
440
440
  /**
@@ -1,4 +1,4 @@
1
- import ClassMethodBinder from '../ClassMethodBinder.js';
1
+ import ClassMethodBinder from '../utilities/ClassMethodBinder.js';
2
2
  import * as PropertySymbol from '../PropertySymbol.js';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import ClassMethodBinder from '../ClassMethodBinder.js';
1
+ import ClassMethodBinder from '../utilities/ClassMethodBinder.js';
2
2
  import DOMExceptionNameEnum from '../exception/DOMExceptionNameEnum.js';
3
3
  import * as PropertySymbol from '../PropertySymbol.js';
4
4
  import BrowserWindow from '../window/BrowserWindow.js';
@@ -1,4 +1,4 @@
1
- import ClassMethodBinder from '../ClassMethodBinder.js';
1
+ import ClassMethodBinder from '../utilities/ClassMethodBinder.js';
2
2
  import DOMExceptionNameEnum from '../exception/DOMExceptionNameEnum.js';
3
3
  import * as PropertySymbol from '../PropertySymbol.js';
4
4
  import BrowserWindow from '../window/BrowserWindow.js';
@@ -1,4 +1,4 @@
1
- import ClassMethodBinder from '../ClassMethodBinder.js';
1
+ import ClassMethodBinder from '../utilities/ClassMethodBinder.js';
2
2
  import DOMExceptionNameEnum from '../exception/DOMExceptionNameEnum.js';
3
3
  import * as PropertySymbol from '../PropertySymbol.js';
4
4
  import BrowserWindow from '../window/BrowserWindow.js';
@@ -1,4 +1,4 @@
1
- import ClassMethodBinder from '../ClassMethodBinder.js';
1
+ import ClassMethodBinder from '../utilities/ClassMethodBinder.js';
2
2
  import DOMExceptionNameEnum from '../exception/DOMExceptionNameEnum.js';
3
3
  import * as PropertySymbol from '../PropertySymbol.js';
4
4
  import BrowserWindow from '../window/BrowserWindow.js';
@@ -1,4 +1,4 @@
1
- import ClassMethodBinder from '../ClassMethodBinder.js';
1
+ import ClassMethodBinder from '../utilities/ClassMethodBinder.js';
2
2
  import DOMExceptionNameEnum from '../exception/DOMExceptionNameEnum.js';
3
3
  import * as PropertySymbol from '../PropertySymbol.js';
4
4
  import BrowserWindow from '../window/BrowserWindow.js';
@@ -1,6 +1,8 @@
1
1
  import INodeFilter from './INodeFilter.js';
2
2
  import TreeWalker from './TreeWalker.js';
3
3
  import Node from '../nodes/node/Node.js';
4
+ import * as PropertySymbol from '../PropertySymbol.js';
5
+ import NodeFilter from './NodeFilter.js';
4
6
 
5
7
  /**
6
8
  * The NodeIterator object represents the nodes of a document subtree and a position within them.
@@ -9,11 +11,11 @@ import Node from '../nodes/node/Node.js';
9
11
  * https://developer.mozilla.org/en-US/docs/Web/API/NodeIterator
10
12
  */
11
13
  export default class NodeIterator {
12
- public root: Node = null;
13
- public whatToShow = -1;
14
- public filter: INodeFilter = null;
15
-
16
- readonly #walker: TreeWalker;
14
+ #root: Node = null;
15
+ #whatToShow = -1;
16
+ #filter: INodeFilter = null;
17
+ #walker: TreeWalker;
18
+ #atRoot = true;
17
19
 
18
20
  /**
19
21
  * Constructor.
@@ -23,18 +25,52 @@ export default class NodeIterator {
23
25
  * @param [filter] Filter.
24
26
  */
25
27
  constructor(root: Node, whatToShow = -1, filter: INodeFilter = null) {
26
- this.root = root;
27
- this.whatToShow = whatToShow;
28
- this.filter = filter;
28
+ this.#root = root;
29
+ this.#whatToShow = whatToShow;
30
+ this.#filter = filter;
29
31
  this.#walker = new TreeWalker(root, whatToShow, filter);
30
32
  }
31
33
 
34
+ /**
35
+ * Returns root.
36
+ *
37
+ * @returns Root.
38
+ */
39
+ public get root(): Node | null {
40
+ return this.#root;
41
+ }
42
+
43
+ /**
44
+ * Returns what to show.
45
+ *
46
+ * @returns What to show.
47
+ */
48
+ public get whatToShow(): number {
49
+ return this.#whatToShow;
50
+ }
51
+
52
+ /**
53
+ * Returns filter.
54
+ *
55
+ * @returns Filter.
56
+ */
57
+ public get filter(): INodeFilter {
58
+ return this.#filter;
59
+ }
60
+
32
61
  /**
33
62
  * Moves the current Node to the next visible node in the document order.
34
63
  *
35
64
  * @returns Current node.
36
65
  */
37
66
  public nextNode(): Node {
67
+ if (this.#atRoot) {
68
+ this.#atRoot = false;
69
+ if (this.#walker[PropertySymbol.filterNode](this.#root) !== NodeFilter.FILTER_ACCEPT) {
70
+ return this.#walker.nextNode();
71
+ }
72
+ return this.#root;
73
+ }
38
74
  return this.#walker.nextNode();
39
75
  }
40
76
 
@@ -69,7 +69,7 @@ export default class TreeWalker {
69
69
  ) {
70
70
  this.currentNode = this.currentNode[PropertySymbol.parentNode];
71
71
 
72
- if (this.filterNode(this.currentNode) === NodeFilter.FILTER_ACCEPT) {
72
+ if (this[PropertySymbol.filterNode](this.currentNode) === NodeFilter.FILTER_ACCEPT) {
73
73
  return this.currentNode;
74
74
  }
75
75
 
@@ -92,7 +92,7 @@ export default class TreeWalker {
92
92
  if (childNodes.length > 0) {
93
93
  this.currentNode = childNodes[0];
94
94
 
95
- if (this.filterNode(this.currentNode) === NodeFilter.FILTER_ACCEPT) {
95
+ if (this[PropertySymbol.filterNode](this.currentNode) === NodeFilter.FILTER_ACCEPT) {
96
96
  return this.currentNode;
97
97
  }
98
98
 
@@ -113,7 +113,7 @@ export default class TreeWalker {
113
113
  if (childNodes.length > 0) {
114
114
  this.currentNode = childNodes[childNodes.length - 1];
115
115
 
116
- if (this.filterNode(this.currentNode) === NodeFilter.FILTER_ACCEPT) {
116
+ if (this[PropertySymbol.filterNode](this.currentNode) === NodeFilter.FILTER_ACCEPT) {
117
117
  return this.currentNode;
118
118
  }
119
119
 
@@ -142,7 +142,7 @@ export default class TreeWalker {
142
142
  if (index > 0) {
143
143
  this.currentNode = siblings[index - 1];
144
144
 
145
- if (this.filterNode(this.currentNode) === NodeFilter.FILTER_ACCEPT) {
145
+ if (this[PropertySymbol.filterNode](this.currentNode) === NodeFilter.FILTER_ACCEPT) {
146
146
  return this.currentNode;
147
147
  }
148
148
 
@@ -172,7 +172,7 @@ export default class TreeWalker {
172
172
  if (index + 1 < siblings.length) {
173
173
  this.currentNode = siblings[index + 1];
174
174
 
175
- if (this.filterNode(this.currentNode) === NodeFilter.FILTER_ACCEPT) {
175
+ if (this[PropertySymbol.filterNode](this.currentNode) === NodeFilter.FILTER_ACCEPT) {
176
176
  return this.currentNode;
177
177
  }
178
178
 
@@ -192,7 +192,7 @@ export default class TreeWalker {
192
192
  * @param node Node.
193
193
  * @returns Child nodes.
194
194
  */
195
- private filterNode(node: Node): number {
195
+ public [PropertySymbol.filterNode](node: Node): number {
196
196
  const mask = NodeFilterMask[node.nodeType];
197
197
 
198
198
  if (mask && (this.whatToShow & mask) == 0) {