happy-dom 8.9.0 → 9.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


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

Files changed (360) hide show
  1. package/README.md +2 -2
  2. package/lib/cookie/CookieJar.js +1 -1
  3. package/lib/cookie/CookieJar.js.map +1 -1
  4. package/lib/dom-token-list/DOMTokenList.js +24 -20
  5. package/lib/dom-token-list/DOMTokenList.js.map +1 -1
  6. package/lib/event/EventTarget.js +6 -3
  7. package/lib/event/EventTarget.js.map +1 -1
  8. package/lib/exception/DOMExceptionNameEnum.d.ts +5 -1
  9. package/lib/exception/DOMExceptionNameEnum.js +4 -0
  10. package/lib/exception/DOMExceptionNameEnum.js.map +1 -1
  11. package/lib/fetch/AbortController.d.ts +19 -0
  12. package/lib/fetch/AbortController.js +30 -0
  13. package/lib/fetch/AbortController.js.map +1 -0
  14. package/lib/fetch/AbortSignal.d.ts +25 -0
  15. package/lib/fetch/AbortSignal.js +51 -0
  16. package/lib/fetch/AbortSignal.js.map +1 -0
  17. package/lib/fetch/Fetch.d.ts +117 -0
  18. package/lib/fetch/Fetch.js +530 -0
  19. package/lib/fetch/Fetch.js.map +1 -0
  20. package/lib/fetch/Headers.d.ts +81 -3
  21. package/lib/fetch/Headers.js +139 -24
  22. package/lib/fetch/Headers.js.map +1 -1
  23. package/lib/fetch/Request.d.ts +56 -32
  24. package/lib/fetch/Request.js +165 -110
  25. package/lib/fetch/Request.js.map +1 -1
  26. package/lib/fetch/{ResourceFetchHandler.d.ts → ResourceFetch.d.ts} +1 -1
  27. package/lib/fetch/{ResourceFetchHandler.js → ResourceFetch.js} +5 -5
  28. package/lib/fetch/ResourceFetch.js.map +1 -0
  29. package/lib/fetch/Response.d.ts +60 -26
  30. package/lib/fetch/Response.js +196 -104
  31. package/lib/fetch/Response.js.map +1 -1
  32. package/lib/fetch/data-uri/DataURIParser.d.ts +20 -0
  33. package/lib/fetch/data-uri/DataURIParser.js +60 -0
  34. package/lib/fetch/data-uri/DataURIParser.js.map +1 -0
  35. package/lib/fetch/multipart/MultipartFormDataParser.d.ts +40 -0
  36. package/lib/fetch/multipart/MultipartFormDataParser.js +81 -0
  37. package/lib/fetch/multipart/MultipartFormDataParser.js.map +1 -0
  38. package/lib/fetch/multipart/MultipartReader.d.ts +49 -0
  39. package/lib/fetch/multipart/MultipartReader.js +178 -0
  40. package/lib/fetch/multipart/MultipartReader.js.map +1 -0
  41. package/lib/fetch/types/IHeaders.d.ts +71 -0
  42. package/lib/fetch/{IHeaders.js.map → types/IHeaders.js.map} +1 -1
  43. package/lib/fetch/types/IHeadersInit.js.map +1 -0
  44. package/lib/fetch/types/IRequest.d.ts +60 -0
  45. package/lib/fetch/{IRequest.js.map → types/IRequest.js.map} +1 -1
  46. package/lib/fetch/types/IRequestBody.d.ts +7 -0
  47. package/lib/fetch/{IBody.js → types/IRequestBody.js} +1 -1
  48. package/lib/fetch/types/IRequestBody.js.map +1 -0
  49. package/lib/fetch/types/IRequestCredentials.d.ts +2 -0
  50. package/lib/fetch/types/IRequestCredentials.js +3 -0
  51. package/lib/fetch/types/IRequestCredentials.js.map +1 -0
  52. package/lib/fetch/{RequestInfo.d.ts → types/IRequestInfo.d.ts} +2 -2
  53. package/lib/fetch/types/IRequestInfo.js +3 -0
  54. package/lib/fetch/types/IRequestInfo.js.map +1 -0
  55. package/lib/fetch/types/IRequestInit.d.ts +21 -0
  56. package/lib/fetch/types/IRequestInit.js.map +1 -0
  57. package/lib/fetch/types/IRequestRedirect.d.ts +2 -0
  58. package/lib/fetch/types/IRequestRedirect.js +3 -0
  59. package/lib/fetch/types/IRequestRedirect.js.map +1 -0
  60. package/lib/fetch/types/IRequestReferrerPolicy.d.ts +2 -0
  61. package/lib/fetch/types/IRequestReferrerPolicy.js +3 -0
  62. package/lib/fetch/types/IRequestReferrerPolicy.js.map +1 -0
  63. package/lib/fetch/types/IResponse.d.ts +27 -0
  64. package/lib/fetch/{IResponse.js.map → types/IResponse.js.map} +1 -1
  65. package/lib/fetch/types/IResponseBody.d.ts +7 -0
  66. package/lib/fetch/types/IResponseBody.js +3 -0
  67. package/lib/fetch/types/IResponseBody.js.map +1 -0
  68. package/lib/fetch/types/IResponseInit.d.ts +9 -0
  69. package/lib/fetch/types/IResponseInit.js.map +1 -0
  70. package/lib/fetch/utilities/FetchBodyUtility.d.ts +44 -0
  71. package/lib/fetch/utilities/FetchBodyUtility.js +156 -0
  72. package/lib/fetch/utilities/FetchBodyUtility.js.map +1 -0
  73. package/lib/fetch/utilities/FetchCORSUtility.d.ts +12 -0
  74. package/lib/fetch/utilities/FetchCORSUtility.js +20 -0
  75. package/lib/fetch/utilities/FetchCORSUtility.js.map +1 -0
  76. package/lib/fetch/utilities/FetchRequestHeaderUtility.d.ts +12 -0
  77. package/lib/fetch/utilities/FetchRequestHeaderUtility.js +45 -0
  78. package/lib/fetch/utilities/FetchRequestHeaderUtility.js.map +1 -0
  79. package/lib/fetch/utilities/FetchRequestReferrerUtility.d.ts +55 -0
  80. package/lib/fetch/utilities/FetchRequestReferrerUtility.js +194 -0
  81. package/lib/fetch/utilities/FetchRequestReferrerUtility.js.map +1 -0
  82. package/lib/fetch/utilities/FetchRequestValidationUtility.d.ts +38 -0
  83. package/lib/fetch/utilities/FetchRequestValidationUtility.js +70 -0
  84. package/lib/fetch/utilities/FetchRequestValidationUtility.js.map +1 -0
  85. package/lib/file/Blob.d.ts +2 -2
  86. package/lib/file/Blob.js +1 -1
  87. package/lib/file/Blob.js.map +1 -1
  88. package/lib/file/File.d.ts +2 -1
  89. package/lib/file/File.js.map +1 -1
  90. package/lib/form-data/FormData.d.ts +98 -0
  91. package/lib/form-data/FormData.js +212 -0
  92. package/lib/form-data/FormData.js.map +1 -0
  93. package/lib/index.d.ts +14 -1
  94. package/lib/index.js +20 -2
  95. package/lib/index.js.map +1 -1
  96. package/lib/nodes/document/Document.d.ts +5 -17
  97. package/lib/nodes/document/Document.js +11 -54
  98. package/lib/nodes/document/Document.js.map +1 -1
  99. package/lib/nodes/document/IDocument.d.ts +1 -1
  100. package/lib/nodes/document-fragment/DocumentFragment.d.ts +3 -14
  101. package/lib/nodes/document-fragment/DocumentFragment.js +7 -51
  102. package/lib/nodes/document-fragment/DocumentFragment.js.map +1 -1
  103. package/lib/nodes/document-fragment/IDocumentFragment.d.ts +2 -1
  104. package/lib/nodes/element/Element.d.ts +8 -8
  105. package/lib/nodes/element/Element.js +28 -45
  106. package/lib/nodes/element/Element.js.map +1 -1
  107. package/lib/nodes/element/ElementUtility.d.ts +32 -0
  108. package/lib/nodes/element/ElementUtility.js +105 -0
  109. package/lib/nodes/element/ElementUtility.js.map +1 -0
  110. package/lib/nodes/element/HTMLCollection.d.ts +26 -3
  111. package/lib/nodes/element/HTMLCollection.js +51 -0
  112. package/lib/nodes/element/HTMLCollection.js.map +1 -1
  113. package/lib/nodes/element/IHTMLCollection.d.ts +9 -2
  114. package/lib/nodes/html-anchor-element/HTMLAnchorElement.js +24 -24
  115. package/lib/nodes/html-anchor-element/HTMLAnchorElement.js.map +1 -1
  116. package/lib/nodes/html-base-element/HTMLBaseElement.js +4 -4
  117. package/lib/nodes/html-base-element/HTMLBaseElement.js.map +1 -1
  118. package/lib/nodes/html-button-element/HTMLButtonElement.d.ts +84 -3
  119. package/lib/nodes/html-button-element/HTMLButtonElement.js +183 -10
  120. package/lib/nodes/html-button-element/HTMLButtonElement.js.map +1 -1
  121. package/lib/nodes/html-button-element/IHTMLButtonElement.d.ts +28 -2
  122. package/lib/nodes/html-dialog-element/HTMLDialogElement.js +3 -3
  123. package/lib/nodes/html-dialog-element/HTMLDialogElement.js.map +1 -1
  124. package/lib/nodes/html-element/HTMLElement.js +12 -12
  125. package/lib/nodes/html-element/HTMLElement.js.map +1 -1
  126. package/lib/nodes/html-form-element/HTMLFormControlsCollection.d.ts +32 -0
  127. package/lib/nodes/html-form-element/HTMLFormControlsCollection.js +58 -0
  128. package/lib/nodes/html-form-element/HTMLFormControlsCollection.js.map +1 -0
  129. package/lib/nodes/html-form-element/HTMLFormElement.d.ts +37 -17
  130. package/lib/nodes/html-form-element/HTMLFormElement.js +128 -37
  131. package/lib/nodes/html-form-element/HTMLFormElement.js.map +1 -1
  132. package/lib/nodes/html-form-element/IHTMLFormControlsCollection.d.ts +25 -0
  133. package/lib/nodes/html-form-element/IHTMLFormControlsCollection.js +3 -0
  134. package/lib/nodes/html-form-element/IHTMLFormControlsCollection.js.map +1 -0
  135. package/lib/nodes/html-form-element/IHTMLFormElement.d.ts +16 -6
  136. package/lib/nodes/html-form-element/IRadioNodeList.d.ts +15 -0
  137. package/lib/nodes/html-form-element/IRadioNodeList.js +3 -0
  138. package/lib/nodes/html-form-element/IRadioNodeList.js.map +1 -0
  139. package/lib/nodes/html-form-element/RadioNodeList.d.ts +16 -0
  140. package/lib/nodes/html-form-element/RadioNodeList.js +28 -0
  141. package/lib/nodes/html-form-element/RadioNodeList.js.map +1 -0
  142. package/lib/nodes/html-image-element/HTMLImageElement.js +19 -19
  143. package/lib/nodes/html-image-element/HTMLImageElement.js.map +1 -1
  144. package/lib/nodes/html-input-element/HTMLInputElement.d.ts +43 -19
  145. package/lib/nodes/html-input-element/HTMLInputElement.js +206 -111
  146. package/lib/nodes/html-input-element/HTMLInputElement.js.map +1 -1
  147. package/lib/nodes/html-input-element/IHTMLInputElement.d.ts +14 -1
  148. package/lib/nodes/html-label-element/HTMLLabelElement.js +3 -7
  149. package/lib/nodes/html-label-element/HTMLLabelElement.js.map +1 -1
  150. package/lib/nodes/html-link-element/HTMLLinkElement.js +21 -21
  151. package/lib/nodes/html-link-element/HTMLLinkElement.js.map +1 -1
  152. package/lib/nodes/html-media-element/HTMLMediaElement.js +21 -21
  153. package/lib/nodes/html-media-element/HTMLMediaElement.js.map +1 -1
  154. package/lib/nodes/html-meta-element/HTMLMetaElement.js +8 -8
  155. package/lib/nodes/html-meta-element/HTMLMetaElement.js.map +1 -1
  156. package/lib/nodes/html-opt-group-element/HTMLOptGroupElement.js +6 -6
  157. package/lib/nodes/html-opt-group-element/HTMLOptGroupElement.js.map +1 -1
  158. package/lib/nodes/html-option-element/HTMLOptionElement.d.ts +3 -4
  159. package/lib/nodes/html-option-element/HTMLOptionElement.js +26 -29
  160. package/lib/nodes/html-option-element/HTMLOptionElement.js.map +1 -1
  161. package/lib/nodes/html-script-element/HTMLScriptElement.js +16 -16
  162. package/lib/nodes/html-script-element/HTMLScriptElement.js.map +1 -1
  163. package/lib/nodes/html-script-element/ScriptUtility.js +5 -5
  164. package/lib/nodes/html-script-element/ScriptUtility.js.map +1 -1
  165. package/lib/nodes/{html-option-element → html-select-element}/HTMLOptionsCollection.d.ts +5 -6
  166. package/lib/nodes/{html-option-element → html-select-element}/HTMLOptionsCollection.js.map +1 -1
  167. package/lib/nodes/html-select-element/HTMLSelectElement.d.ts +42 -41
  168. package/lib/nodes/html-select-element/HTMLSelectElement.js +134 -138
  169. package/lib/nodes/html-select-element/HTMLSelectElement.js.map +1 -1
  170. package/lib/nodes/{html-option-element → html-select-element}/IHTMLOptionsCollection.d.ts +4 -5
  171. package/lib/nodes/html-select-element/IHTMLOptionsCollection.js.map +1 -0
  172. package/lib/nodes/html-select-element/IHTMLSelectElement.d.ts +22 -2
  173. package/lib/nodes/html-slot-element/HTMLSlotElement.js +2 -2
  174. package/lib/nodes/html-slot-element/HTMLSlotElement.js.map +1 -1
  175. package/lib/nodes/html-style-element/HTMLStyleElement.js +7 -7
  176. package/lib/nodes/html-style-element/HTMLStyleElement.js.map +1 -1
  177. package/lib/nodes/html-text-area-element/HTMLTextAreaElement.d.ts +55 -2
  178. package/lib/nodes/html-text-area-element/HTMLTextAreaElement.js +150 -40
  179. package/lib/nodes/html-text-area-element/HTMLTextAreaElement.js.map +1 -1
  180. package/lib/nodes/html-text-area-element/IHTMLTextAreaElement.d.ts +16 -0
  181. package/lib/nodes/node/Node.d.ts +12 -1
  182. package/lib/nodes/node/Node.js +50 -4
  183. package/lib/nodes/node/Node.js.map +1 -1
  184. package/lib/nodes/node/NodeList.d.ts +2 -3
  185. package/lib/nodes/node/NodeList.js.map +1 -1
  186. package/lib/nodes/parent-node/IParentNode.d.ts +4 -4
  187. package/lib/nodes/parent-node/ParentNodeUtility.d.ts +3 -3
  188. package/lib/nodes/parent-node/ParentNodeUtility.js +13 -11
  189. package/lib/nodes/parent-node/ParentNodeUtility.js.map +1 -1
  190. package/lib/nodes/text/Text.d.ts +13 -0
  191. package/lib/nodes/text/Text.js +30 -0
  192. package/lib/nodes/text/Text.js.map +1 -1
  193. package/lib/query-selector/QuerySelector.js +2 -2
  194. package/lib/query-selector/QuerySelector.js.map +1 -1
  195. package/lib/query-selector/SelectorItem.js +2 -0
  196. package/lib/query-selector/SelectorItem.js.map +1 -1
  197. package/lib/validity-state/ValidityState.d.ts +87 -0
  198. package/lib/validity-state/ValidityState.js +171 -0
  199. package/lib/validity-state/ValidityState.js.map +1 -0
  200. package/lib/window/GlobalWindow.d.ts +0 -8
  201. package/lib/window/GlobalWindow.js +0 -2
  202. package/lib/window/GlobalWindow.js.map +1 -1
  203. package/lib/window/INodeJSGlobal.d.ts +71 -0
  204. package/lib/window/INodeJSGlobal.js +2 -0
  205. package/lib/window/INodeJSGlobal.js.map +1 -0
  206. package/lib/window/IWindow.d.ts +30 -10
  207. package/lib/window/Window.d.ts +36 -20
  208. package/lib/window/Window.js +16 -9
  209. package/lib/window/Window.js.map +1 -1
  210. package/lib/xml-http-request/XMLHttpRequest.js +20 -12
  211. package/lib/xml-http-request/XMLHttpRequest.js.map +1 -1
  212. package/lib/xml-parser/XMLParser.js +1 -1
  213. package/lib/xml-parser/XMLParser.js.map +1 -1
  214. package/package.json +2 -3
  215. package/src/cookie/CookieJar.ts +1 -1
  216. package/src/dom-token-list/DOMTokenList.ts +24 -20
  217. package/src/event/EventTarget.ts +7 -3
  218. package/src/exception/DOMExceptionNameEnum.ts +5 -1
  219. package/src/fetch/AbortController.ts +26 -0
  220. package/src/fetch/AbortSignal.ts +44 -0
  221. package/src/fetch/Fetch.ts +666 -0
  222. package/src/fetch/Headers.ts +151 -3
  223. package/src/fetch/Request.ts +226 -94
  224. package/src/fetch/{ResourceFetchHandler.ts → ResourceFetch.ts} +3 -3
  225. package/src/fetch/Response.ts +252 -89
  226. package/src/fetch/data-uri/DataURIParser.ts +66 -0
  227. package/src/fetch/multipart/MultipartFormDataParser.ts +113 -0
  228. package/src/fetch/multipart/MultipartReader.ts +217 -0
  229. package/src/fetch/types/IHeaders.ts +80 -0
  230. package/src/fetch/types/IRequest.ts +65 -0
  231. package/src/fetch/types/IRequestBody.ts +15 -0
  232. package/src/fetch/types/IRequestCredentials.ts +2 -0
  233. package/src/fetch/types/IRequestInfo.ts +6 -0
  234. package/src/fetch/types/IRequestInit.ts +21 -0
  235. package/src/fetch/types/IRequestRedirect.ts +3 -0
  236. package/src/fetch/types/IRequestReferrerPolicy.ts +11 -0
  237. package/src/fetch/types/IResponse.ts +27 -0
  238. package/src/fetch/types/IResponseBody.ts +15 -0
  239. package/src/fetch/types/IResponseInit.ts +10 -0
  240. package/src/fetch/utilities/FetchBodyUtility.ts +175 -0
  241. package/src/fetch/utilities/FetchCORSUtility.ts +18 -0
  242. package/src/fetch/utilities/FetchRequestHeaderUtility.ts +47 -0
  243. package/src/fetch/utilities/FetchRequestReferrerUtility.ts +241 -0
  244. package/src/fetch/utilities/FetchRequestValidationUtility.ts +82 -0
  245. package/src/file/Blob.ts +2 -2
  246. package/src/file/File.ts +5 -1
  247. package/src/form-data/FormData.ts +237 -0
  248. package/src/index.ts +27 -1
  249. package/src/nodes/document/Document.ts +23 -64
  250. package/src/nodes/document/IDocument.ts +1 -1
  251. package/src/nodes/document-fragment/DocumentFragment.ts +9 -59
  252. package/src/nodes/document-fragment/IDocumentFragment.ts +2 -1
  253. package/src/nodes/element/Element.ts +43 -56
  254. package/src/nodes/element/ElementUtility.ts +137 -0
  255. package/src/nodes/element/HTMLCollection.ts +60 -3
  256. package/src/nodes/element/IHTMLCollection.ts +10 -2
  257. package/src/nodes/html-anchor-element/HTMLAnchorElement.ts +24 -24
  258. package/src/nodes/html-base-element/HTMLBaseElement.ts +4 -4
  259. package/src/nodes/html-button-element/HTMLButtonElement.ts +213 -10
  260. package/src/nodes/html-button-element/IHTMLButtonElement.ts +31 -2
  261. package/src/nodes/html-dialog-element/HTMLDialogElement.ts +3 -3
  262. package/src/nodes/html-element/HTMLElement.ts +12 -12
  263. package/src/nodes/html-form-element/HTMLFormControlsCollection.ts +76 -0
  264. package/src/nodes/html-form-element/HTMLFormElement.ts +147 -41
  265. package/src/nodes/html-form-element/IHTMLFormControlsCollection.ts +45 -0
  266. package/src/nodes/html-form-element/IHTMLFormElement.ts +17 -6
  267. package/src/nodes/html-form-element/IRadioNodeList.ts +16 -0
  268. package/src/nodes/html-form-element/RadioNodeList.ts +24 -0
  269. package/src/nodes/html-image-element/HTMLImageElement.ts +19 -19
  270. package/src/nodes/html-input-element/HTMLInputElement.ts +232 -113
  271. package/src/nodes/html-input-element/IHTMLInputElement.ts +20 -1
  272. package/src/nodes/html-label-element/HTMLLabelElement.ts +3 -7
  273. package/src/nodes/html-link-element/HTMLLinkElement.ts +21 -21
  274. package/src/nodes/html-media-element/HTMLMediaElement.ts +21 -21
  275. package/src/nodes/html-meta-element/HTMLMetaElement.ts +8 -8
  276. package/src/nodes/html-opt-group-element/HTMLOptGroupElement.ts +6 -6
  277. package/src/nodes/html-option-element/HTMLOptionElement.ts +29 -30
  278. package/src/nodes/html-script-element/HTMLScriptElement.ts +16 -16
  279. package/src/nodes/html-script-element/ScriptUtility.ts +5 -5
  280. package/src/nodes/{html-option-element → html-select-element}/HTMLOptionsCollection.ts +5 -9
  281. package/src/nodes/html-select-element/HTMLSelectElement.ts +159 -170
  282. package/src/nodes/{html-option-element → html-select-element}/IHTMLOptionsCollection.ts +4 -8
  283. package/src/nodes/html-select-element/IHTMLSelectElement.ts +25 -2
  284. package/src/nodes/html-slot-element/HTMLSlotElement.ts +2 -2
  285. package/src/nodes/html-style-element/HTMLStyleElement.ts +7 -7
  286. package/src/nodes/html-text-area-element/HTMLTextAreaElement.ts +174 -41
  287. package/src/nodes/html-text-area-element/IHTMLTextAreaElement.ts +18 -0
  288. package/src/nodes/node/Node.ts +61 -6
  289. package/src/nodes/node/NodeList.ts +2 -3
  290. package/src/nodes/parent-node/IParentNode.ts +7 -4
  291. package/src/nodes/parent-node/ParentNodeUtility.ts +25 -15
  292. package/src/nodes/text/Text.ts +38 -0
  293. package/src/query-selector/QuerySelector.ts +2 -2
  294. package/src/query-selector/SelectorItem.ts +3 -0
  295. package/src/validity-state/ValidityState.ts +211 -0
  296. package/src/window/GlobalWindow.ts +0 -2
  297. package/src/window/INodeJSGlobal.ts +70 -0
  298. package/src/window/IWindow.ts +32 -10
  299. package/src/window/Window.ts +37 -20
  300. package/src/xml-http-request/XMLHttpRequest.ts +27 -26
  301. package/src/xml-parser/XMLParser.ts +1 -1
  302. package/lib/fetch/FetchHandler.d.ts +0 -18
  303. package/lib/fetch/FetchHandler.js +0 -83
  304. package/lib/fetch/FetchHandler.js.map +0 -1
  305. package/lib/fetch/IAbortSignal.d.ts +0 -16
  306. package/lib/fetch/IAbortSignal.js +0 -4
  307. package/lib/fetch/IAbortSignal.js.map +0 -1
  308. package/lib/fetch/IBody.d.ts +0 -17
  309. package/lib/fetch/IBody.js.map +0 -1
  310. package/lib/fetch/IHeaders.d.ts +0 -18
  311. package/lib/fetch/IHeadersInit.js.map +0 -1
  312. package/lib/fetch/IRequest.d.ts +0 -18
  313. package/lib/fetch/IRequestInit.d.ts +0 -16
  314. package/lib/fetch/IRequestInit.js.map +0 -1
  315. package/lib/fetch/IResponse.d.ts +0 -20
  316. package/lib/fetch/IResponseInit.d.ts +0 -9
  317. package/lib/fetch/IResponseInit.js.map +0 -1
  318. package/lib/fetch/RequestInfo.js +0 -3
  319. package/lib/fetch/RequestInfo.js.map +0 -1
  320. package/lib/fetch/ResourceFetchHandler.js.map +0 -1
  321. package/lib/form-data/IFormData.d.ts +0 -32
  322. package/lib/form-data/IFormData.js +0 -3
  323. package/lib/form-data/IFormData.js.map +0 -1
  324. package/lib/location/RelativeURL.d.ts +0 -15
  325. package/lib/location/RelativeURL.js +0 -19
  326. package/lib/location/RelativeURL.js.map +0 -1
  327. package/lib/nodes/element/HTMLCollectionFactory.d.ts +0 -21
  328. package/lib/nodes/element/HTMLCollectionFactory.js +0 -31
  329. package/lib/nodes/element/HTMLCollectionFactory.js.map +0 -1
  330. package/lib/nodes/html-option-element/IHTMLOptionsCollection.js.map +0 -1
  331. package/lib/nodes/node/NodeListFactory.d.ts +0 -21
  332. package/lib/nodes/node/NodeListFactory.js +0 -31
  333. package/lib/nodes/node/NodeListFactory.js.map +0 -1
  334. package/lib/nodes/validity-state/ValidityState.d.ts +0 -52
  335. package/lib/nodes/validity-state/ValidityState.js +0 -81
  336. package/lib/nodes/validity-state/ValidityState.js.map +0 -1
  337. package/src/fetch/FetchHandler.ts +0 -90
  338. package/src/fetch/IAbortSignal.ts +0 -34
  339. package/src/fetch/IBody.ts +0 -18
  340. package/src/fetch/IHeaders.ts +0 -18
  341. package/src/fetch/IRequest.ts +0 -59
  342. package/src/fetch/IRequestInit.ts +0 -41
  343. package/src/fetch/IResponse.ts +0 -22
  344. package/src/fetch/IResponseInit.ts +0 -10
  345. package/src/fetch/RequestInfo.ts +0 -6
  346. package/src/form-data/IFormData.ts +0 -33
  347. package/src/location/RelativeURL.ts +0 -17
  348. package/src/nodes/element/HTMLCollectionFactory.ts +0 -31
  349. package/src/nodes/node/NodeListFactory.ts +0 -31
  350. package/src/nodes/validity-state/ValidityState.ts +0 -84
  351. /package/lib/fetch/{IHeaders.js → types/IHeaders.js} +0 -0
  352. /package/lib/fetch/{IHeadersInit.d.ts → types/IHeadersInit.d.ts} +0 -0
  353. /package/lib/fetch/{IHeadersInit.js → types/IHeadersInit.js} +0 -0
  354. /package/lib/fetch/{IRequest.js → types/IRequest.js} +0 -0
  355. /package/lib/fetch/{IRequestInit.js → types/IRequestInit.js} +0 -0
  356. /package/lib/fetch/{IResponse.js → types/IResponse.js} +0 -0
  357. /package/lib/fetch/{IResponseInit.js → types/IResponseInit.js} +0 -0
  358. /package/lib/nodes/{html-option-element → html-select-element}/HTMLOptionsCollection.js +0 -0
  359. /package/lib/nodes/{html-option-element → html-select-element}/IHTMLOptionsCollection.js +0 -0
  360. /package/src/fetch/{IHeadersInit.ts → types/IHeadersInit.ts} +0 -0
