happy-dom 8.8.0 → 9.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.

Potentially problematic release.


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

Files changed (364) 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-audio-element/Audio.d.ts +15 -0
  117. package/lib/nodes/html-audio-element/Audio.js +27 -0
  118. package/lib/nodes/html-audio-element/Audio.js.map +1 -0
  119. package/lib/nodes/html-base-element/HTMLBaseElement.js +4 -4
  120. package/lib/nodes/html-base-element/HTMLBaseElement.js.map +1 -1
  121. package/lib/nodes/html-button-element/HTMLButtonElement.d.ts +79 -3
  122. package/lib/nodes/html-button-element/HTMLButtonElement.js +158 -10
  123. package/lib/nodes/html-button-element/HTMLButtonElement.js.map +1 -1
  124. package/lib/nodes/html-button-element/IHTMLButtonElement.d.ts +28 -2
  125. package/lib/nodes/html-dialog-element/HTMLDialogElement.js +3 -3
  126. package/lib/nodes/html-dialog-element/HTMLDialogElement.js.map +1 -1
  127. package/lib/nodes/html-element/HTMLElement.js +12 -12
  128. package/lib/nodes/html-element/HTMLElement.js.map +1 -1
  129. package/lib/nodes/html-form-element/HTMLFormControlsCollection.d.ts +32 -0
  130. package/lib/nodes/html-form-element/HTMLFormControlsCollection.js +58 -0
  131. package/lib/nodes/html-form-element/HTMLFormControlsCollection.js.map +1 -0
  132. package/lib/nodes/html-form-element/HTMLFormElement.d.ts +37 -17
  133. package/lib/nodes/html-form-element/HTMLFormElement.js +128 -37
  134. package/lib/nodes/html-form-element/HTMLFormElement.js.map +1 -1
  135. package/lib/nodes/html-form-element/IHTMLFormControlsCollection.d.ts +25 -0
  136. package/lib/nodes/html-form-element/IHTMLFormControlsCollection.js +3 -0
  137. package/lib/nodes/html-form-element/IHTMLFormControlsCollection.js.map +1 -0
  138. package/lib/nodes/html-form-element/IHTMLFormElement.d.ts +16 -6
  139. package/lib/nodes/html-form-element/IRadioNodeList.d.ts +15 -0
  140. package/lib/nodes/html-form-element/IRadioNodeList.js +3 -0
  141. package/lib/nodes/html-form-element/IRadioNodeList.js.map +1 -0
  142. package/lib/nodes/html-form-element/RadioNodeList.d.ts +16 -0
  143. package/lib/nodes/html-form-element/RadioNodeList.js +28 -0
  144. package/lib/nodes/html-form-element/RadioNodeList.js.map +1 -0
  145. package/lib/nodes/html-image-element/HTMLImageElement.js +19 -19
  146. package/lib/nodes/html-image-element/HTMLImageElement.js.map +1 -1
  147. package/lib/nodes/html-input-element/HTMLInputElement.d.ts +43 -19
  148. package/lib/nodes/html-input-element/HTMLInputElement.js +206 -111
  149. package/lib/nodes/html-input-element/HTMLInputElement.js.map +1 -1
  150. package/lib/nodes/html-input-element/IHTMLInputElement.d.ts +14 -1
  151. package/lib/nodes/html-label-element/HTMLLabelElement.js +3 -7
  152. package/lib/nodes/html-label-element/HTMLLabelElement.js.map +1 -1
  153. package/lib/nodes/html-link-element/HTMLLinkElement.js +21 -21
  154. package/lib/nodes/html-link-element/HTMLLinkElement.js.map +1 -1
  155. package/lib/nodes/html-media-element/HTMLMediaElement.js +21 -21
  156. package/lib/nodes/html-media-element/HTMLMediaElement.js.map +1 -1
  157. package/lib/nodes/html-meta-element/HTMLMetaElement.js +8 -8
  158. package/lib/nodes/html-meta-element/HTMLMetaElement.js.map +1 -1
  159. package/lib/nodes/html-opt-group-element/HTMLOptGroupElement.js +6 -6
  160. package/lib/nodes/html-opt-group-element/HTMLOptGroupElement.js.map +1 -1
  161. package/lib/nodes/html-option-element/HTMLOptionElement.d.ts +3 -4
  162. package/lib/nodes/html-option-element/HTMLOptionElement.js +26 -29
  163. package/lib/nodes/html-option-element/HTMLOptionElement.js.map +1 -1
  164. package/lib/nodes/html-script-element/HTMLScriptElement.js +16 -16
  165. package/lib/nodes/html-script-element/HTMLScriptElement.js.map +1 -1
  166. package/lib/nodes/html-script-element/ScriptUtility.js +5 -5
  167. package/lib/nodes/html-script-element/ScriptUtility.js.map +1 -1
  168. package/lib/nodes/{html-option-element → html-select-element}/HTMLOptionsCollection.d.ts +5 -6
  169. package/lib/nodes/{html-option-element → html-select-element}/HTMLOptionsCollection.js.map +1 -1
  170. package/lib/nodes/html-select-element/HTMLSelectElement.d.ts +42 -41
  171. package/lib/nodes/html-select-element/HTMLSelectElement.js +134 -138
  172. package/lib/nodes/html-select-element/HTMLSelectElement.js.map +1 -1
  173. package/lib/nodes/{html-option-element → html-select-element}/IHTMLOptionsCollection.d.ts +4 -5
  174. package/lib/nodes/html-select-element/IHTMLOptionsCollection.js.map +1 -0
  175. package/lib/nodes/html-select-element/IHTMLSelectElement.d.ts +22 -2
  176. package/lib/nodes/html-slot-element/HTMLSlotElement.js +2 -2
  177. package/lib/nodes/html-slot-element/HTMLSlotElement.js.map +1 -1
  178. package/lib/nodes/html-style-element/HTMLStyleElement.js +7 -7
  179. package/lib/nodes/html-style-element/HTMLStyleElement.js.map +1 -1
  180. package/lib/nodes/html-text-area-element/HTMLTextAreaElement.d.ts +55 -2
  181. package/lib/nodes/html-text-area-element/HTMLTextAreaElement.js +150 -40
  182. package/lib/nodes/html-text-area-element/HTMLTextAreaElement.js.map +1 -1
  183. package/lib/nodes/html-text-area-element/IHTMLTextAreaElement.d.ts +16 -0
  184. package/lib/nodes/node/Node.d.ts +12 -1
  185. package/lib/nodes/node/Node.js +50 -4
  186. package/lib/nodes/node/Node.js.map +1 -1
  187. package/lib/nodes/node/NodeList.d.ts +2 -3
  188. package/lib/nodes/node/NodeList.js.map +1 -1
  189. package/lib/nodes/parent-node/IParentNode.d.ts +4 -4
  190. package/lib/nodes/parent-node/ParentNodeUtility.d.ts +3 -3
  191. package/lib/nodes/parent-node/ParentNodeUtility.js +13 -11
  192. package/lib/nodes/parent-node/ParentNodeUtility.js.map +1 -1
  193. package/lib/nodes/text/Text.d.ts +13 -0
  194. package/lib/nodes/text/Text.js +30 -0
  195. package/lib/nodes/text/Text.js.map +1 -1
  196. package/lib/query-selector/QuerySelector.js +2 -2
  197. package/lib/query-selector/QuerySelector.js.map +1 -1
  198. package/lib/query-selector/SelectorItem.js +2 -0
  199. package/lib/query-selector/SelectorItem.js.map +1 -1
  200. package/lib/validity-state/ValidityState.d.ts +87 -0
  201. package/lib/validity-state/ValidityState.js +171 -0
  202. package/lib/validity-state/ValidityState.js.map +1 -0
  203. package/lib/window/GlobalWindow.d.ts +0 -8
  204. package/lib/window/GlobalWindow.js +0 -2
  205. package/lib/window/GlobalWindow.js.map +1 -1
  206. package/lib/window/INodeJSGlobal.d.ts +71 -0
  207. package/lib/window/INodeJSGlobal.js +2 -0
  208. package/lib/window/INodeJSGlobal.js.map +1 -0
  209. package/lib/window/IWindow.d.ts +30 -10
  210. package/lib/window/Window.d.ts +37 -20
  211. package/lib/window/Window.js +22 -10
  212. package/lib/window/Window.js.map +1 -1
  213. package/lib/xml-http-request/XMLHttpRequest.js +20 -12
  214. package/lib/xml-http-request/XMLHttpRequest.js.map +1 -1
  215. package/lib/xml-parser/XMLParser.js +1 -1
  216. package/lib/xml-parser/XMLParser.js.map +1 -1
  217. package/package.json +2 -3
  218. package/src/cookie/CookieJar.ts +1 -1
  219. package/src/dom-token-list/DOMTokenList.ts +24 -20
  220. package/src/event/EventTarget.ts +7 -3
  221. package/src/exception/DOMExceptionNameEnum.ts +5 -1
  222. package/src/fetch/AbortController.ts +26 -0
  223. package/src/fetch/AbortSignal.ts +44 -0
  224. package/src/fetch/Fetch.ts +666 -0
  225. package/src/fetch/Headers.ts +151 -3
  226. package/src/fetch/Request.ts +226 -94
  227. package/src/fetch/{ResourceFetchHandler.ts → ResourceFetch.ts} +3 -3
  228. package/src/fetch/Response.ts +252 -89
  229. package/src/fetch/data-uri/DataURIParser.ts +66 -0
  230. package/src/fetch/multipart/MultipartFormDataParser.ts +113 -0
  231. package/src/fetch/multipart/MultipartReader.ts +217 -0
  232. package/src/fetch/types/IHeaders.ts +80 -0
  233. package/src/fetch/types/IRequest.ts +65 -0
  234. package/src/fetch/types/IRequestBody.ts +15 -0
  235. package/src/fetch/types/IRequestCredentials.ts +2 -0
  236. package/src/fetch/types/IRequestInfo.ts +6 -0
  237. package/src/fetch/types/IRequestInit.ts +21 -0
  238. package/src/fetch/types/IRequestRedirect.ts +3 -0
  239. package/src/fetch/types/IRequestReferrerPolicy.ts +11 -0
  240. package/src/fetch/types/IResponse.ts +27 -0
  241. package/src/fetch/types/IResponseBody.ts +15 -0
  242. package/src/fetch/types/IResponseInit.ts +10 -0
  243. package/src/fetch/utilities/FetchBodyUtility.ts +175 -0
  244. package/src/fetch/utilities/FetchCORSUtility.ts +18 -0
  245. package/src/fetch/utilities/FetchRequestHeaderUtility.ts +47 -0
  246. package/src/fetch/utilities/FetchRequestReferrerUtility.ts +241 -0
  247. package/src/fetch/utilities/FetchRequestValidationUtility.ts +82 -0
  248. package/src/file/Blob.ts +2 -2
  249. package/src/file/File.ts +5 -1
  250. package/src/form-data/FormData.ts +237 -0
  251. package/src/index.ts +27 -1
  252. package/src/nodes/document/Document.ts +23 -64
  253. package/src/nodes/document/IDocument.ts +1 -1
  254. package/src/nodes/document-fragment/DocumentFragment.ts +9 -59
  255. package/src/nodes/document-fragment/IDocumentFragment.ts +2 -1
  256. package/src/nodes/element/Element.ts +43 -56
  257. package/src/nodes/element/ElementUtility.ts +137 -0
  258. package/src/nodes/element/HTMLCollection.ts +60 -3
  259. package/src/nodes/element/IHTMLCollection.ts +10 -2
  260. package/src/nodes/html-anchor-element/HTMLAnchorElement.ts +24 -24
  261. package/src/nodes/html-audio-element/Audio.ts +22 -0
  262. package/src/nodes/html-base-element/HTMLBaseElement.ts +4 -4
  263. package/src/nodes/html-button-element/HTMLButtonElement.ts +184 -10
  264. package/src/nodes/html-button-element/IHTMLButtonElement.ts +31 -2
  265. package/src/nodes/html-dialog-element/HTMLDialogElement.ts +3 -3
  266. package/src/nodes/html-element/HTMLElement.ts +12 -12
  267. package/src/nodes/html-form-element/HTMLFormControlsCollection.ts +76 -0
  268. package/src/nodes/html-form-element/HTMLFormElement.ts +147 -41
  269. package/src/nodes/html-form-element/IHTMLFormControlsCollection.ts +45 -0
  270. package/src/nodes/html-form-element/IHTMLFormElement.ts +17 -6
  271. package/src/nodes/html-form-element/IRadioNodeList.ts +16 -0
  272. package/src/nodes/html-form-element/RadioNodeList.ts +24 -0
  273. package/src/nodes/html-image-element/HTMLImageElement.ts +19 -19
  274. package/src/nodes/html-input-element/HTMLInputElement.ts +232 -113
  275. package/src/nodes/html-input-element/IHTMLInputElement.ts +20 -1
  276. package/src/nodes/html-label-element/HTMLLabelElement.ts +3 -7
  277. package/src/nodes/html-link-element/HTMLLinkElement.ts +21 -21
  278. package/src/nodes/html-media-element/HTMLMediaElement.ts +21 -21
  279. package/src/nodes/html-meta-element/HTMLMetaElement.ts +8 -8
  280. package/src/nodes/html-opt-group-element/HTMLOptGroupElement.ts +6 -6
  281. package/src/nodes/html-option-element/HTMLOptionElement.ts +29 -30
  282. package/src/nodes/html-script-element/HTMLScriptElement.ts +16 -16
  283. package/src/nodes/html-script-element/ScriptUtility.ts +5 -5
  284. package/src/nodes/{html-option-element → html-select-element}/HTMLOptionsCollection.ts +5 -9
  285. package/src/nodes/html-select-element/HTMLSelectElement.ts +159 -170
  286. package/src/nodes/{html-option-element → html-select-element}/IHTMLOptionsCollection.ts +4 -8
  287. package/src/nodes/html-select-element/IHTMLSelectElement.ts +25 -2
  288. package/src/nodes/html-slot-element/HTMLSlotElement.ts +2 -2
  289. package/src/nodes/html-style-element/HTMLStyleElement.ts +7 -7
  290. package/src/nodes/html-text-area-element/HTMLTextAreaElement.ts +174 -41
  291. package/src/nodes/html-text-area-element/IHTMLTextAreaElement.ts +18 -0
  292. package/src/nodes/node/Node.ts +61 -6
  293. package/src/nodes/node/NodeList.ts +2 -3
  294. package/src/nodes/parent-node/IParentNode.ts +7 -4
  295. package/src/nodes/parent-node/ParentNodeUtility.ts +25 -15
  296. package/src/nodes/text/Text.ts +38 -0
  297. package/src/query-selector/QuerySelector.ts +2 -2
  298. package/src/query-selector/SelectorItem.ts +3 -0
  299. package/src/validity-state/ValidityState.ts +211 -0
  300. package/src/window/GlobalWindow.ts +0 -2
  301. package/src/window/INodeJSGlobal.ts +70 -0
  302. package/src/window/IWindow.ts +32 -10
  303. package/src/window/Window.ts +43 -21
  304. package/src/xml-http-request/XMLHttpRequest.ts +27 -26
  305. package/src/xml-parser/XMLParser.ts +1 -1
  306. package/lib/fetch/FetchHandler.d.ts +0 -18
  307. package/lib/fetch/FetchHandler.js +0 -83
  308. package/lib/fetch/FetchHandler.js.map +0 -1
  309. package/lib/fetch/IAbortSignal.d.ts +0 -16
  310. package/lib/fetch/IAbortSignal.js +0 -4
  311. package/lib/fetch/IAbortSignal.js.map +0 -1
  312. package/lib/fetch/IBody.d.ts +0 -17
  313. package/lib/fetch/IBody.js.map +0 -1
  314. package/lib/fetch/IHeaders.d.ts +0 -18
  315. package/lib/fetch/IHeadersInit.js.map +0 -1
  316. package/lib/fetch/IRequest.d.ts +0 -18
  317. package/lib/fetch/IRequestInit.d.ts +0 -16
  318. package/lib/fetch/IRequestInit.js.map +0 -1
  319. package/lib/fetch/IResponse.d.ts +0 -20
  320. package/lib/fetch/IResponseInit.d.ts +0 -9
  321. package/lib/fetch/IResponseInit.js.map +0 -1
  322. package/lib/fetch/RequestInfo.js +0 -3
  323. package/lib/fetch/RequestInfo.js.map +0 -1
  324. package/lib/fetch/ResourceFetchHandler.js.map +0 -1
  325. package/lib/form-data/IFormData.d.ts +0 -32
  326. package/lib/form-data/IFormData.js +0 -3
  327. package/lib/form-data/IFormData.js.map +0 -1
  328. package/lib/location/RelativeURL.d.ts +0 -15
  329. package/lib/location/RelativeURL.js +0 -19
  330. package/lib/location/RelativeURL.js.map +0 -1
  331. package/lib/nodes/element/HTMLCollectionFactory.d.ts +0 -21
  332. package/lib/nodes/element/HTMLCollectionFactory.js +0 -31
  333. package/lib/nodes/element/HTMLCollectionFactory.js.map +0 -1
  334. package/lib/nodes/html-option-element/IHTMLOptionsCollection.js.map +0 -1
  335. package/lib/nodes/node/NodeListFactory.d.ts +0 -21
  336. package/lib/nodes/node/NodeListFactory.js +0 -31
  337. package/lib/nodes/node/NodeListFactory.js.map +0 -1
  338. package/lib/nodes/validity-state/ValidityState.d.ts +0 -52
  339. package/lib/nodes/validity-state/ValidityState.js +0 -81
  340. package/lib/nodes/validity-state/ValidityState.js.map +0 -1
  341. package/src/fetch/FetchHandler.ts +0 -90
  342. package/src/fetch/IAbortSignal.ts +0 -34
  343. package/src/fetch/IBody.ts +0 -18
  344. package/src/fetch/IHeaders.ts +0 -18
  345. package/src/fetch/IRequest.ts +0 -59
  346. package/src/fetch/IRequestInit.ts +0 -41
  347. package/src/fetch/IResponse.ts +0 -22
  348. package/src/fetch/IResponseInit.ts +0 -10
  349. package/src/fetch/RequestInfo.ts +0 -6
  350. package/src/form-data/IFormData.ts +0 -33
  351. package/src/location/RelativeURL.ts +0 -17
  352. package/src/nodes/element/HTMLCollectionFactory.ts +0 -31
  353. package/src/nodes/node/NodeListFactory.ts +0 -31
  354. package/src/nodes/validity-state/ValidityState.ts +0 -84
  355. /package/lib/fetch/{IHeaders.js → types/IHeaders.js} +0 -0
  356. /package/lib/fetch/{IHeadersInit.d.ts → types/IHeadersInit.d.ts} +0 -0
  357. /package/lib/fetch/{IHeadersInit.js → types/IHeadersInit.js} +0 -0
  358. /package/lib/fetch/{IRequest.js → types/IRequest.js} +0 -0
  359. /package/lib/fetch/{IRequestInit.js → types/IRequestInit.js} +0 -0
  360. /package/lib/fetch/{IResponse.js → types/IResponse.js} +0 -0
  361. /package/lib/fetch/{IResponseInit.js → types/IResponseInit.js} +0 -0
  362. /package/lib/nodes/{html-option-element → html-select-element}/HTMLOptionsCollection.js +0 -0
  363. /package/lib/nodes/{html-option-element → html-select-element}/IHTMLOptionsCollection.js +0 -0
  364. /package/src/fetch/{IHeadersInit.ts → types/IHeadersInit.ts} +0 -0
