happy-dom 15.11.6 → 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 (489) 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/browser/utilities/BrowserFrameURL.cjs +1 -1
  6. package/cjs/browser/utilities/BrowserFrameURL.cjs.map +1 -1
  7. package/cjs/browser/utilities/BrowserFrameURL.d.ts +1 -1
  8. package/cjs/browser/utilities/BrowserFrameURL.d.ts.map +1 -1
  9. package/cjs/config/HTMLElementConfig.cjs +42 -16
  10. package/cjs/config/HTMLElementConfig.cjs.map +1 -1
  11. package/cjs/config/HTMLElementConfig.d.ts +7 -0
  12. package/cjs/config/HTMLElementConfig.d.ts.map +1 -1
  13. package/cjs/config/HTMLElementConfigContentModelEnum.cjs +3 -0
  14. package/cjs/config/HTMLElementConfigContentModelEnum.cjs.map +1 -1
  15. package/cjs/config/HTMLElementConfigContentModelEnum.d.ts +3 -0
  16. package/cjs/config/HTMLElementConfigContentModelEnum.d.ts.map +1 -1
  17. package/cjs/config/NamespaceURI.cjs +2 -0
  18. package/cjs/config/NamespaceURI.cjs.map +1 -1
  19. package/cjs/config/NamespaceURI.d.ts +2 -0
  20. package/cjs/config/NamespaceURI.d.ts.map +1 -1
  21. package/cjs/css/declaration/CSSStyleDeclaration.cjs +1 -1
  22. package/cjs/css/declaration/CSSStyleDeclaration.cjs.map +1 -1
  23. package/cjs/css/declaration/CSSStyleDeclaration.d.ts.map +1 -1
  24. package/cjs/css/declaration/computed-style/CSSStyleDeclarationComputedStyle.cjs +2 -2
  25. package/cjs/css/declaration/computed-style/CSSStyleDeclarationComputedStyle.cjs.map +1 -1
  26. package/cjs/css/declaration/computed-style/CSSStyleDeclarationComputedStyle.d.ts.map +1 -1
  27. package/cjs/custom-element/CustomElementReactionStack.cjs +100 -0
  28. package/cjs/custom-element/CustomElementReactionStack.cjs.map +1 -0
  29. package/cjs/custom-element/CustomElementReactionStack.d.ts +27 -0
  30. package/cjs/custom-element/CustomElementReactionStack.d.ts.map +1 -0
  31. package/cjs/custom-element/CustomElementRegistry.cjs +32 -45
  32. package/cjs/custom-element/CustomElementRegistry.cjs.map +1 -1
  33. package/cjs/custom-element/CustomElementRegistry.d.ts +2 -6
  34. package/cjs/custom-element/CustomElementRegistry.d.ts.map +1 -1
  35. package/cjs/custom-element/CustomElementUtility.cjs +35 -0
  36. package/cjs/custom-element/CustomElementUtility.cjs.map +1 -0
  37. package/cjs/custom-element/CustomElementUtility.d.ts +14 -0
  38. package/cjs/custom-element/CustomElementUtility.d.ts.map +1 -0
  39. package/cjs/custom-element/ICustomElementDefinition.cjs +3 -0
  40. package/cjs/custom-element/ICustomElementDefinition.cjs.map +1 -0
  41. package/cjs/custom-element/ICustomElementDefinition.d.ts +12 -0
  42. package/cjs/custom-element/ICustomElementDefinition.d.ts.map +1 -0
  43. package/cjs/dom/DOMStringMap.cjs +8 -8
  44. package/cjs/dom/DOMStringMap.cjs.map +1 -1
  45. package/cjs/dom/DOMStringMap.d.ts.map +1 -1
  46. package/cjs/dom/DOMTokenList.cjs +1 -1
  47. package/cjs/dom/DOMTokenList.cjs.map +1 -1
  48. package/cjs/dom-parser/DOMParser.cjs +5 -67
  49. package/cjs/dom-parser/DOMParser.cjs.map +1 -1
  50. package/cjs/dom-parser/DOMParser.d.ts +0 -1
  51. package/cjs/dom-parser/DOMParser.d.ts.map +1 -1
  52. package/cjs/exception/DOMExceptionNameEnum.cjs +1 -0
  53. package/cjs/exception/DOMExceptionNameEnum.cjs.map +1 -1
  54. package/cjs/exception/DOMExceptionNameEnum.d.ts +2 -1
  55. package/cjs/exception/DOMExceptionNameEnum.d.ts.map +1 -1
  56. package/cjs/history/History.cjs +8 -8
  57. package/cjs/history/History.cjs.map +1 -1
  58. package/cjs/history/History.d.ts +2 -2
  59. package/cjs/history/History.d.ts.map +1 -1
  60. package/cjs/html-parser/HTMLParser.cjs +726 -0
  61. package/cjs/html-parser/HTMLParser.cjs.map +1 -0
  62. package/cjs/html-parser/HTMLParser.d.ts +91 -0
  63. package/cjs/html-parser/HTMLParser.d.ts.map +1 -0
  64. package/cjs/html-serializer/HTMLSerializer.cjs +152 -0
  65. package/cjs/html-serializer/HTMLSerializer.cjs.map +1 -0
  66. package/cjs/html-serializer/HTMLSerializer.d.ts +36 -0
  67. package/cjs/html-serializer/HTMLSerializer.d.ts.map +1 -0
  68. package/cjs/nodes/document/Document.cjs +105 -121
  69. package/cjs/nodes/document/Document.cjs.map +1 -1
  70. package/cjs/nodes/document/Document.d.ts +8 -0
  71. package/cjs/nodes/document/Document.d.ts.map +1 -1
  72. package/cjs/nodes/element/Element.cjs +35 -53
  73. package/cjs/nodes/element/Element.cjs.map +1 -1
  74. package/cjs/nodes/element/Element.d.ts +2 -12
  75. package/cjs/nodes/element/Element.d.ts.map +1 -1
  76. package/cjs/nodes/element/HTMLCollection.cjs +5 -9
  77. package/cjs/nodes/element/HTMLCollection.cjs.map +1 -1
  78. package/cjs/nodes/element/HTMLCollection.d.ts.map +1 -1
  79. package/cjs/nodes/element/NamedNodeMap.cjs +39 -52
  80. package/cjs/nodes/element/NamedNodeMap.cjs.map +1 -1
  81. package/cjs/nodes/element/NamedNodeMap.d.ts +1 -16
  82. package/cjs/nodes/element/NamedNodeMap.d.ts.map +1 -1
  83. package/cjs/nodes/element/NamedNodeMapProxyFactory.cjs +12 -14
  84. package/cjs/nodes/element/NamedNodeMapProxyFactory.cjs.map +1 -1
  85. package/cjs/nodes/element/NamedNodeMapProxyFactory.d.ts.map +1 -1
  86. package/cjs/nodes/html-button-element/HTMLButtonElement.cjs +1 -1
  87. package/cjs/nodes/html-button-element/HTMLButtonElement.cjs.map +1 -1
  88. package/cjs/nodes/html-button-element/HTMLButtonElement.d.ts.map +1 -1
  89. package/cjs/nodes/html-document/HTMLDocument.cjs +33 -2
  90. package/cjs/nodes/html-document/HTMLDocument.cjs.map +1 -1
  91. package/cjs/nodes/html-document/HTMLDocument.d.ts +10 -0
  92. package/cjs/nodes/html-document/HTMLDocument.d.ts.map +1 -1
  93. package/cjs/nodes/html-element/HTMLElement.cjs +52 -22
  94. package/cjs/nodes/html-element/HTMLElement.cjs.map +1 -1
  95. package/cjs/nodes/html-element/HTMLElement.d.ts +34 -0
  96. package/cjs/nodes/html-element/HTMLElement.d.ts.map +1 -1
  97. package/cjs/nodes/html-field-set-element/HTMLFieldSetElement.cjs +1 -1
  98. package/cjs/nodes/html-field-set-element/HTMLFieldSetElement.cjs.map +1 -1
  99. package/cjs/nodes/html-field-set-element/HTMLFieldSetElement.d.ts.map +1 -1
  100. package/cjs/nodes/html-form-element/HTMLFormElement.cjs +5 -8
  101. package/cjs/nodes/html-form-element/HTMLFormElement.cjs.map +1 -1
  102. package/cjs/nodes/html-form-element/HTMLFormElement.d.ts.map +1 -1
  103. package/cjs/nodes/html-iframe-element/HTMLIFrameElement.cjs +1 -1
  104. package/cjs/nodes/html-iframe-element/HTMLIFrameElement.cjs.map +1 -1
  105. package/cjs/nodes/html-input-element/HTMLInputElement.cjs +1 -1
  106. package/cjs/nodes/html-input-element/HTMLInputElement.cjs.map +1 -1
  107. package/cjs/nodes/html-input-element/HTMLInputElement.d.ts.map +1 -1
  108. package/cjs/nodes/html-media-element/TextTrackList.cjs +1 -1
  109. package/cjs/nodes/html-media-element/TextTrackList.cjs.map +1 -1
  110. package/cjs/nodes/html-object-element/HTMLObjectElement.cjs +1 -1
  111. package/cjs/nodes/html-object-element/HTMLObjectElement.cjs.map +1 -1
  112. package/cjs/nodes/html-object-element/HTMLObjectElement.d.ts.map +1 -1
  113. package/cjs/nodes/html-output-element/HTMLOutputElement.cjs +1 -1
  114. package/cjs/nodes/html-output-element/HTMLOutputElement.cjs.map +1 -1
  115. package/cjs/nodes/html-output-element/HTMLOutputElement.d.ts.map +1 -1
  116. package/cjs/nodes/html-script-element/HTMLScriptElement.cjs +3 -1
  117. package/cjs/nodes/html-script-element/HTMLScriptElement.cjs.map +1 -1
  118. package/cjs/nodes/html-script-element/HTMLScriptElement.d.ts.map +1 -1
  119. package/cjs/nodes/html-select-element/HTMLSelectElement.cjs +2 -2
  120. package/cjs/nodes/html-select-element/HTMLSelectElement.cjs.map +1 -1
  121. package/cjs/nodes/html-select-element/HTMLSelectElement.d.ts.map +1 -1
  122. package/cjs/nodes/html-table-element/HTMLTableElement.cjs +9 -1
  123. package/cjs/nodes/html-table-element/HTMLTableElement.cjs.map +1 -1
  124. package/cjs/nodes/html-table-element/HTMLTableElement.d.ts.map +1 -1
  125. package/cjs/nodes/html-table-row-element/HTMLTableRowElement.cjs +1 -1
  126. package/cjs/nodes/html-template-element/HTMLTemplateElement.cjs +15 -17
  127. package/cjs/nodes/html-template-element/HTMLTemplateElement.cjs.map +1 -1
  128. package/cjs/nodes/html-template-element/HTMLTemplateElement.d.ts +2 -2
  129. package/cjs/nodes/html-template-element/HTMLTemplateElement.d.ts.map +1 -1
  130. package/cjs/nodes/html-text-area-element/HTMLTextAreaElement.cjs +1 -1
  131. package/cjs/nodes/html-text-area-element/HTMLTextAreaElement.cjs.map +1 -1
  132. package/cjs/nodes/html-text-area-element/HTMLTextAreaElement.d.ts.map +1 -1
  133. package/cjs/nodes/node/Node.cjs +44 -48
  134. package/cjs/nodes/node/Node.cjs.map +1 -1
  135. package/cjs/nodes/node/Node.d.ts +2 -10
  136. package/cjs/nodes/node/Node.d.ts.map +1 -1
  137. package/cjs/nodes/node/NodeList.cjs +1 -1
  138. package/cjs/nodes/node/NodeList.cjs.map +1 -1
  139. package/cjs/nodes/node/NodeUtility.cjs +4 -3
  140. package/cjs/nodes/node/NodeUtility.cjs.map +1 -1
  141. package/cjs/nodes/node/NodeUtility.d.ts.map +1 -1
  142. package/cjs/nodes/parent-node/ParentNodeUtility.cjs +5 -2
  143. package/cjs/nodes/parent-node/ParentNodeUtility.cjs.map +1 -1
  144. package/cjs/nodes/parent-node/ParentNodeUtility.d.ts.map +1 -1
  145. package/cjs/nodes/shadow-root/ShadowRoot.cjs +8 -8
  146. package/cjs/nodes/shadow-root/ShadowRoot.cjs.map +1 -1
  147. package/cjs/nodes/shadow-root/ShadowRoot.d.ts.map +1 -1
  148. package/cjs/nodes/xml-document/XMLDocument.cjs +26 -0
  149. package/cjs/nodes/xml-document/XMLDocument.cjs.map +1 -1
  150. package/cjs/nodes/xml-document/XMLDocument.d.ts +2 -0
  151. package/cjs/nodes/xml-document/XMLDocument.d.ts.map +1 -1
  152. package/cjs/query-selector/SelectorItem.cjs +1 -2
  153. package/cjs/query-selector/SelectorItem.cjs.map +1 -1
  154. package/cjs/query-selector/SelectorItem.d.ts.map +1 -1
  155. package/cjs/range/Range.cjs +3 -3
  156. package/cjs/range/Range.cjs.map +1 -1
  157. package/cjs/range/Range.d.ts.map +1 -1
  158. package/cjs/storage/Storage.cjs +1 -1
  159. package/cjs/storage/Storage.cjs.map +1 -1
  160. package/cjs/svg/SVGLengthList.cjs +1 -1
  161. package/cjs/svg/SVGLengthList.cjs.map +1 -1
  162. package/cjs/svg/SVGNumberList.cjs +1 -1
  163. package/cjs/svg/SVGNumberList.cjs.map +1 -1
  164. package/cjs/svg/SVGPointList.cjs +1 -1
  165. package/cjs/svg/SVGPointList.cjs.map +1 -1
  166. package/cjs/svg/SVGStringList.cjs +1 -1
  167. package/cjs/svg/SVGStringList.cjs.map +1 -1
  168. package/cjs/svg/SVGTransformList.cjs +1 -1
  169. package/cjs/svg/SVGTransformList.cjs.map +1 -1
  170. package/cjs/tree-walker/NodeIterator.cjs +63 -6
  171. package/cjs/tree-walker/NodeIterator.cjs.map +1 -1
  172. package/cjs/tree-walker/NodeIterator.d.ts +18 -3
  173. package/cjs/tree-walker/NodeIterator.d.ts.map +1 -1
  174. package/cjs/tree-walker/TreeWalker.cjs +6 -6
  175. package/cjs/tree-walker/TreeWalker.cjs.map +1 -1
  176. package/cjs/tree-walker/TreeWalker.d.ts +2 -1
  177. package/cjs/tree-walker/TreeWalker.d.ts.map +1 -1
  178. package/cjs/utilities/ClassMethodBinder.cjs.map +1 -0
  179. package/cjs/utilities/ClassMethodBinder.d.ts.map +1 -0
  180. package/cjs/utilities/StringUtility.cjs.map +1 -0
  181. package/cjs/utilities/StringUtility.d.ts.map +1 -0
  182. package/cjs/utilities/XMLEncodeUtility.cjs +119 -0
  183. package/cjs/utilities/XMLEncodeUtility.cjs.map +1 -0
  184. package/cjs/utilities/XMLEncodeUtility.d.ts +48 -0
  185. package/cjs/utilities/XMLEncodeUtility.d.ts.map +1 -0
  186. package/cjs/window/BrowserWindow.cjs +9 -3
  187. package/cjs/window/BrowserWindow.cjs.map +1 -1
  188. package/cjs/window/BrowserWindow.d.ts +2 -0
  189. package/cjs/window/BrowserWindow.d.ts.map +1 -1
  190. package/cjs/window/WindowErrorUtility.cjs +1 -1
  191. package/cjs/window/WindowErrorUtility.cjs.map +1 -1
  192. package/cjs/xml-http-request/XMLHttpRequest.cjs +2 -1
  193. package/cjs/xml-http-request/XMLHttpRequest.cjs.map +1 -1
  194. package/cjs/xml-http-request/XMLHttpRequest.d.ts.map +1 -1
  195. package/cjs/xml-http-request/XMLHttpRequestResponseDataParser.cjs +1 -1
  196. package/cjs/xml-http-request/XMLHttpRequestResponseDataParser.cjs.map +1 -1
  197. package/cjs/xml-parser/XMLParser.cjs +531 -242
  198. package/cjs/xml-parser/XMLParser.cjs.map +1 -1
  199. package/cjs/xml-parser/XMLParser.d.ts +89 -19
  200. package/cjs/xml-parser/XMLParser.d.ts.map +1 -1
  201. package/cjs/xml-serializer/XMLSerializer.cjs +136 -40
  202. package/cjs/xml-serializer/XMLSerializer.cjs.map +1 -1
  203. package/cjs/xml-serializer/XMLSerializer.d.ts +6 -17
  204. package/cjs/xml-serializer/XMLSerializer.d.ts.map +1 -1
  205. package/lib/PropertySymbol.d.ts +4 -1
  206. package/lib/PropertySymbol.d.ts.map +1 -1
  207. package/lib/PropertySymbol.js +4 -1
  208. package/lib/PropertySymbol.js.map +1 -1
  209. package/lib/browser/utilities/BrowserFrameURL.d.ts +1 -1
  210. package/lib/browser/utilities/BrowserFrameURL.d.ts.map +1 -1
  211. package/lib/browser/utilities/BrowserFrameURL.js +1 -1
  212. package/lib/browser/utilities/BrowserFrameURL.js.map +1 -1
  213. package/lib/config/HTMLElementConfig.d.ts +7 -0
  214. package/lib/config/HTMLElementConfig.d.ts.map +1 -1
  215. package/lib/config/HTMLElementConfig.js +42 -16
  216. package/lib/config/HTMLElementConfig.js.map +1 -1
  217. package/lib/config/HTMLElementConfigContentModelEnum.d.ts +3 -0
  218. package/lib/config/HTMLElementConfigContentModelEnum.d.ts.map +1 -1
  219. package/lib/config/HTMLElementConfigContentModelEnum.js +3 -0
  220. package/lib/config/HTMLElementConfigContentModelEnum.js.map +1 -1
  221. package/lib/config/NamespaceURI.d.ts +2 -0
  222. package/lib/config/NamespaceURI.d.ts.map +1 -1
  223. package/lib/config/NamespaceURI.js +2 -0
  224. package/lib/config/NamespaceURI.js.map +1 -1
  225. package/lib/css/declaration/CSSStyleDeclaration.d.ts.map +1 -1
  226. package/lib/css/declaration/CSSStyleDeclaration.js +1 -1
  227. package/lib/css/declaration/CSSStyleDeclaration.js.map +1 -1
  228. package/lib/css/declaration/computed-style/CSSStyleDeclarationComputedStyle.d.ts.map +1 -1
  229. package/lib/css/declaration/computed-style/CSSStyleDeclarationComputedStyle.js +2 -2
  230. package/lib/css/declaration/computed-style/CSSStyleDeclarationComputedStyle.js.map +1 -1
  231. package/lib/custom-element/CustomElementReactionStack.d.ts +27 -0
  232. package/lib/custom-element/CustomElementReactionStack.d.ts.map +1 -0
  233. package/lib/custom-element/CustomElementReactionStack.js +71 -0
  234. package/lib/custom-element/CustomElementReactionStack.js.map +1 -0
  235. package/lib/custom-element/CustomElementRegistry.d.ts +2 -6
  236. package/lib/custom-element/CustomElementRegistry.d.ts.map +1 -1
  237. package/lib/custom-element/CustomElementRegistry.js +32 -45
  238. package/lib/custom-element/CustomElementRegistry.js.map +1 -1
  239. package/lib/custom-element/CustomElementUtility.d.ts +14 -0
  240. package/lib/custom-element/CustomElementUtility.d.ts.map +1 -0
  241. package/lib/custom-element/CustomElementUtility.js +32 -0
  242. package/lib/custom-element/CustomElementUtility.js.map +1 -0
  243. package/lib/custom-element/ICustomElementDefinition.d.ts +12 -0
  244. package/lib/custom-element/ICustomElementDefinition.d.ts.map +1 -0
  245. package/lib/custom-element/ICustomElementDefinition.js +2 -0
  246. package/lib/custom-element/ICustomElementDefinition.js.map +1 -0
  247. package/lib/dom/DOMStringMap.d.ts.map +1 -1
  248. package/lib/dom/DOMStringMap.js +8 -8
  249. package/lib/dom/DOMStringMap.js.map +1 -1
  250. package/lib/dom/DOMTokenList.js +1 -1
  251. package/lib/dom/DOMTokenList.js.map +1 -1
  252. package/lib/dom-parser/DOMParser.d.ts +0 -1
  253. package/lib/dom-parser/DOMParser.d.ts.map +1 -1
  254. package/lib/dom-parser/DOMParser.js +5 -67
  255. package/lib/dom-parser/DOMParser.js.map +1 -1
  256. package/lib/exception/DOMExceptionNameEnum.d.ts +2 -1
  257. package/lib/exception/DOMExceptionNameEnum.d.ts.map +1 -1
  258. package/lib/exception/DOMExceptionNameEnum.js +1 -0
  259. package/lib/exception/DOMExceptionNameEnum.js.map +1 -1
  260. package/lib/history/History.d.ts +2 -2
  261. package/lib/history/History.d.ts.map +1 -1
  262. package/lib/history/History.js +8 -8
  263. package/lib/history/History.js.map +1 -1
  264. package/lib/html-parser/HTMLParser.d.ts +91 -0
  265. package/lib/html-parser/HTMLParser.d.ts.map +1 -0
  266. package/lib/html-parser/HTMLParser.js +697 -0
  267. package/lib/html-parser/HTMLParser.js.map +1 -0
  268. package/lib/html-serializer/HTMLSerializer.d.ts +36 -0
  269. package/lib/html-serializer/HTMLSerializer.d.ts.map +1 -0
  270. package/lib/html-serializer/HTMLSerializer.js +123 -0
  271. package/lib/html-serializer/HTMLSerializer.js.map +1 -0
  272. package/lib/nodes/document/Document.d.ts +8 -0
  273. package/lib/nodes/document/Document.d.ts.map +1 -1
  274. package/lib/nodes/document/Document.js +106 -122
  275. package/lib/nodes/document/Document.js.map +1 -1
  276. package/lib/nodes/element/Element.d.ts +2 -12
  277. package/lib/nodes/element/Element.d.ts.map +1 -1
  278. package/lib/nodes/element/Element.js +35 -53
  279. package/lib/nodes/element/Element.js.map +1 -1
  280. package/lib/nodes/element/HTMLCollection.d.ts.map +1 -1
  281. package/lib/nodes/element/HTMLCollection.js +5 -9
  282. package/lib/nodes/element/HTMLCollection.js.map +1 -1
  283. package/lib/nodes/element/NamedNodeMap.d.ts +1 -16
  284. package/lib/nodes/element/NamedNodeMap.d.ts.map +1 -1
  285. package/lib/nodes/element/NamedNodeMap.js +39 -52
  286. package/lib/nodes/element/NamedNodeMap.js.map +1 -1
  287. package/lib/nodes/element/NamedNodeMapProxyFactory.d.ts.map +1 -1
  288. package/lib/nodes/element/NamedNodeMapProxyFactory.js +12 -14
  289. package/lib/nodes/element/NamedNodeMapProxyFactory.js.map +1 -1
  290. package/lib/nodes/html-button-element/HTMLButtonElement.d.ts.map +1 -1
  291. package/lib/nodes/html-button-element/HTMLButtonElement.js +1 -1
  292. package/lib/nodes/html-button-element/HTMLButtonElement.js.map +1 -1
  293. package/lib/nodes/html-document/HTMLDocument.d.ts +10 -0
  294. package/lib/nodes/html-document/HTMLDocument.d.ts.map +1 -1
  295. package/lib/nodes/html-document/HTMLDocument.js +33 -2
  296. package/lib/nodes/html-document/HTMLDocument.js.map +1 -1
  297. package/lib/nodes/html-element/HTMLElement.d.ts +34 -0
  298. package/lib/nodes/html-element/HTMLElement.d.ts.map +1 -1
  299. package/lib/nodes/html-element/HTMLElement.js +52 -22
  300. package/lib/nodes/html-element/HTMLElement.js.map +1 -1
  301. package/lib/nodes/html-field-set-element/HTMLFieldSetElement.d.ts.map +1 -1
  302. package/lib/nodes/html-field-set-element/HTMLFieldSetElement.js +1 -1
  303. package/lib/nodes/html-field-set-element/HTMLFieldSetElement.js.map +1 -1
  304. package/lib/nodes/html-form-element/HTMLFormElement.d.ts.map +1 -1
  305. package/lib/nodes/html-form-element/HTMLFormElement.js +5 -8
  306. package/lib/nodes/html-form-element/HTMLFormElement.js.map +1 -1
  307. package/lib/nodes/html-iframe-element/HTMLIFrameElement.js +1 -1
  308. package/lib/nodes/html-iframe-element/HTMLIFrameElement.js.map +1 -1
  309. package/lib/nodes/html-input-element/HTMLInputElement.d.ts.map +1 -1
  310. package/lib/nodes/html-input-element/HTMLInputElement.js +1 -1
  311. package/lib/nodes/html-input-element/HTMLInputElement.js.map +1 -1
  312. package/lib/nodes/html-media-element/TextTrackList.js +1 -1
  313. package/lib/nodes/html-media-element/TextTrackList.js.map +1 -1
  314. package/lib/nodes/html-object-element/HTMLObjectElement.d.ts.map +1 -1
  315. package/lib/nodes/html-object-element/HTMLObjectElement.js +1 -1
  316. package/lib/nodes/html-object-element/HTMLObjectElement.js.map +1 -1
  317. package/lib/nodes/html-output-element/HTMLOutputElement.d.ts.map +1 -1
  318. package/lib/nodes/html-output-element/HTMLOutputElement.js +1 -1
  319. package/lib/nodes/html-output-element/HTMLOutputElement.js.map +1 -1
  320. package/lib/nodes/html-script-element/HTMLScriptElement.d.ts.map +1 -1
  321. package/lib/nodes/html-script-element/HTMLScriptElement.js +3 -1
  322. package/lib/nodes/html-script-element/HTMLScriptElement.js.map +1 -1
  323. package/lib/nodes/html-select-element/HTMLSelectElement.d.ts.map +1 -1
  324. package/lib/nodes/html-select-element/HTMLSelectElement.js +2 -2
  325. package/lib/nodes/html-select-element/HTMLSelectElement.js.map +1 -1
  326. package/lib/nodes/html-table-element/HTMLTableElement.d.ts.map +1 -1
  327. package/lib/nodes/html-table-element/HTMLTableElement.js +9 -1
  328. package/lib/nodes/html-table-element/HTMLTableElement.js.map +1 -1
  329. package/lib/nodes/html-table-row-element/HTMLTableRowElement.js +1 -1
  330. package/lib/nodes/html-template-element/HTMLTemplateElement.d.ts +2 -2
  331. package/lib/nodes/html-template-element/HTMLTemplateElement.d.ts.map +1 -1
  332. package/lib/nodes/html-template-element/HTMLTemplateElement.js +15 -17
  333. package/lib/nodes/html-template-element/HTMLTemplateElement.js.map +1 -1
  334. package/lib/nodes/html-text-area-element/HTMLTextAreaElement.d.ts.map +1 -1
  335. package/lib/nodes/html-text-area-element/HTMLTextAreaElement.js +1 -1
  336. package/lib/nodes/html-text-area-element/HTMLTextAreaElement.js.map +1 -1
  337. package/lib/nodes/node/Node.d.ts +2 -10
  338. package/lib/nodes/node/Node.d.ts.map +1 -1
  339. package/lib/nodes/node/Node.js +44 -48
  340. package/lib/nodes/node/Node.js.map +1 -1
  341. package/lib/nodes/node/NodeList.js +1 -1
  342. package/lib/nodes/node/NodeList.js.map +1 -1
  343. package/lib/nodes/node/NodeUtility.d.ts.map +1 -1
  344. package/lib/nodes/node/NodeUtility.js +4 -3
  345. package/lib/nodes/node/NodeUtility.js.map +1 -1
  346. package/lib/nodes/parent-node/ParentNodeUtility.d.ts.map +1 -1
  347. package/lib/nodes/parent-node/ParentNodeUtility.js +5 -2
  348. package/lib/nodes/parent-node/ParentNodeUtility.js.map +1 -1
  349. package/lib/nodes/shadow-root/ShadowRoot.d.ts.map +1 -1
  350. package/lib/nodes/shadow-root/ShadowRoot.js +8 -8
  351. package/lib/nodes/shadow-root/ShadowRoot.js.map +1 -1
  352. package/lib/nodes/xml-document/XMLDocument.d.ts +2 -0
  353. package/lib/nodes/xml-document/XMLDocument.d.ts.map +1 -1
  354. package/lib/nodes/xml-document/XMLDocument.js +3 -0
  355. package/lib/nodes/xml-document/XMLDocument.js.map +1 -1
  356. package/lib/query-selector/SelectorItem.d.ts.map +1 -1
  357. package/lib/query-selector/SelectorItem.js +1 -2
  358. package/lib/query-selector/SelectorItem.js.map +1 -1
  359. package/lib/range/Range.d.ts.map +1 -1
  360. package/lib/range/Range.js +3 -3
  361. package/lib/range/Range.js.map +1 -1
  362. package/lib/storage/Storage.js +1 -1
  363. package/lib/storage/Storage.js.map +1 -1
  364. package/lib/svg/SVGLengthList.js +1 -1
  365. package/lib/svg/SVGLengthList.js.map +1 -1
  366. package/lib/svg/SVGNumberList.js +1 -1
  367. package/lib/svg/SVGNumberList.js.map +1 -1
  368. package/lib/svg/SVGPointList.js +1 -1
  369. package/lib/svg/SVGPointList.js.map +1 -1
  370. package/lib/svg/SVGStringList.js +1 -1
  371. package/lib/svg/SVGStringList.js.map +1 -1
  372. package/lib/svg/SVGTransformList.js +1 -1
  373. package/lib/svg/SVGTransformList.js.map +1 -1
  374. package/lib/tree-walker/NodeIterator.d.ts +18 -3
  375. package/lib/tree-walker/NodeIterator.d.ts.map +1 -1
  376. package/lib/tree-walker/NodeIterator.js +40 -6
  377. package/lib/tree-walker/NodeIterator.js.map +1 -1
  378. package/lib/tree-walker/TreeWalker.d.ts +2 -1
  379. package/lib/tree-walker/TreeWalker.d.ts.map +1 -1
  380. package/lib/tree-walker/TreeWalker.js +6 -6
  381. package/lib/tree-walker/TreeWalker.js.map +1 -1
  382. package/lib/utilities/ClassMethodBinder.d.ts.map +1 -0
  383. package/lib/utilities/ClassMethodBinder.js.map +1 -0
  384. package/lib/utilities/StringUtility.d.ts.map +1 -0
  385. package/lib/utilities/StringUtility.js.map +1 -0
  386. package/lib/utilities/XMLEncodeUtility.d.ts +48 -0
  387. package/lib/utilities/XMLEncodeUtility.d.ts.map +1 -0
  388. package/lib/utilities/XMLEncodeUtility.js +116 -0
  389. package/lib/utilities/XMLEncodeUtility.js.map +1 -0
  390. package/lib/window/BrowserWindow.d.ts +2 -0
  391. package/lib/window/BrowserWindow.d.ts.map +1 -1
  392. package/lib/window/BrowserWindow.js +9 -3
  393. package/lib/window/BrowserWindow.js.map +1 -1
  394. package/lib/window/WindowErrorUtility.js +1 -1
  395. package/lib/window/WindowErrorUtility.js.map +1 -1
  396. package/lib/xml-http-request/XMLHttpRequest.d.ts.map +1 -1
  397. package/lib/xml-http-request/XMLHttpRequest.js +2 -1
  398. package/lib/xml-http-request/XMLHttpRequest.js.map +1 -1
  399. package/lib/xml-http-request/XMLHttpRequestResponseDataParser.js +1 -1
  400. package/lib/xml-http-request/XMLHttpRequestResponseDataParser.js.map +1 -1
  401. package/lib/xml-parser/XMLParser.d.ts +89 -19
  402. package/lib/xml-parser/XMLParser.d.ts.map +1 -1
  403. package/lib/xml-parser/XMLParser.js +531 -242
  404. package/lib/xml-parser/XMLParser.js.map +1 -1
  405. package/lib/xml-serializer/XMLSerializer.d.ts +6 -17
  406. package/lib/xml-serializer/XMLSerializer.d.ts.map +1 -1
  407. package/lib/xml-serializer/XMLSerializer.js +136 -40
  408. package/lib/xml-serializer/XMLSerializer.js.map +1 -1
  409. package/package.json +1 -2
  410. package/src/PropertySymbol.ts +4 -1
  411. package/src/browser/utilities/BrowserFrameURL.ts +2 -2
  412. package/src/config/HTMLElementConfig.ts +53 -17
  413. package/src/config/HTMLElementConfigContentModelEnum.ts +3 -0
  414. package/src/config/NamespaceURI.ts +2 -0
  415. package/src/css/declaration/CSSStyleDeclaration.ts +1 -4
  416. package/src/css/declaration/computed-style/CSSStyleDeclarationComputedStyle.ts +2 -4
  417. package/src/custom-element/CustomElementReactionStack.ts +81 -0
  418. package/src/custom-element/CustomElementRegistry.ts +35 -54
  419. package/src/custom-element/CustomElementUtility.ts +34 -0
  420. package/src/custom-element/ICustomElementDefinition.ts +16 -0
  421. package/src/dom/DOMStringMap.ts +12 -10
  422. package/src/dom/DOMTokenList.ts +1 -1
  423. package/src/dom-parser/DOMParser.ts +5 -75
  424. package/src/exception/DOMExceptionNameEnum.ts +2 -1
  425. package/src/history/History.ts +10 -10
  426. package/src/html-parser/HTMLParser.ts +864 -0
  427. package/src/html-serializer/HTMLSerializer.ts +162 -0
  428. package/src/nodes/document/Document.ts +118 -137
  429. package/src/nodes/element/Element.ts +48 -95
  430. package/src/nodes/element/HTMLCollection.ts +5 -30
  431. package/src/nodes/element/NamedNodeMap.ts +58 -72
  432. package/src/nodes/element/NamedNodeMapProxyFactory.ts +12 -15
  433. package/src/nodes/html-button-element/HTMLButtonElement.ts +1 -4
  434. package/src/nodes/html-document/HTMLDocument.ts +58 -2
  435. package/src/nodes/html-element/HTMLElement.ts +107 -25
  436. package/src/nodes/html-field-set-element/HTMLFieldSetElement.ts +1 -4
  437. package/src/nodes/html-form-element/HTMLFormElement.ts +5 -27
  438. package/src/nodes/html-iframe-element/HTMLIFrameElement.ts +1 -1
  439. package/src/nodes/html-input-element/HTMLInputElement.ts +1 -4
  440. package/src/nodes/html-media-element/TextTrackList.ts +1 -1
  441. package/src/nodes/html-object-element/HTMLObjectElement.ts +1 -4
  442. package/src/nodes/html-output-element/HTMLOutputElement.ts +1 -4
  443. package/src/nodes/html-script-element/HTMLScriptElement.ts +4 -1
  444. package/src/nodes/html-select-element/HTMLSelectElement.ts +2 -5
  445. package/src/nodes/html-table-element/HTMLTableElement.ts +8 -1
  446. package/src/nodes/html-table-row-element/HTMLTableRowElement.ts +1 -1
  447. package/src/nodes/html-template-element/HTMLTemplateElement.ts +23 -17
  448. package/src/nodes/html-text-area-element/HTMLTextAreaElement.ts +1 -4
  449. package/src/nodes/node/Node.ts +57 -70
  450. package/src/nodes/node/NodeList.ts +1 -1
  451. package/src/nodes/node/NodeUtility.ts +4 -3
  452. package/src/nodes/parent-node/ParentNodeUtility.ts +6 -6
  453. package/src/nodes/shadow-root/ShadowRoot.ts +8 -8
  454. package/src/nodes/xml-document/XMLDocument.ts +5 -1
  455. package/src/query-selector/SelectorItem.ts +1 -2
  456. package/src/range/Range.ts +3 -3
  457. package/src/storage/Storage.ts +1 -1
  458. package/src/svg/SVGLengthList.ts +1 -1
  459. package/src/svg/SVGNumberList.ts +1 -1
  460. package/src/svg/SVGPointList.ts +1 -1
  461. package/src/svg/SVGStringList.ts +1 -1
  462. package/src/svg/SVGTransformList.ts +1 -1
  463. package/src/tree-walker/NodeIterator.ts +44 -8
  464. package/src/tree-walker/TreeWalker.ts +6 -6
  465. package/src/utilities/XMLEncodeUtility.ts +127 -0
  466. package/src/window/BrowserWindow.ts +18 -5
  467. package/src/window/WindowErrorUtility.ts +1 -1
  468. package/src/xml-http-request/XMLHttpRequest.ts +3 -1
  469. package/src/xml-http-request/XMLHttpRequestResponseDataParser.ts +1 -1
  470. package/src/xml-parser/XMLParser.ts +627 -313
  471. package/src/xml-serializer/XMLSerializer.ts +204 -58
  472. package/cjs/ClassMethodBinder.cjs.map +0 -1
  473. package/cjs/ClassMethodBinder.d.ts.map +0 -1
  474. package/cjs/StringUtility.cjs.map +0 -1
  475. package/cjs/StringUtility.d.ts.map +0 -1
  476. package/lib/ClassMethodBinder.d.ts.map +0 -1
  477. package/lib/ClassMethodBinder.js.map +0 -1
  478. package/lib/StringUtility.d.ts.map +0 -1
  479. package/lib/StringUtility.js.map +0 -1
  480. /package/cjs/{ClassMethodBinder.cjs → utilities/ClassMethodBinder.cjs} +0 -0
  481. /package/cjs/{ClassMethodBinder.d.ts → utilities/ClassMethodBinder.d.ts} +0 -0
  482. /package/cjs/{StringUtility.cjs → utilities/StringUtility.cjs} +0 -0
  483. /package/cjs/{StringUtility.d.ts → utilities/StringUtility.d.ts} +0 -0
  484. /package/lib/{ClassMethodBinder.d.ts → utilities/ClassMethodBinder.d.ts} +0 -0
  485. /package/lib/{ClassMethodBinder.js → utilities/ClassMethodBinder.js} +0 -0
  486. /package/lib/{StringUtility.d.ts → utilities/StringUtility.d.ts} +0 -0
  487. /package/lib/{StringUtility.js → utilities/StringUtility.js} +0 -0
  488. /package/src/{ClassMethodBinder.ts → utilities/ClassMethodBinder.ts} +0 -0
  489. /package/src/{StringUtility.ts → utilities/StringUtility.ts} +0 -0