@@ -1,12 +1,20 @@
1
1
  import Event from '../../event/Event';
2
2
  import DOMException from '../../exception/DOMException';
3
3
  import DOMExceptionNameEnum from '../../exception/DOMExceptionNameEnum';
4
+ import IAttr from '../attr/IAttr';
4
5
  import HTMLElement from '../html-element/HTMLElement';
5
- import IHTMLElement from '../html-element/IHTMLElement';
6
+ import HTMLFormElement from '../html-form-element/HTMLFormElement';
6
7
  import IHTMLFormElement from '../html-form-element/IHTMLFormElement';
7
8
  import HTMLInputElementSelectionDirectionEnum from '../html-input-element/HTMLInputElementSelectionDirectionEnum';
8
9
  import HTMLInputElementSelectionModeEnum from '../html-input-element/HTMLInputElementSelectionModeEnum';
10
+ import INode from '../node/INode';
11
+ import ValidityState from '../../validity-state/ValidityState';
9
12
  import IHTMLTextAreaElement from './IHTMLTextAreaElement';
13
+ import INodeList from '../node/INodeList';
14
+ import IHTMLLabelElement from '../html-label-element/IHTMLLabelElement';
15
+ import IDocument from '../document/IDocument';
16
+ import IShadowRoot from '../shadow-root/IShadowRoot';
17
+ import NodeList from '../node/NodeList';
10
18
 