@@ -63,7 +63,7 @@ export default class HTMLElement extends Element implements IHTMLElement {
63
63
  * @returns Tab index.
64
64
  */
65
65
  public get tabIndex(): number {
66
- const tabIndex = this.getAttributeNS(null, 'tabindex');
66
+ const tabIndex = this.getAttribute('tabindex');
67
67
  return tabIndex !== null ? Number(tabIndex) : -1;
68
68
  }
69
69
 
@@ -74,9 +74,9 @@ export default class HTMLElement extends Element implements IHTMLElement {
74
74
  */
75
75
  public set tabIndex(tabIndex: number) {
76
76
  if (tabIndex === -1) {
77
- this.removeAttributeNS(null, 'tabindex');
77
+ this.removeAttribute('tabindex');
78
78
  } else {
79
- this.setAttributeNS(null, 'tabindex', String(tabIndex));
79
+ this.setAttribute('tabindex', String(tabIndex));
80
80
  }
81
81
  }
82
82
 
@@ -290,7 +290,7 @@ export default class HTMLElement extends Element implements IHTMLElement {
290
290
  * @returns Direction.
291
291
  */
292
292
  public get dir(): string {
293
- return this.getAttributeNS(null, 'dir') || '';
293
+ return this.getAttribute('dir') || '';
294
294
  }
295
295
 
296
296
  /**
@@ -299,7 +299,7 @@ export default class HTMLElement extends Element implements IHTMLElement {
299
299
  * @param direction Direction.
300
300
  */
301
301
  public set dir(direction: string) {
302
- this.setAttributeNS(null, 'dir', direction);
302
+ this.setAttribute('dir', direction);
303
303
  }
304
304
 
305
305
  /**
@@ -308,7 +308,7 @@ export default class HTMLElement extends Element implements IHTMLElement {
308
308
  * @returns Hidden.
309
309
  */
310
310
  public get hidden(): boolean {
311
- return this.getAttributeNS(null, 'hidden') !== null;
311
+ return this.getAttribute('hidden') !== null;
312
312
  }
313
313
 
314
314
  /**
@@ -318,9 +318,9 @@ export default class HTMLElement extends Element implements IHTMLElement {
318
318
  */
319
319
  public set hidden(hidden: boolean) {
320
320
  if (!hidden) {
321
- this.removeAttributeNS(null, 'hidden');
321
+ this.removeAttribute('hidden');
322
322
  } else {
323
- this.setAttributeNS(null, 'hidden', '');
323
+ this.setAttribute('hidden', '');
324
324
  }
325
325
  }
326
326
 
@@ -330,7 +330,7 @@ export default class HTMLElement extends Element implements IHTMLElement {
330
330
  * @returns Language.
331
331
  */
332
332
  public get lang(): string {
333
- return this.getAttributeNS(null, 'lang') || '';
333
+ return this.getAttribute('lang') || '';
334
334
  }
335
335
 
336
336
  /**
@@ -339,7 +339,7 @@ export default class HTMLElement extends Element implements IHTMLElement {
339
339
  * @param language Language.
340
340
  */
341
341
  public set lang(lang: string) {
342
- this.setAttributeNS(null, 'lang', lang);
342
+ this.setAttribute('lang', lang);
343
343
  }
344
344
 
345
345
  /**
@@ -348,7 +348,7 @@ export default class HTMLElement extends Element implements IHTMLElement {
348
348
  * @returns Title.
349
349
  */
350
350
  public get title(): string {
351
- return this.getAttributeNS(null, 'title') || '';
351
+ return this.getAttribute('title') || '';
352
352
  }
353
353
 
354
354
  /**
@@ -357,7 +357,7 @@ export default class HTMLElement extends Element implements IHTMLElement {
357
357
  * @param title Title.
358
358
  */
359
359
  public set title(title: string) {
360
- this.setAttributeNS(null, 'title', title);
360
+ this.setAttribute('title', title);
361
361
  }
362
362
 
363
363
  /**
@@ -0,0 +1,76 @@
1
+ import IHTMLFormControlsCollection from './IHTMLFormControlsCollection';
2
+ import IHTMLInputElement from '../html-input-element/IHTMLInputElement';
3
+ import IHTMLTextAreaElement from '../html-text-area-element/IHTMLTextAreaElement';
4
+ import IHTMLSelectElement from '../html-select-element/IHTMLSelectElement';
5
+ import HTMLCollection from '../element/HTMLCollection';
6
+ import RadioNodeList from './RadioNodeList';
7
+ import IHTMLButtonElement from '../html-button-element/IHTMLButtonElement';
8
+ import IRadioNodeList from './IRadioNodeList';
9
+
10
+ /**
11
+ * HTMLFormControlsCollection.
12
+ *
13
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormControlsCollection
14
+ */
15
+ export default class HTMLFormControlsCollection
16
+ extends HTMLCollection<
17
+ IHTMLInputElement | IHTMLTextAreaElement | IHTMLSelectElement | IHTMLButtonElement,
18
+ | IHTMLInputElement
19
+ | IHTMLTextAreaElement
20
+ | IHTMLSelectElement
21
+ | IHTMLButtonElement
22
+ | IRadioNodeList
23
+ >
24
+ implements IHTMLFormControlsCollection
25
+ {
26
+ public _namedItems: { [k: string]: RadioNodeList } = {};
27
+
28
+ /**
29
+ * Appends named item.
30
+ *
31
+ * @param node Node.
32
+ * @param name Name.
33
+ */
34
+ public _appendNamedItem(
35
+ node: IHTMLInputElement | IHTMLTextAreaElement | IHTMLSelectElement | IHTMLButtonElement,
36
+ name: string
37
+ ): void {
38
+ if (name) {
39
+ this._namedItems[name] = this._namedItems[name] || new RadioNodeList();
40
+
41
+ if (!this._namedItems[name].includes(node)) {
42
+ this._namedItems[name].push(node);
43
+ }
44
+
45
+ this[name] =
46
+ this._namedItems[name].length > 1 ? this._namedItems[name] : this._namedItems[name][0];
47
+ }
48
+ }
49
+
50
+ /**
51
+ * Appends named item.
52
+ *
53
+ * @param node Node.
54
+ * @param name Name.
55
+ */
56
+ public _removeNamedItem(
57
+ node: IHTMLInputElement | IHTMLTextAreaElement | IHTMLSelectElement | IHTMLButtonElement,
58
+ name: string
59
+ ): void {
60
+ if (name && this._namedItems[name]) {
61
+ const index = this._namedItems[name].indexOf(node);
62
+
63
+ if (index > -1) {
64
+ this._namedItems[name].splice(index, 1);
65
+
66
+ if (this._namedItems[name].length === 0) {
67
+ delete this._namedItems[name];
68
+ delete this[name];
69
+ } else {
70
+ this[name] =
71
+ this._namedItems[name].length > 1 ? this._namedItems[name] : this._namedItems[name][0];
72
+ }
73
+ }
74
+ }
75
+ }
76
+ }
@@ -1,7 +1,13 @@
1
1
  import HTMLElement from '../html-element/HTMLElement';
2
- import IElement from '../element/IElement';
3
2
  import IHTMLFormElement from './IHTMLFormElement';
4
3
  import Event from '../../event/Event';
4
+ import HTMLFormControlsCollection from './HTMLFormControlsCollection';
5
+ import IHTMLFormControlsCollection from './IHTMLFormControlsCollection';
6
+ import INode from '../node/INode';
7
+ import IHTMLInputElement from '../html-input-element/IHTMLInputElement';
8
+ import IHTMLTextAreaElement from '../html-text-area-element/IHTMLTextAreaElement';
9
+ import IHTMLSelectElement from '../html-select-element/IHTMLSelectElement';
10
+ import IHTMLButtonElement from '../html-button-element/IHTMLButtonElement';
5
11
 
6
12
  /**
7
13
  * HTML Form Element.
@@ -10,18 +16,25 @@ import Event from '../../event/Event';
10
16
  * https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement.
11
17
  */
12
18
  export default class HTMLFormElement extends HTMLElement implements IHTMLFormElement {
19
+ // Public properties.
20
+ public readonly elements: IHTMLFormControlsCollection = new HTMLFormControlsCollection();
21
+ public readonly length = 0;
22
+
13
23
  // Events
14
24
  public onformdata: (event: Event) => void | null = null;
15
25
  public onreset: (event: Event) => void | null = null;
16
26
  public onsubmit: (event: Event) => void | null = null;
17
27
 
28
+ // Private properties
29
+ public _formNode: INode = this;
30
+
18
31
  /**
19
32
  * Returns name.
20
33
  *
21
34
  * @returns Name.
22
35
  */
23
36
  public get name(): string {
24
- return this.getAttributeNS(null, 'name') || '';
37
+ return this.getAttribute('name') || '';
25
38
  }
26
39
 
27
40
  /**
@@ -30,7 +43,7 @@ export default class HTMLFormElement extends HTMLElement implements IHTMLFormEle
30
43
  * @param name Name.
31
44
  */
32
45
  public set name(name: string) {
33
- this.setAttributeNS(null, 'name', name);
46
+ this.setAttribute('name', name);
34
47
  }
35
48
 
36
49
  /**
@@ -39,7 +52,7 @@ export default class HTMLFormElement extends HTMLElement implements IHTMLFormEle
39
52
  * @returns Method.
40
53
  */
41
54
  public get method(): string {
42
- return this.getAttributeNS(null, 'method') || 'get';
55
+ return this.getAttribute('method') || 'get';
43
56
  }
44
57
 
45
58
  /**
@@ -48,7 +61,7 @@ export default class HTMLFormElement extends HTMLElement implements IHTMLFormEle
48
61
  * @param method Method.
49
62
  */
50
63
  public set method(method: string) {
51
- this.setAttributeNS(null, 'method', method);
64
+ this.setAttribute('method', method);
52
65
  }
53
66
 
54
67
  /**
@@ -57,7 +70,7 @@ export default class HTMLFormElement extends HTMLElement implements IHTMLFormEle
57
70
  * @returns Target.
58
71
  */
59
72
  public get target(): string {
60
- return this.getAttributeNS(null, 'target') || '';
73
+ return this.getAttribute('target') || '';
61
74
  }
62
75
 
63
76
  /**
@@ -66,7 +79,7 @@ export default class HTMLFormElement extends HTMLElement implements IHTMLFormEle
66
79
  * @param target Target.
67
80
  */
68
81
  public set target(target: string) {
69
- this.setAttributeNS(null, 'target', target);
82
+ this.setAttribute('target', target);
70
83
  }
71
84
 
72
85
  /**
@@ -75,7 +88,7 @@ export default class HTMLFormElement extends HTMLElement implements IHTMLFormEle
75
88
  * @returns Action.
76
89
  */
77
90
  public get action(): string {
78
- return this.getAttributeNS(null, 'action') || '';
91
+ return this.getAttribute('action') || '';
79
92
  }
80
93
 
81
94
  /**
@@ -84,7 +97,7 @@ export default class HTMLFormElement extends HTMLElement implements IHTMLFormEle
84
97
  * @param action Action.
85
98
  */
86
99
  public set action(action: string) {
87
- this.setAttributeNS(null, 'action', action);
100
+ this.setAttribute('action', action);
88
101
  }
89
102
 
90
103
  /**
@@ -93,7 +106,7 @@ export default class HTMLFormElement extends HTMLElement implements IHTMLFormEle
93
106
  * @returns Encoding.
94
107
  */
95
108
  public get encoding(): string {
96
- return this.getAttributeNS(null, 'encoding') || '';
109
+ return this.getAttribute('encoding') || '';
97
110
  }
98
111
 
99
112
  /**
@@ -102,7 +115,7 @@ export default class HTMLFormElement extends HTMLElement implements IHTMLFormEle
102
115
  * @param encoding Encoding.
103
116
  */
104
117
  public set encoding(encoding: string) {
105
- this.setAttributeNS(null, 'encoding', encoding);
118
+ this.setAttribute('encoding', encoding);
106
119
  }
107
120
 
108
121
  /**
@@ -111,7 +124,7 @@ export default class HTMLFormElement extends HTMLElement implements IHTMLFormEle
111
124
  * @returns Enctype.
112
125
  */
113
126
  public get enctype(): string {
114
- return this.getAttributeNS(null, 'enctype') || '';
127
+ return this.getAttribute('enctype') || '';
115
128
  }
116
129
 
117
130
  /**
@@ -120,7 +133,7 @@ export default class HTMLFormElement extends HTMLElement implements IHTMLFormEle
120
133
  * @param enctype Enctype.
121
134
  */
122
135
  public set enctype(enctype: string) {
123
- this.setAttributeNS(null, 'enctype', enctype);
136
+ this.setAttribute('enctype', enctype);
124
137
  }
125
138
 
126
139
  /**
@@ -129,7 +142,7 @@ export default class HTMLFormElement extends HTMLElement implements IHTMLFormEle
129
142
  * @returns Autocomplete.
130
143
  */
131
144
  public get autocomplete(): string {
132
- return this.getAttributeNS(null, 'autocomplete') || '';
145
+ return this.getAttribute('autocomplete') || '';
133
146
  }
134
147
 
135
148
  /**
@@ -138,7 +151,7 @@ export default class HTMLFormElement extends HTMLElement implements IHTMLFormEle
138
151
  * @param autocomplete Autocomplete.
139
152
  */
140
153
  public set autocomplete(autocomplete: string) {
141
- this.setAttributeNS(null, 'autocomplete', autocomplete);
154
+ this.setAttribute('autocomplete', autocomplete);
142
155
  }
143
156
 
144
157
  /**
@@ -147,7 +160,7 @@ export default class HTMLFormElement extends HTMLElement implements IHTMLFormEle
147
160
  * @returns Accept charset.
148
161
  */
149
162
  public get acceptCharset(): string {
150
- return this.getAttributeNS(null, 'acceptcharset') || '';
163
+ return this.getAttribute('acceptcharset') || '';
151
164
  }
152
165
 
153
166
  /**
@@ -156,7 +169,7 @@ export default class HTMLFormElement extends HTMLElement implements IHTMLFormEle
156
169
  * @param acceptCharset Accept charset.
157
170
  */
158
171
  public set acceptCharset(acceptCharset: string) {
159
- this.setAttributeNS(null, 'acceptcharset', acceptCharset);
172
+ this.setAttribute('acceptcharset', acceptCharset);
160
173
  }
161
174
 
162
175
  /**
@@ -164,8 +177,8 @@ export default class HTMLFormElement extends HTMLElement implements IHTMLFormEle
164
177
  *
165
178
  * @returns No validate.
166
179
  */
167
- public get noValidate(): string {
168
- return this.getAttributeNS(null, 'novalidate') || '';
180
+ public get noValidate(): boolean {
181
+ return this.getAttribute('novalidate') !== null;
169
182
  }
170
183
 
171
184
  /**
@@ -173,42 +186,60 @@ export default class HTMLFormElement extends HTMLElement implements IHTMLFormEle
173
186
  *
174
187
  * @param noValidate No validate.
175
188
  */
176
- public set noValidate(noValidate: string) {
177
- this.setAttributeNS(null, 'novalidate', noValidate);
189
+ public set noValidate(noValidate: boolean) {
190
+ if (!noValidate) {
191
+ this.removeAttribute('novalidate');
192
+ } else {
193
+ this.setAttribute('novalidate', '');
194
+ }
178
195
  }
179
196
 
180
197
  /**
181
- * Returns input elements.
198
+ * Submits form. No submit event is raised. In particular, the form's "submit" event handler is not run.
182
199
  *
183
- * @returns Elements.
200
+ * In Happy DOM this means that nothing happens.
184
201
  */
185
- public get elements(): IElement[] {
186
- return this.querySelectorAll('input,textarea');
187
- }
202
+ public submit(): void {}
188
203
 
189
204
  /**
190
- * Returns number of input elements.
205
+ * Submits form, reports validity and raises submit event.
191
206
  *
192
- * @returns Length.
207
+ * @param [submitter] Submitter.
193
208
  */
194
- public get length(): number {
195
- return this.elements.length;
209
+ public requestSubmit(submitter?: IHTMLInputElement | IHTMLButtonElement): void {
210
+ const noValidate = submitter?.formNoValidate || this.noValidate;
211
+ if (noValidate || this.checkValidity()) {
212
+ this.dispatchEvent(new Event('submit', { bubbles: true, cancelable: true }));
213
+ }
196
214
  }
197
215
 
198
- /**
199
- * Submits form.
200
- */
201
- public submit(): void {}
202
-
203
216
  /**
204
217
  * Resets form.
205
218
  */
206
- public reset(): void {}
219
+ public reset(): void {
220
+ for (const element of this.elements) {
221
+ if (element.tagName === 'INPUT' || element.tagName === 'TEXTAREA') {
222
+ element['_value'] = null;
223
+ element['_checked'] = null;
224
+ } else if (element.tagName === 'TEXTAREA') {
225
+ element['_value'] = null;
226
+ } else if (element.tagName === 'SELECT') {
227
+ let hasSelectedAttribute = false;
228
+ for (const option of (<IHTMLSelectElement>element).options) {
229
+ if (option.hasAttribute('selected')) {
230
+ hasSelectedAttribute = true;
231
+ option.selected = true;
232
+ break;
233
+ }
234
+ }
235
+ if (!hasSelectedAttribute && (<IHTMLSelectElement>element).options.length > 0) {
236
+ (<IHTMLSelectElement>element).options[0].selected = true;
237
+ }
238
+ }
239
+ }
207
240
 
208
- /**
209
- * Reports validity.
210
- */
211
- public reportValidity(): void {}
241
+ this.dispatchEvent(new Event('reset', { bubbles: true, cancelable: true }));
242
+ }
212
243
 
213
244
  /**
214
245
  * Checks validity.
@@ -216,7 +247,32 @@ export default class HTMLFormElement extends HTMLElement implements IHTMLFormEle
216
247
  * @returns "true" if validation does'nt fail.
217
248
  */
218
249
  public checkValidity(): boolean {
219
- return true;
250
+ const radioValidationState: { [k: string]: boolean } = {};
251
+ let isFormValid = true;
252
+
253
+ for (const element of this.elements) {
254
+ if (element.tagName === 'INPUT' && element.type === 'radio' && element.name) {
255
+ if (!radioValidationState[element.name]) {
256
+ radioValidationState[element.name] = true;
257
+ if (!element.checkValidity()) {
258
+ isFormValid = false;
259
+ }
260
+ }
261
+ } else if (!element.checkValidity()) {
262
+ isFormValid = false;
263
+ }
264
+ }
265
+
266
+ return isFormValid;
267
+ }
268
+
269
+ /**
270
+ * Reports validity.
271
+ *
272
+ * @returns "true" if validation does'nt fail.
273
+ */
274
+ public reportValidity(): boolean {
275
+ return this.checkValidity();
220
276
  }
221
277
 
222
278
  /**
@@ -229,4 +285,54 @@ export default class HTMLFormElement extends HTMLElement implements IHTMLFormEle
229
285
  public cloneNode(deep = false): IHTMLFormElement {
230
286
  return <IHTMLFormElement>super.cloneNode(deep);
231
287
  }
288
+
289
+ /**
290
+ * Appends a form control item.
291
+ *
292
+ * @param node Node.
293
+ * @param name Name
294
+ */
295
+ public _appendFormControlItem(
296
+ node: IHTMLInputElement | IHTMLTextAreaElement | IHTMLSelectElement | IHTMLButtonElement,
297
+ name: string
298
+ ): void {
299
+ if (!this.elements.includes(node)) {
300
+ this[this.elements.length] = node;
301
+ this.elements.push(node);
302
+ (<number>this.length) = this.elements.length;
303
+ }
304
+
305
+ (<HTMLFormControlsCollection>this.elements)._appendNamedItem(node, name);
306
+ this[name] = this.elements[name];
307
+ }
308
+
309
+ /**
310
+ * Remove a form control item.
311
+ *
312
+ * @param node Node.
313
+ * @param name Name.
314
+ */
315
+ public _removeFormControlItem(
316
+ node: IHTMLInputElement | IHTMLTextAreaElement | IHTMLSelectElement | IHTMLButtonElement,
317
+ name: string
318
+ ): void {
319
+ const index = this.elements.indexOf(node);
320
+
321
+ if (index !== -1) {
322
+ this.elements.splice(index, 1);
323
+ for (let i = index; i < this.length; i++) {
324
+ this[i] = this[i + 1];
325
+ }
326
+ delete this[this.length - 1];
327
+ (<number>this.length)--;
328
+ }
329
+
330
+ (<HTMLFormControlsCollection>this.elements)._removeNamedItem(node, name);
331
+
332
+ if (this.elements[name]) {
333
+ this[name] = this.elements[name];
334
+ } else {
335
+ delete this[name];
336
+ }
337
+ }
232
338
  }
@@ -0,0 +1,45 @@
1
+ import IHTMLCollection from '../element/IHTMLCollection';
2
+ import IHTMLButtonElement from '../html-button-element/IHTMLButtonElement';
3
+ import IHTMLInputElement from '../html-input-element/IHTMLInputElement';
4
+ import IHTMLSelectElement from '../html-select-element/IHTMLSelectElement';
5
+ import IHTMLTextAreaElement from '../html-text-area-element/IHTMLTextAreaElement';
6
+ import IRadioNodeList from './IRadioNodeList';
7
+
8
+ /**
9
+ * HTMLFormControlsCollection.
10
+ *
11
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormControlsCollection
12
+ */
13
+ export default interface IHTMLFormControlsCollection
14
+ extends IHTMLCollection<
15
+ IHTMLInputElement | IHTMLTextAreaElement | IHTMLSelectElement | IHTMLButtonElement,
16
+ | IHTMLInputElement
17
+ | IHTMLTextAreaElement
18
+ | IHTMLSelectElement
19
+ | IHTMLButtonElement
20
+ | IRadioNodeList
21
+ > {
22
+ /**
23
+ * Returns item by index.
24
+ *
25
+ * @param index Index.
26
+ */
27
+ item(
28
+ index: number
29
+ ): IHTMLInputElement | IHTMLTextAreaElement | IHTMLSelectElement | IHTMLButtonElement | null;
30
+
31
+ /**
32
+ * Returns named item.
33
+ *
34
+ * @param name Name.
35
+ */
36
+ namedItem(
37
+ name: string
38
+ ):
39
+ | IHTMLInputElement
40
+ | IHTMLTextAreaElement
41
+ | IHTMLSelectElement
42
+ | IHTMLButtonElement
43
+ | IRadioNodeList
44
+ | null;
45
+ }
@@ -1,6 +1,8 @@
1
1
  import Event from '../../event/Event';
2
- import IElement from '../element/IElement';
2
+ import IHTMLButtonElement from '../html-button-element/IHTMLButtonElement';
3
3
  import IHTMLElement from '../html-element/IHTMLElement';
4
+ import IHTMLInputElement from '../html-input-element/IHTMLInputElement';
5
+ import IHTMLFormControlsCollection from './IHTMLFormControlsCollection';
4
6
 
5
7
  /**
6
8
  * HTML Form Element.
@@ -17,9 +19,9 @@ export default interface IHTMLFormElement extends IHTMLElement {
17
19
  enctype: string;
18
20
  autocomplete: string;
19
21
  acceptCharset: string;
20
- noValidate: string;
21
- elements: IElement[];
22
- length: number;
22
+ noValidate: boolean;
23
+ readonly elements: IHTMLFormControlsCollection;
24
+ readonly length: number;
23
25
 
24
26
  // Events
25
27
  onformdata: (event: Event) => void | null;
@@ -27,10 +29,19 @@ export default interface IHTMLFormElement extends IHTMLElement {
27
29
  onsubmit: (event: Event) => void | null;
28
30
 
29
31
  /**
30
- * Submits form.
32
+ * Submits form. No submit event is raised. In particular, the form's "submit" event handler is not run.
33
+ *
34
+ * In Happy DOM this means that nothing happens.
31
35
  */
32
36
  submit(): void;
33
37
 
38
+ /**
39
+ * Submits form, reports validity and raises submit event.
40
+ *
41
+ * @param [submitter] Submitter.
42
+ */
43
+ requestSubmit(submitter?: IHTMLInputElement | IHTMLButtonElement): void;
44
+
34
45
  /**
35
46
  * Resets form.
36
47
  */
@@ -39,7 +50,7 @@ export default interface IHTMLFormElement extends IHTMLElement {
39
50
  /**
40
51
  * Reports validity.
41
52
  */
42
- reportValidity(): void;
53
+ reportValidity(): boolean;
43
54
 
44
55
  /**
45
56
  * Checks validity.
@@ -0,0 +1,16 @@
1
+ import IElement from '../element/IElement';
2
+ import INodeList from '../node/INodeList';
3
+
4
+ /**
5
+ * RadioNodeList.
6
+ *
7
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/RadioNodeList
8
+ */
9
+ export default interface IRadioNodeList extends INodeList<IElement> {
10
+ /**
11
+ * Returns value.
12
+ *
13
+ * @returns Value.
14
+ */
15
+ readonly value: string;
16
+ }
@@ -0,0 +1,24 @@
1
+ import IElement from '../element/IElement';
2
+ import NodeList from '../node/NodeList';
3
+ import IRadioNodeList from './IRadioNodeList';
4
+
5
+ /**
6
+ * RadioNodeList
7
+ *
8
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/RadioNodeList
9
+ */
10
+ export default class RadioNodeList extends NodeList<IElement> implements IRadioNodeList {
11
+ /**
12
+ * Returns value.
13
+ *
14
+ * @returns Value.
15
+ */
16
+ public get value(): string {
17
+ for (const node of this) {
18
+ if (node.checked) {
19
+ return node.value;
20
+ }
21
+ }
22
+ return null;
23
+ }
24
+ }