@@ -0,0 +1,81 @@
1
+ import HTMLElement from '../nodes/html-element/HTMLElement.js';
2
+ import BrowserWindow from '../window/BrowserWindow.js';
3
+ import * as PropertySymbol from '../PropertySymbol.js';
4
+ import WindowBrowserContext from '../window/WindowBrowserContext.js';
5
+
6
+ /**
7
+ * Custom element reaction stack.
8
+ *
9
+ * @see https://html.spec.whatwg.org/multipage/custom-elements.html#custom-element-reactions-stack
10
+ */
11
+ export default class CustomElementReactionStack {
12
+ private window: BrowserWindow;
13
+
14
+ /**
15
+ * Constructor.
16
+ *
17
+ * @param window Window.
18
+ */
19
+ constructor(window: BrowserWindow) {
20
+ this.window = window;
21
+ }
22
+
23
+ /**
24
+ * Enqueues a custom element reaction.
25
+ *
26
+ * @see https://html.spec.whatwg.org/multipage/custom-elements.html#enqueue-a-custom-element-callback-reaction
27
+ * @see https://html.spec.whatwg.org/multipage/custom-elements.html#enqueue-an-element-on-the-appropriate-element-queue
28
+ * @param element Element.
29
+ * @param callbackName Callback name.
30
+ * @param [args] Arguments.
31
+ */
32
+ public enqueueReaction(element: HTMLElement, callbackName: string, args?: any[]): void {
33
+ // If a polyfill is used, [PropertySymbol.registry] may be undefined
34
+ const definition = this.window.customElements[PropertySymbol.registry]?.get(element.localName);
35
+
36
+ if (!definition) {
37
+ return;
38
+ }
39
+
40
+ // According to the spec, we should use a queue for each element and then invoke the reactions in the order they were enqueued asynchronously.
41
+ // However, the browser seem to always invoke the reactions synchronously.
42
+ // TODO: Can we find an example where the reactions are invoked asynchronously? In that case we should use a queue for those cases.
43
+
44
+ switch (callbackName) {
45
+ case 'connectedCallback':
46
+ if (definition.livecycleCallbacks.connectedCallback) {
47
+ const returnValue = definition.livecycleCallbacks.connectedCallback.call(element);
48
+
49
+ /**
50
+ * It is common to import dependencies in the connectedCallback() method of web components.
51
+ * As Happy DOM doesn't have support for dynamic imports yet, this is a temporary solution to wait for imports in connectedCallback().
52
+ *
53
+ * @see https://github.com/capricorn86/happy-dom/issues/1442
54
+ */
55
+ if (returnValue instanceof Promise) {
56
+ const asyncTaskManager = new WindowBrowserContext(this.window).getAsyncTaskManager();
57
+ if (asyncTaskManager) {
58
+ const taskID = asyncTaskManager.startTask();
59
+ returnValue
60
+ .then(() => asyncTaskManager.endTask(taskID))
61
+ .catch(() => asyncTaskManager.endTask(taskID));
62
+ }
63
+ }
64
+ }
65
+ break;
66
+ case 'disconnectedCallback':
67
+ if (definition.livecycleCallbacks.disconnectedCallback) {
68
+ definition.livecycleCallbacks.disconnectedCallback.call(element);
69
+ }
70
+ break;
71
+ case 'attributeChangedCallback':
72
+ if (
73
+ definition.livecycleCallbacks.attributeChangedCallback &&
74
+ definition.observedAttributes.has(args[0])
75
+ ) {
76
+ definition.livecycleCallbacks.attributeChangedCallback.apply(element, args);
77
+ }
78
+ break;
79
+ }
80
+ }
81
+ }
@@ -3,14 +3,15 @@ import HTMLElement from '../nodes/html-element/HTMLElement.js';
3
3
  import Node from '../nodes/node/Node.js';