11
19
  /**
12
20
  * HTML Text Area Element.
@@ -16,7 +24,8 @@ import IHTMLTextAreaElement from './IHTMLTextAreaElement';
16
24
  */
17
25
  export default class HTMLTextAreaElement extends HTMLElement implements IHTMLTextAreaElement {
18
26
  public readonly type = 'textarea';
19
- public defaultValue = '';
27
+ public readonly validationMessage = '';
28
+ public readonly validity = new ValidityState(this);
20
29
 
21
30
  // Events
22
31
  public oninput: (event: Event) => void | null = null;
@@ -26,6 +35,25 @@ export default class HTMLTextAreaElement extends HTMLElement implements IHTMLTex
26
35
  public _selectionStart = null;
27
36
  public _selectionEnd = null;
28
37
  public _selectionDirection = HTMLInputElementSelectionDirectionEnum.none;
38
+ public _textAreaNode: HTMLTextAreaElement = this;
39
+
40
+ /**
41
+ * Returns the default value.
42
+ *
43
+ * @returns Default value.
44
+ */
45
+ public get defaultValue(): string {
46
+ return this.textContent;
47
+ }
48
+
49
+ /**
50
+ * Sets the default value.
51
+ *
52
+ * @param defaultValue Default value.
53
+ */
54
+ public set defaultValue(defaultValue: string) {
55
+ this.textContent = defaultValue;
56
+ }
29
57
 
30
58
  /**
31
59
  * Returns minlength.
@@ -33,7 +61,7 @@ export default class HTMLTextAreaElement extends HTMLElement implements IHTMLTex
33
61
  * @returns Min length.
34
62
  */
35
63
  public get minLength(): number {
36
- const minLength = this.getAttributeNS(null, 'minlength');
64
+ const minLength = this.getAttribute('minlength');
37
65
  if (minLength !== null) {
38
66
  return parseInt(minLength);
39
67
  }
@@ -46,7 +74,7 @@ export default class HTMLTextAreaElement extends HTMLElement implements IHTMLTex
46
74
  * @param minLength Min length.
47
75
  */
48
76
  public set minLength(minlength: number) {
49
- this.setAttributeNS(null, 'minlength', String(minlength));
77
+ this.setAttribute('minlength', String(minlength));
50
78
  }
51
79
 
52
80
  /**
@@ -55,7 +83,7 @@ export default class HTMLTextAreaElement extends HTMLElement implements IHTMLTex
55
83
  * @returns Max length.
56
84
  */
57
85
  public get maxLength(): number {
58
- const maxLength = this.getAttributeNS(null, 'maxlength');
86
+ const maxLength = this.getAttribute('maxlength');
59
87
  if (maxLength !== null) {
60
88
  return parseInt(maxLength);
61
89
  }
@@ -68,7 +96,7 @@ export default class HTMLTextAreaElement extends HTMLElement implements IHTMLTex
68
96
  * @param maxlength Max length.
69
97
  */
70
98
  public set maxLength(maxLength: number) {
71
- this.setAttributeNS(null, 'maxlength', String(maxLength));
99
+ this.setAttribute('maxlength', String(maxLength));
72
100
  }
73
101
 
74
102
  /**
@@ -77,7 +105,7 @@ export default class HTMLTextAreaElement extends HTMLElement implements IHTMLTex
77
105
  * @returns Name.
78
106
  */
79
107
  public get name(): string {
80
- return this.getAttributeNS(null, 'name') || '';
108
+ return this.getAttribute('name') || '';
81
109
  }
82
110
 
83
111
  /**
@@ -86,7 +114,7 @@ export default class HTMLTextAreaElement extends HTMLElement implements IHTMLTex
86
114
  * @param name Name.
87
115
  */
88
116
  public set name(name: string) {
89
- this.setAttributeNS(null, 'name', name);
117
+ this.setAttribute('name', name);
90
118
  }
91
119
 
92
120
  /**
@@ -95,7 +123,7 @@ export default class HTMLTextAreaElement extends HTMLElement implements IHTMLTex
95
123
  * @returns Placeholder.
96
124
  */
97
125
  public get placeholder(): string {
98
- return this.getAttributeNS(null, 'placeholder') || '';
126
+ return this.getAttribute('placeholder') || '';
99
127
  }
100
128
 
101
129
  /**
@@ -104,7 +132,7 @@ export default class HTMLTextAreaElement extends HTMLElement implements IHTMLTex
104
132
  * @param placeholder Placeholder.
105
133
  */
106
134
  public set placeholder(placeholder: string) {
107
- this.setAttributeNS(null, 'placeholder', placeholder);
135
+ this.setAttribute('placeholder', placeholder);
108
136
  }
109
137
 
110
138
  /**
@@ -113,7 +141,7 @@ export default class HTMLTextAreaElement extends HTMLElement implements IHTMLTex
113
141
  * @returns Inputmode.
114
142
  */
115
143
  public get inputmode(): string {
116
- return this.getAttributeNS(null, 'inputmode') || '';
144
+ return this.getAttribute('inputmode') || '';
117
145
  }
118
146
 
119
147
  /**
@@ -122,7 +150,7 @@ export default class HTMLTextAreaElement extends HTMLElement implements IHTMLTex
122
150
  * @param inputmode Inputmode.
123
151
  */
124
152
  public set inputmode(inputmode: string) {
125
- this.setAttributeNS(null, 'inputmode', inputmode);
153
+ this.setAttribute('inputmode', inputmode);
126
154
  }
127
155
 
128
156
  /**
@@ -131,7 +159,7 @@ export default class HTMLTextAreaElement extends HTMLElement implements IHTMLTex
131
159
  * @returns Cols.
132
160
  */
133
161
  public get cols(): string {
134
- return this.getAttributeNS(null, 'cols') || '';
162
+ return this.getAttribute('cols') || '';
135
163
  }
136
164
 
137
165
  /**
@@ -140,7 +168,7 @@ export default class HTMLTextAreaElement extends HTMLElement implements IHTMLTex
140
168
  * @param cols Cols.
141
169
  */
142
170
  public set cols(cols: string) {
143
- this.setAttributeNS(null, 'cols', cols);
171
+ this.setAttribute('cols', cols);
144
172
  }
145
173
 
146
174
  /**
@@ -149,7 +177,7 @@ export default class HTMLTextAreaElement extends HTMLElement implements IHTMLTex
149
177
  * @returns Rows.
150
178
  */
151
179
  public get rows(): string {
152
- return this.getAttributeNS(null, 'rows') || '';
180
+ return this.getAttribute('rows') || '';
153
181
  }
154
182
 
155
183
  /**
@@ -158,7 +186,7 @@ export default class HTMLTextAreaElement extends HTMLElement implements IHTMLTex
158
186
  * @param rows Rows.
159
187
  */
160
188
  public set rows(rows: string) {
161
- this.setAttributeNS(null, 'rows', rows);
189
+ this.setAttribute('rows', rows);
162
190
  }
163
191
 
164
192
  /**
@@ -167,7 +195,7 @@ export default class HTMLTextAreaElement extends HTMLElement implements IHTMLTex
167
195
  * @returns Autocomplete.
168
196
  */
169
197
  public get autocomplete(): string {
170
- return this.getAttributeNS(null, 'autocomplete') || '';
198
+ return this.getAttribute('autocomplete') || '';
171
199
  }
172
200
 
173
201
  /**
@@ -176,7 +204,7 @@ export default class HTMLTextAreaElement extends HTMLElement implements IHTMLTex
176
204
  * @param autocomplete Autocomplete.
177
205
  */
178
206
  public set autocomplete(autocomplete: string) {
179
- this.setAttributeNS(null, 'autocomplete', autocomplete);
207
+ this.setAttribute('autocomplete', autocomplete);
180
208
  }
181
209
 
182
210
  /**
@@ -185,7 +213,7 @@ export default class HTMLTextAreaElement extends HTMLElement implements IHTMLTex
185
213
  * @returns ReadOnly.
186
214
  */
187
215
  public get readOnly(): boolean {
188
- return this.getAttributeNS(null, 'readonly') !== null;
216
+ return this.getAttribute('readonly') !== null;
189
217
  }
190
218
 
191
219
  /**
@@ -195,9 +223,9 @@ export default class HTMLTextAreaElement extends HTMLElement implements IHTMLTex
195
223
  */
196
224
  public set readOnly(readOnly: boolean) {
197
225
  if (!readOnly) {
198
- this.removeAttributeNS(null, 'readonly');
226
+ this.removeAttribute('readonly');
199
227
  } else {
200
- this.setAttributeNS(null, 'readonly', '');
228
+ this.setAttribute('readonly', '');
201
229
  }
202
230
  }
203
231
 
@@ -207,7 +235,7 @@ export default class HTMLTextAreaElement extends HTMLElement implements IHTMLTex
207
235
  * @returns Disabled.
208
236
  */
209
237
  public get disabled(): boolean {
210
- return this.getAttributeNS(null, 'disabled') !== null;
238
+ return this.getAttribute('disabled') !== null;
211
239
  }
212
240
 
213
241
  /**
@@ -217,9 +245,9 @@ export default class HTMLTextAreaElement extends HTMLElement implements IHTMLTex
217
245
  */
218
246
  public set disabled(disabled: boolean) {
219
247
  if (!disabled) {
220
- this.removeAttributeNS(null, 'disabled');
248
+ this.removeAttribute('disabled');
221
249
  } else {
222
- this.setAttributeNS(null, 'disabled', '');
250
+ this.setAttribute('disabled', '');
223
251
  }
224
252
  }
225
253
 
@@ -229,7 +257,7 @@ export default class HTMLTextAreaElement extends HTMLElement implements IHTMLTex
229
257
  * @returns Autofocus.
230
258
  */
231
259
  public get autofocus(): boolean {
232
- return this.getAttributeNS(null, 'autofocus') !== null;
260
+ return this.getAttribute('autofocus') !== null;
233
261
  }
234
262
 
235
263
  /**
@@ -239,9 +267,9 @@ export default class HTMLTextAreaElement extends HTMLElement implements IHTMLTex
239
267
  */
240
268
  public set autofocus(autofocus: boolean) {
241
269
  if (!autofocus) {
242
- this.removeAttributeNS(null, 'autofocus');
270
+ this.removeAttribute('autofocus');
243
271
  } else {
244
- this.setAttributeNS(null, 'autofocus', '');
272
+ this.setAttribute('autofocus', '');
245
273
  }
246
274
  }
247
275
 
@@ -251,7 +279,7 @@ export default class HTMLTextAreaElement extends HTMLElement implements IHTMLTex
251
279
  * @returns Required.
252
280
  */
253
281
  public get required(): boolean {
254
- return this.getAttributeNS(null, 'required') !== null;
282
+ return this.getAttribute('required') !== null;
255
283
  }
256
284
 
257
285
  /**
@@ -261,9 +289,9 @@ export default class HTMLTextAreaElement extends HTMLElement implements IHTMLTex
261
289
  */
262
290
  public set required(required: boolean) {
263
291
  if (!required) {
264
- this.removeAttributeNS(null, 'required');
292
+ this.removeAttribute('required');
265
293
  } else {
266
- this.setAttributeNS(null, 'required', '');
294
+ this.setAttribute('required', '');
267
295
  }
268
296
  }
269
297
 
@@ -274,7 +302,7 @@ export default class HTMLTextAreaElement extends HTMLElement implements IHTMLTex
274
302
  */
275
303
  public get value(): string {
276
304
  if (this._value === null) {
277
- return this.getAttributeNS(null, 'value') || '';
305
+ return this.textContent;
278
306
  }
279
307
 
280
308
  return this._value;
@@ -355,7 +383,7 @@ export default class HTMLTextAreaElement extends HTMLElement implements IHTMLTex
355
383
  * @param direction Direction.
356
384
  */
357
385
  public set selectionDirection(direction: string) {
358
- this.setSelectionRange(this._selectionStart, this._selectionEnd, direction);
386
+ this.setSelectionRange(this.selectionStart, this.selectionEnd, direction);
359
387
  }
360
388
 
361
389
  /**
@@ -364,11 +392,7 @@ export default class HTMLTextAreaElement extends HTMLElement implements IHTMLTex
364
392
  * @returns Form.
365
393
  */
366
394
  public get form(): IHTMLFormElement {
367
- let parent = <IHTMLElement>this.parentNode;
368
- while (parent && parent.tagName !== 'FORM') {
369
- parent = <IHTMLElement>parent.parentNode;
370
- }
371
- return <IHTMLFormElement>parent;
395
+ return <IHTMLFormElement>this._formNode;
372
396
  }
373
397
 
374
398
  /**
@@ -380,6 +404,31 @@ export default class HTMLTextAreaElement extends HTMLElement implements IHTMLTex
380
404
  return this.value.length;
381
405
  }
382
406
 
407
+ /**
408
+ * Returns the associated label elements.
409
+ *
410
+ * @returns Label elements.
411
+ */
412
+ public get labels(): INodeList<IHTMLLabelElement> {
413
+ const id = this.id;
414
+ if (id) {
415
+ const rootNode = <IDocument | IShadowRoot>this.getRootNode();
416
+ const labels = rootNode.querySelectorAll(`label[for="${id}"]`);
417
+
418
+ let parent = this.parentNode;
419
+ while (parent) {
420
+ if (parent['tagName'] === 'LABEL') {
421
+ labels.push(<IHTMLLabelElement>parent);
422
+ break;
423
+ }
424
+ parent = parent.parentNode;
425
+ }
426
+
427
+ return <INodeList<IHTMLLabelElement>>labels;
428
+ }
429
+ return new NodeList<IHTMLLabelElement>();
430
+ }
431
+
383
432
  /**
384
433
  * Set selection range.
385
434
  *
@@ -389,7 +438,7 @@ export default class HTMLTextAreaElement extends HTMLElement implements IHTMLTex
389
438
  */
390
439
  public setSelectionRange(start: number, end: number, direction = 'none'): void {
391
440
  this._selectionEnd = Math.min(end, this.value.length);
392
- this._selectionStart = Math.min(start, this._selectionEnd);
441
+ this._selectionStart = Math.min(start, this.selectionEnd);
393
442
  this._selectionDirection =
394
443
  direction === HTMLInputElementSelectionDirectionEnum.forward ||
395
444
  direction === HTMLInputElementSelectionDirectionEnum.backward
@@ -468,13 +517,35 @@ export default class HTMLTextAreaElement extends HTMLElement implements IHTMLTex
468
517
  }
469
518
  }
470
519
 
520
+ /**
521
+ * Sets validation message.
522
+ *
523
+ * @param message Message.
524
+ */
525
+ public setCustomValidity(message: string): void {
526
+ (<string>this.validationMessage) = String(message);
527
+ }
528
+
471
529
  /**
472
530
  * Checks validity.
473
531
  *
474
- * @returns "true" if validation does'nt fail.
532
+ * @returns "true" if the field is valid.
475
533
  */
476
534
  public checkValidity(): boolean {
477
- return true;
535
+ const valid = this.disabled || this.readOnly || this.validity.valid;
536
+ if (!valid) {
537
+ this.dispatchEvent(new Event('invalid', { bubbles: true, cancelable: true }));
538
+ }
539
+ return valid;
540
+ }
541
+
542
+ /**
543
+ * Reports validity.
544
+ *
545
+ * @returns "true" if the field is valid.
546
+ */
547
+ public reportValidity(): boolean {
548
+ return this.checkValidity();
478
549
  }
479
550
 
480
551
  /**
@@ -491,8 +562,70 @@ export default class HTMLTextAreaElement extends HTMLElement implements IHTMLTex
491
562
  clone._selectionStart = this._selectionStart;
492
563
  clone._selectionEnd = this._selectionEnd;
493
564
  clone._selectionDirection = this._selectionDirection;
494
- clone.defaultValue = this.defaultValue;
495
565
 
496
566
  return clone;
497
567
  }
568
+
569
+ /**
570
+ * Resets selection.
571
+ */
572
+ public _resetSelection(): void {
573
+ if (this._value === null) {
574
+ this._selectionStart = null;
575
+ this._selectionEnd = null;
576
+ this._selectionDirection = HTMLInputElementSelectionDirectionEnum.none;
577
+ }
578
+ }
579
+
580
+ /**
581
+ * @override
582
+ */
583
+ public override setAttributeNode(attribute: IAttr): IAttr {
584
+ const replacedAttribute = super.setAttributeNode(attribute);
585
+ const oldValue = replacedAttribute ? replacedAttribute.value : null;
586
+
587
+ if ((attribute.name === 'id' || attribute.name === 'name') && this._formNode) {
588
+ if (oldValue) {
589
+ (<HTMLFormElement>this._formNode)._removeFormControlItem(this, oldValue);
590
+ }
591
+ if (attribute.value) {
592
+ (<HTMLFormElement>this._formNode)._appendFormControlItem(this, attribute.value);
593
+ }
594
+ }
595
+
596
+ return replacedAttribute;
597
+ }
598
+
599
+ /**
600
+ * @override
601
+ */
602
+ public override removeAttributeNode(attribute: IAttr): IAttr {
603
+ super.removeAttributeNode(attribute);
604
+
605
+ if ((attribute.name === 'id' || attribute.name === 'name') && this._formNode) {
606
+ (<HTMLFormElement>this._formNode)._removeFormControlItem(this, attribute.value);
607
+ }
608
+
609
+ return attribute;
610
+ }
611
+
612
+ /**
613
+ * @override
614
+ */
615
+ public override _connectToNode(parentNode: INode = null): void {
616
+ const oldFormNode = <HTMLFormElement>this._formNode;
617
+
618
+ super._connectToNode(parentNode);
619
+
620
+ if (oldFormNode !== this._formNode) {
621
+ if (oldFormNode) {
622
+ oldFormNode._removeFormControlItem(this, this.name);
623
+ oldFormNode._removeFormControlItem(this, this.id);
624
+ }
625
+ if (this._formNode) {
626
+ (<HTMLFormElement>this._formNode)._appendFormControlItem(this, this.name);
627
+ (<HTMLFormElement>this._formNode)._appendFormControlItem(this, this.id);
628
+ }
629
+ }
630
+ }
498
631
  }
@@ -2,6 +2,8 @@ import Event from '../../event/Event';
2
2
  import IHTMLElement from '../html-element/IHTMLElement';
3
3
  import IHTMLFormElement from '../html-form-element/IHTMLFormElement';
4
4
  import HTMLInputElementSelectionModeEnum from '../html-input-element/HTMLInputElementSelectionModeEnum';
5
+ import IHTMLLabelElement from '../html-label-element/IHTMLLabelElement';
6
+ import INodeList from '../node/INodeList';
5
7
 
6
8
  /**
7
9
  * HTML Text Area Element.
@@ -12,6 +14,8 @@ import HTMLInputElementSelectionModeEnum from '../html-input-element/HTMLInputEl
12
14
  export default interface IHTMLTextAreaElement extends IHTMLElement {
13
15
  readonly type: string;
14
16
  readonly form: IHTMLFormElement;
17
+ readonly validationMessage: string;
18
+ readonly labels: INodeList<IHTMLLabelElement>;
15
19
  defaultValue: string;
16
20
  minLength: number;
17
21
  maxLength: number;
@@ -66,6 +70,20 @@ export default interface IHTMLTextAreaElement extends IHTMLElement {
66
70
  */
67
71
  checkValidity(): boolean;
68
72
 
73
+ /**
74
+ * Reports validity.
75
+ *
76
+ * @returns "true" if the field is valid.
77
+ */
78
+ reportValidity(): boolean;
79
+
80
+ /**
81
+ * Sets validation message.
82
+ *
83
+ * @param message Message.
84
+ */
85
+ setCustomValidity(message: string): void;
86
+
69
87
  /**
70
88
  * Clones a node.
71
89
  *
@@ -8,12 +8,24 @@ import DOMException from '../../exception/DOMException';
8
8
  import IDocument from '../document/IDocument';
9
9
  import IElement from '../element/IElement';
10
10
  import IHTMLBaseElement from '../html-base-element/IHTMLBaseElement';
11
- import INodeList from './INodeList';
12
- import NodeListFactory from './NodeListFactory';
13
11
  import NodeTypeEnum from './NodeTypeEnum';
14
12
  import NodeDocumentPositionEnum from './NodeDocumentPositionEnum';
15
13
  import NodeUtility from './NodeUtility';
16
14
  import IAttr from '../attr/IAttr';
15
+ import NodeList from './NodeList';
16
+ import INodeList from './INodeList';
17
+ import IShadowRoot from '../shadow-root/IShadowRoot';
18
+
19
+ const JSON_CIRCULAR_PROPERTIES = [
20
+ 'ownerDocument',
21
+ 'parentNode',
22
+ 'ownerElement',
23
+ 'defaultView',
24
+ '_rootNode',
25
+ '_formNode',
26
+ '_selectNode',
27
+ '_textAreaNode'
28
+ ];
17
29
 
18
30
  /**
19
31
  * Node.
@@ -58,11 +70,14 @@ export default class Node extends EventTarget implements INode {
58
70
  public readonly ownerDocument: IDocument = null;
59
71
  public readonly parentNode: INode = null;
60
72
  public readonly nodeType: number;
61
- public readonly childNodes: INodeList<INode> = NodeListFactory.create();
73
+ public readonly childNodes: INodeList<INode> = new NodeList<INode>();
62
74
  public readonly isConnected: boolean = false;
63
75
 
64
76
  // Custom Properties (not part of HTML standard)
65
77
  public _rootNode: INode = null;
78
+ public _formNode: INode = null;
79
+ public _selectNode: INode = null;
80
+ public _textAreaNode: INode = null;
66
81
  public _observers: MutationListener[] = [];
67
82
 
68
83
  /**
@@ -485,9 +500,13 @@ export default class Node extends EventTarget implements INode {
485
500
  }
486
501
 
487
502
  // eslint-disable-next-line
488
- if (event.composed && this.nodeType === NodeTypeEnum.documentFragmentNode && (<any>this).host) {
503
+ if (
504
+ event.composed &&
505
+ this.nodeType === NodeTypeEnum.documentFragmentNode &&
506
+ (<IShadowRoot>(<unknown>this)).host
507
+ ) {
489
508
  // eslint-disable-next-line
490
- return (<any>this).host.dispatchEvent(event);
509
+ return (<IShadowRoot>(<unknown>this)).host.dispatchEvent(event);
491
510
  }
492
511
  }
493
512
 
@@ -543,10 +562,25 @@ export default class Node extends EventTarget implements INode {
543
562
  */
544
563
  public _connectToNode(parentNode: INode = null): void {
545
564
  const isConnected = !!parentNode && parentNode.isConnected;
565
+ const formNode = (<Node>this)._formNode;
566
+ const selectNode = (<Node>this)._selectNode;
567
+ const textAreaNode = (<Node>this)._textAreaNode;
546
568
 
547
- if (this.nodeType !== Node.DOCUMENT_FRAGMENT_NODE) {
569
+ if (this.nodeType !== NodeTypeEnum.documentFragmentNode) {
548
570
  (<INode>this.parentNode) = parentNode;
549
571
  (<Node>this)._rootNode = isConnected && parentNode ? (<Node>parentNode)._rootNode : null;
572
+
573
+ if (this['tagName'] !== 'FORM') {
574
+ (<Node>this)._formNode = parentNode ? (<Node>parentNode)._formNode : null;
575
+ }
576
+
577
+ if (this['tagName'] !== 'SELECT') {
578
+ (<Node>this)._selectNode = parentNode ? (<Node>parentNode)._selectNode : null;
579
+ }
580
+
581
+ if (this['tagName'] !== 'TEXTAREA') {
582
+ (<Node>this)._textAreaNode = parentNode ? (<Node>parentNode)._textAreaNode : null;
583
+ }
550
584
  }
551
585
 
552
586
  if (this.isConnected !== isConnected) {
@@ -570,6 +604,14 @@ export default class Node extends EventTarget implements INode {
570
604
  // eslint-disable-next-line
571
605
  (<any>this)._shadowRoot._connectToNode(this);
572
606
  }
607
+ } else if (
608
+ formNode !== this._formNode ||
609
+ selectNode !== this._selectNode ||
610
+ textAreaNode !== this._textAreaNode
611
+ ) {
612
+ for (const child of this.childNodes) {
613
+ (<Node>child)._connectToNode(this);
614
+ }
573
615
  }
574
616
  }
575
617
 
@@ -745,4 +787,17 @@ export default class Node extends EventTarget implements INode {
745
787
  ? Node.DOCUMENT_POSITION_PRECEDING
746
788
  : Node.DOCUMENT_POSITION_FOLLOWING;
747
789
  }
790
+
791
+ /**
792
+ * This will be called by JSON.stringify() when serializing this node.
793
+ *
794
+ * @returns Object without circular references.
795
+ */
796
+ public toJSON(): { [key: string]: unknown } {
797
+ const result = {};
798
+ for (const key of Object.keys(this)) {
799
+ result[key] = !JSON_CIRCULAR_PROPERTIES.includes(key) ? this[key] : null;
800
+ }
801
+ return result;
802
+ }
748
803
  }
@@ -1,10 +1,9 @@
1
1
  import INodeList from './INodeList';
2
- import INode from './INode';
3
2
 
4
3
  /**
5
4
  * Class list.
6
5
  */
7
- export default class NodeList extends Array implements INodeList<INode> {
6
+ export default class NodeList<T> extends Array implements INodeList<T> {
8
7
  /**
9
8
  * Returns `Symbol.toStringTag`.
10
9
  *
@@ -19,7 +18,7 @@ export default class NodeList extends Array implements INodeList<INode> {
19
18
  *
20
19
  * @param index Index.
21
20
  */
22
- public item(index: number): INode {
21
+ public item(index: number): T {
23
22
  return index >= 0 && this[index] ? this[index] : null;
24
23
  }
25
24
  }
@@ -7,7 +7,7 @@ export default interface IParentNode extends INode {
7
7
  readonly childElementCount: number;
8
8
  readonly firstElementChild: IElement;
9
9
  readonly lastElementChild: IElement;
10
- readonly children: IElement[];
10
+ readonly children: IHTMLCollection<IElement, IElement>;
11
11
 
12
12
  /**
13
13
  * Inserts a set of Node objects or DOMString objects after the last child of the ParentNode. DOMString objects are inserted as equivalent Text nodes.
@@ -45,7 +45,7 @@ export default interface IParentNode extends INode {
45
45
  * @param className Tag name.
46
46
  * @returns Matching element.
47
47
  */
48
- getElementsByClassName(className: string): IHTMLCollection<IElement>;
48
+ getElementsByClassName(className: string): IHTMLCollection<IElement, IElement>;
49
49
 
50
50
  /**
51
51
  * Returns an elements by tag name.
@@ -53,7 +53,7 @@ export default interface IParentNode extends INode {
53
53
  * @param tagName Tag name.
54
54
  * @returns Matching element.
55
55
  */
56
- getElementsByTagName(tagName: string): IHTMLCollection<IElement>;
56
+ getElementsByTagName(tagName: string): IHTMLCollection<IElement, IElement>;
57
57
 
58
58
  /**
59
59
  * Returns an elements by tag name and namespace.
@@ -62,7 +62,10 @@ export default interface IParentNode extends INode {
62
62
  * @param tagName Tag name.
63
63
  * @returns Matching element.
64
64
  */
65
- getElementsByTagNameNS(namespaceURI: string, tagName: string): IHTMLCollection<IElement>;
65
+ getElementsByTagNameNS(
66
+ namespaceURI: string,
67
+ tagName: string
68
+ ): IHTMLCollection<IElement, IElement>;
66
69
 
67
70
  /**
68
71
  * Replaces the existing children of a node with a specified new set of children.