4
4
  import BrowserWindow from '../window/BrowserWindow.js';
5
5
  import NamespaceURI from '../config/NamespaceURI.js';
6
+ import StringUtility from '../utilities/StringUtility.js';
7
+ import CustomElementUtility from './CustomElementUtility.js';
8
+ import ICustomElementDefinition from './ICustomElementDefinition.js';
6
9
 
7
10
  /**
8
11
  * Custom elements registry.
9
12
  */
10
13
  export default class CustomElementRegistry {
11
- public [PropertySymbol.registry]: {
12
- [k: string]: { elementClass: typeof HTMLElement; extends: string };
13
- } = {};
14
+ public [PropertySymbol.registry]: Map<string, ICustomElementDefinition> = new Map();
14
15
  public [PropertySymbol.classRegistry]: Map<typeof HTMLElement, string> = new Map();
15
16
  public [PropertySymbol.callbacks]: Map<string, Array<() => void>> = new Map();
16
17
  public [PropertySymbol.destroyed]: boolean = false;
@@ -45,13 +46,13 @@ export default class CustomElementRegistry {
45
46
  return;
46
47
  }
47
48
 
48
- if (!this.#isValidCustomElementName(name)) {
49
+ if (!CustomElementUtility.isValidCustomElementName(name)) {
49
50
  throw new this.#window.DOMException(
50
51
  `Failed to execute 'define' on 'CustomElementRegistry': "${name}" is not a valid custom element name`
51
52
  );
52
53
  }
53
54
 
54
- if (this[PropertySymbol.registry][name]) {
55
+ if (this[PropertySymbol.registry].has(name)) {
55
56
  throw new this.#window.DOMException(
56
57
  `Failed to execute 'define' on 'CustomElementRegistry': the name "${name}" has already been used with this registry`
57
58
  );
@@ -63,7 +64,7 @@ export default class CustomElementRegistry {
63
64
  );
64
65
  }
65
66
 
66
- const tagName = name.toUpperCase();
67
+ const tagName = StringUtility.asciiUpperCase(name);
67
68
 
68
69
  elementClass.prototype[PropertySymbol.window] = this.#window;
69
70
  elementClass.prototype[PropertySymbol.ownerDocument] = this.#window.document;
@@ -71,17 +72,28 @@ export default class CustomElementRegistry {
71
72
  elementClass.prototype[PropertySymbol.localName] = name;
72
73
  elementClass.prototype[PropertySymbol.namespaceURI] = NamespaceURI.html;
73
74
 
74
- this[PropertySymbol.registry][name] = {
75
+ // ObservedAttributes should only be called once by CustomElementRegistry (see #117)
76
+ const observedAttributes: Set<string> = new Set();
77
+ const elementObservervedAttributes = elementClass.observedAttributes;
78
+
79
+ if (Array.isArray(elementObservervedAttributes)) {
80
+ for (const attribute of elementObservervedAttributes) {
81
+ observedAttributes.add(String(attribute).toLowerCase());
82
+ }
83
+ }
84
+
85
+ this[PropertySymbol.registry].set(name, {
75
86
  elementClass,
76
- extends: options && options.extends ? options.extends.toLowerCase() : null
77
- };
87
+ extends: options && options.extends ? options.extends.toLowerCase() : null,
88
+ observedAttributes,
89
+ livecycleCallbacks: {
90
+ connectedCallback: elementClass.prototype.connectedCallback,
91
+ disconnectedCallback: elementClass.prototype.disconnectedCallback,
92
+ attributeChangedCallback: elementClass.prototype.attributeChangedCallback
93
+ }
94
+ });
78
95
  this[PropertySymbol.classRegistry].set(elementClass, name);
79
96
 
80
- // ObservedAttributes should only be called once by CustomElementRegistry (see #117)
81
- elementClass[PropertySymbol.observedAttributes] = (elementClass.observedAttributes || []).map(
82
- (name) => String(name).toLowerCase()
83
- );
84
-
85
97
  const callbacks = this[PropertySymbol.callbacks].get(name);
86
98
  if (callbacks) {
87
99
  this[PropertySymbol.callbacks].delete(name);
@@ -98,7 +110,7 @@ export default class CustomElementRegistry {
98
110
  * @returns HTMLElement Class defined or undefined.
99
111
  */
100
112
  public get(name: string): typeof HTMLElement | undefined {
101
- return this[PropertySymbol.registry][name]?.elementClass;
113
+ return this[PropertySymbol.registry].get(name)?.elementClass;
102
114
  }
103
115
 
104
116
  /**
@@ -125,7 +137,7 @@ export default class CustomElementRegistry {
125
137
  )
126
138
  );
127
139
  }
128
- if (!this.#isValidCustomElementName(name)) {
140
+ if (!CustomElementUtility.isValidCustomElementName(name)) {
129
141
  return Promise.reject(
130
142
  new this.#window.DOMException(
131
143
  `Failed to execute 'whenDefined' on 'CustomElementRegistry': Invalid custom element name: "${name}"`
@@ -160,46 +172,15 @@ export default class CustomElementRegistry {
160
172
  */
161
173
  public [PropertySymbol.destroy](): void {
162
174
  this[PropertySymbol.destroyed] = true;
163
- for (const entity of Object.values(this[PropertySymbol.registry])) {
164
- entity.elementClass.prototype[PropertySymbol.window] = null;
165
- entity.elementClass.prototype[PropertySymbol.ownerDocument] = null;
166
- entity.elementClass.prototype[PropertySymbol.tagName] = null;
167
- entity.elementClass.prototype[PropertySymbol.localName] = null;
168
- entity.elementClass.prototype[PropertySymbol.namespaceURI] = null;
175
+ for (const definition of this[PropertySymbol.registry].values()) {
176
+ definition.elementClass.prototype[PropertySymbol.window] = null;
177
+ definition.elementClass.prototype[PropertySymbol.ownerDocument] = null;
178
+ definition.elementClass.prototype[PropertySymbol.tagName] = null;
179
+ definition.elementClass.prototype[PropertySymbol.localName] = null;
180
+ definition.elementClass.prototype[PropertySymbol.namespaceURI] = null;
169
181
  }
170
- this[PropertySymbol.registry] = {};
182
+ this[PropertySymbol.registry] = new Map();
171
183
  this[PropertySymbol.classRegistry] = new Map();
172
184
  this[PropertySymbol.callbacks] = new Map();
173
185
  }
174
-
175
- /**
176
- * Validates the correctness of custom element tag names.
177
- *
178
- * @param name Custom element tag name.
179
- * @returns True, if tag name is standard compliant.
180
- */
181
- #isValidCustomElementName(name: string): boolean {
182
- // Validation criteria based on:
183
- // https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name
184
- const PCENChar =
185
- '[-_.]|[0-9]|[a-z]|\u{B7}|[\u{C0}-\u{D6}]|[\u{D8}-\u{F6}]' +
186
- '|[\u{F8}-\u{37D}]|[\u{37F}-\u{1FFF}]' +
187
- '|[\u{200C}-\u{200D}]|[\u{203F}-\u{2040}]|[\u{2070}-\u{218F}]' +
188
- '|[\u{2C00}-\u{2FEF}]|[\u{3001}-\u{D7FF}]' +
189
- '|[\u{F900}-\u{FDCF}]|[\u{FDF0}-\u{FFFD}]|[\u{10000}-\u{EFFFF}]';
190
-
191
- const PCEN = new RegExp(`^[a-z](${PCENChar})*-(${PCENChar})*$`, 'u');
192
-
193
- const reservedNames = [
194
- 'annotation-xml',
195
- 'color-profile',
196
- 'font-face',
197
- 'font-face-src',
198
- 'font-face-uri',
199
- 'font-face-format',
200
- 'font-face-name',
201
- 'missing-glyph'
202
- ];
203
- return PCEN.test(name) && !reservedNames.includes(name);
204
- }
205
186
  }
@@ -0,0 +1,34 @@
1
+ const PCEN_CHAR =
2
+ '[-_.]|[0-9]|[a-z]|\u{B7}|[\u{C0}-\u{D6}]|[\u{D8}-\u{F6}]' +
3
+ '|[\u{F8}-\u{37D}]|[\u{37F}-\u{1FFF}]' +
4
+ '|[\u{200C}-\u{200D}]|[\u{203F}-\u{2040}]|[\u{2070}-\u{218F}]' +
5
+ '|[\u{2C00}-\u{2FEF}]|[\u{3001}-\u{D7FF}]' +
6
+ '|[\u{F900}-\u{FDCF}]|[\u{FDF0}-\u{FFFD}]|[\u{10000}-\u{EFFFF}]';
7
+
8
+ const PCEN_REGEXP = new RegExp(`^[a-z](${PCEN_CHAR})*-(${PCEN_CHAR})*$`, 'u');
9
+ const RESERVED_NAMES = [
10
+ 'annotation-xml',
11
+ 'color-profile',
12
+ 'font-face',
13
+ 'font-face-src',
14
+ 'font-face-uri',
15
+ 'font-face-format',
16
+ 'font-face-name',
17
+ 'missing-glyph'
18
+ ];
19
+
20
+ /**
21
+ * Custom element utility.
22
+ */
23
+ export default class CustomElementUtility {
24
+ /**
25
+ * Returns true if the tag name is a valid custom element name.
26
+ *
27
+ * @see https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name
28
+ * @param name Tag name.
29
+ * @returns True if valid.
30
+ */
31
+ public static isValidCustomElementName(name: string): boolean {
32
+ return PCEN_REGEXP.test(name) && !RESERVED_NAMES.includes(name);
33
+ }
34
+ }
@@ -0,0 +1,16 @@
1
+ import HTMLElement from '../nodes/html-element/HTMLElement.js';
2
+
3
+ export default interface ICustomElementDefinition {
4
+ elementClass: typeof HTMLElement;
5
+ extends: string;
6
+ observedAttributes: Set<string>;
7
+ livecycleCallbacks: {
8
+ connectedCallback: () => void;
9
+ disconnectedCallback: () => void;
10
+ attributeChangedCallback: (
11
+ name: string,
12
+ oldValue: string | null,
13
+ newValue: string | null
14
+ ) => void;
15
+ };
16
+ }
@@ -26,11 +26,11 @@ export default class DOMStringMap {
26
26
  // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy
27
27
  return new Proxy(this, {
28
28
  get(_target, property: string): string {
29
- const attribute = element[PropertySymbol.attributes][PropertySymbol.namedItems].get(
29
+ const attribute = element.getAttribute(
30
30
  'data-' + DOMStringMapUtility.camelCaseToKebab(property)
31
31
  );
32
32
  if (attribute) {
33
- return attribute[PropertySymbol.value];
33
+ return attribute;
34
34
  }
35
35
  },
36
36
  set(_target, property: string, value: string): boolean {
@@ -46,19 +46,21 @@ export default class DOMStringMap {
46
46
  // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/Proxy/ownKeys
47
47
  // "The result List must contain the keys of all non-configurable own properties of the target object."
48
48
  const keys = [];
49
- for (const item of element[PropertySymbol.attributes][PropertySymbol.namedItems].values()) {
50
- if (item[PropertySymbol.name].startsWith('data-')) {
49
+ for (const items of element[PropertySymbol.attributes][
50
+ PropertySymbol.namedItems
51
+ ].values()) {
52
+ if (items[0][PropertySymbol.name].startsWith('data-')) {
51
53
  keys.push(
52
- DOMStringMapUtility.kebabToCamelCase(item[PropertySymbol.name].replace('data-', ''))
54
+ DOMStringMapUtility.kebabToCamelCase(
55
+ items[0][PropertySymbol.name].replace('data-', '')
56
+ )
53
57
  );
54
58
  }
55
59
  }
56
60
  return keys;
57
61
  },
58
62
  has(_target, property: string): boolean {
59
- return element[PropertySymbol.attributes][PropertySymbol.namedItems].has(
60
- 'data-' + DOMStringMapUtility.camelCaseToKebab(property)
61
- );
63
+ return element.hasAttribute('data-' + DOMStringMapUtility.camelCaseToKebab(property));
62
64
  },
63
65
  defineProperty(_target, property: string, descriptor): boolean {
64
66
  if (descriptor.value === undefined) {
@@ -73,14 +75,14 @@ export default class DOMStringMap {
73
75
  return true;
74
76
  },
75
77
  getOwnPropertyDescriptor(_target, property: string): PropertyDescriptor {
76
- const attribute = element[PropertySymbol.attributes][PropertySymbol.namedItems].get(
78
+ const attribute = element.getAttribute(
77
79
  'data-' + DOMStringMapUtility.camelCaseToKebab(property)
78
80
  );
79
81
  if (!attribute) {
80
82
  return;
81
83
  }
82
84
  return {
83
- value: attribute[PropertySymbol.value],
85
+ value: attribute,
84
86
  writable: true,
85
87
  enumerable: true,
86
88
  configurable: true
@@ -1,4 +1,4 @@
1
- import ClassMethodBinder from '../ClassMethodBinder.js';
1
+ import ClassMethodBinder from '../utilities/ClassMethodBinder.js';
2
2
  import Element from '../nodes/element/Element.js';
3
3
  import * as PropertySymbol from '../PropertySymbol.js';
4
4
 
@@ -1,9 +1,8 @@
1
1
  import Document from '../nodes/document/Document.js';
2
2
  import * as PropertySymbol from '../PropertySymbol.js';
3
3
  import XMLParser from '../xml-parser/XMLParser.js';
4
- import DocumentFragment from '../nodes/document-fragment/DocumentFragment.js';
5
4
  import BrowserWindow from '../window/BrowserWindow.js';
6
- import NodeTypeEnum from '../nodes/node/NodeTypeEnum.js';
5
+ import HTMLParser from '../html-parser/HTMLParser.js';
7
6
 
8
7
  /**
9
8
  * DOM parser.
@@ -29,87 +28,18 @@ export default class DOMParser {
29
28
  );
30
29
  }
31
30
 
32
- const newDocument = <Document>this.#createDocument(mimeType);
33
- const documentChildNodes = newDocument[PropertySymbol.nodeArray];
34
-
35
- while (documentChildNodes.length) {
36
- newDocument.removeChild(documentChildNodes[0]);
37
- }
38
-
39
- const root = <DocumentFragment>XMLParser.parse(newDocument, string, { evaluateScripts: true });
40
- let documentElement = null;
41
- let documentTypeNode = null;
42
-
43
- for (const node of root[PropertySymbol.nodeArray]) {
44
- if (node['tagName'] === 'HTML') {
45
- documentElement = node;
46
- } else if (node[PropertySymbol.nodeType] === NodeTypeEnum.documentTypeNode) {
47
- documentTypeNode = node;
48
- }
49
-
50
- if (documentElement && documentTypeNode) {
51
- break;
52
- }
53
- }
54
-
55
- if (documentElement) {
56
- if (documentTypeNode) {
57
- newDocument.appendChild(documentTypeNode);
58
- }
59
- newDocument.appendChild(documentElement);
60
- const body = newDocument.body;
61
- if (body) {
62
- while (root[PropertySymbol.nodeArray].length) {
63
- body.appendChild(root[PropertySymbol.nodeArray][0]);
64
- }
65
- }
66
- } else {
67
- switch (mimeType) {
68
- case 'image/svg+xml':
69
- {
70
- while (root[PropertySymbol.nodeArray].length) {
71
- newDocument.appendChild(root[PropertySymbol.nodeArray][0]);
72
- }
73
- }
74
- break;
75
- case 'text/html':
76
- default:
77
- {
78
- const documentElement = newDocument.createElement('html');
79
- const bodyElement = newDocument.createElement('body');
80
- const headElement = newDocument.createElement('head');
81
-
82
- documentElement.appendChild(headElement);
83
- documentElement.appendChild(bodyElement);
84
- newDocument.appendChild(documentElement);
85
-
86
- while (root[PropertySymbol.nodeArray].length) {
87
- bodyElement.appendChild(root[PropertySymbol.nodeArray][0]);
88
- }
89
- }
90
- break;
91
- }
92
- }
93
-
94
- return newDocument;
95
- }
96
-
97
- /**
98
- *
99
- * @param mimeType Mime type.
100
- * @returns Document.
101
- */
102
- #createDocument(mimeType: string): Document {
103
31
  const window = this[PropertySymbol.window];
104
32
 
105
33
  switch (mimeType) {
106
34
  case 'text/html':
107
- return new window.HTMLDocument();
35
+ const newDocument = new window.HTMLDocument();
36
+ newDocument[PropertySymbol.defaultView] = window;
37
+ return <Document>new HTMLParser(this[PropertySymbol.window]).parse(string, newDocument);
108
38
  case 'image/svg+xml':
109
39
  case 'text/xml':
110
40
  case 'application/xml':
111
41
  case 'application/xhtml+xml':
112
- return new window.XMLDocument();
42
+ return <Document>new XMLParser(this[PropertySymbol.window]).parse(string);
113
43
  default:
114
44
  throw new window.DOMException(`Unknown mime type "${mimeType}".`);
115
45
  }
@@ -16,6 +16,7 @@ enum DOMExceptionNameEnum {
16
16
  abortError = 'AbortError',
17
17
  timeoutError = 'TimeoutError',
18
18
  encodingError = 'EncodingError',
19
- uriMismatchError = 'URIMismatchError'
19
+ uriMismatchError = 'URIMismatchError',
20
+ inUseAttributeError = 'InUseAttributeError'
20
21
  }
21
22
  export default DOMExceptionNameEnum;
@@ -47,7 +47,7 @@ export default class History {
47
47
  * @returns History length.
48
48
  */
49
49
  public get length(): number {
50
- return this.#browserFrame[PropertySymbol.history].length;
50
+ return this.#browserFrame?.[PropertySymbol.history].length || 0;
51
51
  }
52
52
 
53
53
  /**
@@ -87,7 +87,7 @@ export default class History {
87
87
  */
88
88
  public back(): void {
89
89
  if (!this.#window.closed) {
90
- this.#browserFrame.goBack();
90
+ this.#browserFrame?.goBack();
91
91
  }
92
92
  }
93
93
 
@@ -96,7 +96,7 @@ export default class History {
96
96
  */
97
97
  public forward(): void {
98
98
  if (!this.#window.closed) {
99
- this.#browserFrame.goForward();
99
+ this.#browserFrame?.goForward();
100
100
  }
101
101
  }
102
102
 
@@ -108,7 +108,7 @@ export default class History {
108
108
  */
109
109
  public go(delta: number): void {
110
110
  if (!this.#window.closed) {
111
- this.#browserFrame.goSteps(delta);
111
+ this.#browserFrame?.goSteps(delta);
112
112
  }
113
113
  }
114
114
 
@@ -119,12 +119,12 @@ export default class History {
119
119
  * @param title Title.
120
120
  * @param [url] URL.
121
121
  */
122
- public pushState(state: object, title, url?: string): void {
122
+ public pushState(state: object, title, url?: string | URL): void {
123
123
  if (this.#window.closed) {
124
124
  return;
125
125
  }
126
126
 
127
- const history = this.#browserFrame[PropertySymbol.history];
127
+ const history = this.#browserFrame?.[PropertySymbol.history];
128
128
 
129
129
  if (!history) {
130
130
  return;
@@ -135,7 +135,7 @@ export default class History {
135
135
 
136
136
  if (url && newURL.origin !== location.origin) {
137
137
  throw new this.#window.DOMException(
138
- `Failed to execute 'pushState' on 'History': A history state object with URL '${url}' cannot be created in a document with origin '${location.origin}' and URL '${location.href}'.`,
138
+ `Failed to execute 'pushState' on 'History': A history state object with URL '${url.toString()}' cannot be created in a document with origin '${location.origin}' and URL '${location.href}'.`,
139
139
  DOMExceptionNameEnum.securityError
140
140
  );
141
141
  }
@@ -177,12 +177,12 @@ export default class History {
177
177
  * @param title Title.
178
178
  * @param [url] URL.
179
179
  */
180
- public replaceState(state: object, title, url?: string): void {
180
+ public replaceState(state: object, title, url?: string | URL): void {
181
181
  if (this.#window.closed) {
182
182
  return;
183
183
  }
184
184
 
185
- const history = this.#browserFrame[PropertySymbol.history];
185
+ const history = this.#browserFrame?.[PropertySymbol.history];
186
186
 
187
187
  if (!history) {
188
188
  return;
@@ -193,7 +193,7 @@ export default class History {
193
193
 
194
194
  if (url && newURL.origin !== location.origin) {
195
195
  throw new this.#window.DOMException(
196
- `Failed to execute 'pushState' on 'History': A history state object with URL '${url}' cannot be created in a document with origin '${location.origin}' and URL '${location.href}'.`,
196
+ `Failed to execute 'pushState' on 'History': A history state object with URL '${url.toString()}' cannot be created in a document with origin '${location.origin}' and URL '${location.href}'.`,
197
197
  DOMExceptionNameEnum.securityError
198
198
  );
199
199
  }