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
@@ -0,0 +1,47 @@
1
+ import Headers from '../Headers';
2
+ import IHeaders from '../types/IHeaders';
3
+
4
+ const FORBIDDEN_HEADER_NAMES = [
5
+ 'accept-charset',
6
+ 'accept-encoding',
7
+ 'access-control-request-headers',
8
+ 'access-control-request-method',
9
+ 'connection',
10
+ 'content-length',
11
+ 'cookie',
12
+ 'cookie2',
13
+ 'date',
14
+ 'dnt',
15
+ 'expect',
16
+ 'host',
17
+ 'keep-alive',
18
+ 'origin',
19
+ 'referer',
20
+ 'te',
21
+ 'trailer',
22
+ 'transfer-encoding',
23
+ 'upgrade',
24
+ 'via'
25
+ ];
26
+
27
+ /**
28
+ * Fetch request header utility.
29
+ */
30
+ export default class FetchRequestHeaderUtility {
31
+ /**
32
+ * Validates request headers.
33
+ *
34
+ * @param headers Headers.
35
+ */
36
+ public static removeForbiddenHeaders(headers: IHeaders): void {
37
+ for (const key of Object.keys((<Headers>headers)._entries)) {
38
+ if (
39
+ FORBIDDEN_HEADER_NAMES.includes(key) ||
40
+ key.startsWith('proxy-') ||
41
+ key.startsWith('sec-')
42
+ ) {
43
+ delete (<Headers>headers)._entries[key];
44
+ }
45
+ }
46
+ }
47
+ }
@@ -0,0 +1,241 @@
1
+ import { URL } from 'url';
2
+ import IRequest from '../types/IRequest';
3
+ import IDocument from '../../nodes/document/IDocument';
4
+ import { isIP } from 'net';
5
+ import Headers from '../Headers';
6
+ import IRequestReferrerPolicy from '../types/IRequestReferrerPolicy';
7
+
8
+ const REQUEST_REFERRER_UNSUPPORTED_PROTOCOL_REGEXP = /^(about|blob|data):$/;
9
+ const REFERRER_POLICIES: IRequestReferrerPolicy[] = [
10
+ '',
11
+ 'no-referrer',
12
+ 'no-referrer-when-downgrade',
13
+ 'same-origin',
14
+ 'origin',
15
+ 'strict-origin',
16
+ 'origin-when-cross-origin',
17
+ 'strict-origin-when-cross-origin',
18
+ 'unsafe-url'
19
+ ];
20
+
21
+ /**
22
+ * Fetch referrer utility.
23
+ */
24
+ export default class FetchRequestReferrerUtility {
25
+ /**
26
+ * Returns the request referrer to be used as the value for the "Referer" header.
27
+ *
28
+ * Based on:
29
+ * https://github.com/node-fetch/node-fetch/blob/main/src/utils/referrer.js (MIT)
30
+ *
31
+ * @see https://w3c.github.io/webappsec-referrer-policy/#determine-requests-referrer
32
+ * @param document Document.
33
+ * @param request Request.
34
+ * @returns Request referrer.
35
+ */
36
+ public static getSentReferrer(
37
+ document: IDocument,
38
+ request: IRequest
39
+ ): '' | 'no-referrer' | 'client' | URL {
40
+ if (request.referrer === 'about:client' && document.defaultView.location.origin === 'null') {
41
+ return 'no-referrer';
42
+ }
43
+
44
+ const requestURL = new URL(request.url);
45
+ const referrerURL =
46
+ request.referrer === 'about:client'
47
+ ? new URL(document.defaultView.location.href)
48
+ : new URL(request.referrer);
49
+
50
+ if (REQUEST_REFERRER_UNSUPPORTED_PROTOCOL_REGEXP.test(referrerURL.protocol)) {
51
+ return 'no-referrer';
52
+ }
53
+
54
+ referrerURL.username = '';
55
+ referrerURL.password = '';
56
+ referrerURL.hash = '';
57
+
58
+ switch (request.referrerPolicy) {
59
+ case 'no-referrer':
60
+ return 'no-referrer';
61
+ case 'origin':
62
+ return new URL(referrerURL.origin);
63
+ case 'unsafe-url':
64
+ return referrerURL;
65
+ case 'strict-origin':
66
+ if (
67
+ this.isURLPotentiallyTrustWorthy(referrerURL) &&
68
+ !this.isURLPotentiallyTrustWorthy(requestURL)
69
+ ) {
70
+ return 'no-referrer';
71
+ }
72
+
73
+ return new URL(referrerURL.origin);
74
+ case 'strict-origin-when-cross-origin':
75
+ if (referrerURL.origin === requestURL.origin) {
76
+ return referrerURL;
77
+ }
78
+
79
+ if (
80
+ this.isURLPotentiallyTrustWorthy(referrerURL) &&
81
+ !this.isURLPotentiallyTrustWorthy(requestURL)
82
+ ) {
83
+ return 'no-referrer';
84
+ }
85
+
86
+ return new URL(referrerURL.origin);
87
+ case 'same-origin':
88
+ if (referrerURL.origin === requestURL.origin) {
89
+ return referrerURL;
90
+ }
91
+
92
+ return 'no-referrer';
93
+ case 'origin-when-cross-origin':
94
+ if (referrerURL.origin === requestURL.origin) {
95
+ return referrerURL;
96
+ }
97
+
98
+ return new URL(referrerURL.origin);
99
+ case 'no-referrer-when-downgrade':
100
+ if (
101
+ this.isURLPotentiallyTrustWorthy(referrerURL) &&
102
+ !this.isURLPotentiallyTrustWorthy(requestURL)
103
+ ) {
104
+ return 'no-referrer';
105
+ }
106
+
107
+ return referrerURL;
108
+ }
109
+
110
+ return 'no-referrer';
111
+ }
112
+
113
+ /**
114
+ * Returns initial referrer.
115
+ *
116
+ * @param document Document.
117
+ * @param referrer Referrer.
118
+ * @returns Initial referrer.
119
+ */
120
+ public static getInitialReferrer(
121
+ document: IDocument,
122
+ referrer: '' | 'no-referrer' | 'client' | string | URL
123
+ ): '' | 'no-referrer' | 'client' | URL {
124
+ if (referrer === '' || referrer === 'no-referrer' || referrer === 'client') {
125
+ return referrer;
126
+ } else if (referrer) {
127
+ const referrerURL = referrer instanceof URL ? referrer : new URL(referrer, document.location);
128
+ return referrerURL.origin === document.location.origin ? referrerURL : 'client';
129
+ }
130
+
131
+ return 'client';
132
+ }
133
+
134
+ /**
135
+ * Returns referrer policy from header.
136
+ *
137
+ * @see https://w3c.github.io/webappsec-referrer-policy/#parse-referrer-policy-from-header
138
+ * @param headers Response headers
139
+ * @returns Policy.
140
+ */
141
+ public static getReferrerPolicyFromHeader(headers: Headers): IRequestReferrerPolicy {
142
+ const referrerPolicyHeader = headers.get('Referrer-Policy');
143
+
144
+ if (!referrerPolicyHeader) {
145
+ return '';
146
+ }
147
+
148
+ const policyTokens = referrerPolicyHeader.split(/[,\s]+/);
149
+ let policy: IRequestReferrerPolicy = '';
150
+
151
+ for (const token of policyTokens) {
152
+ if (token && REFERRER_POLICIES.includes(<IRequestReferrerPolicy>token)) {
153
+ policy = <IRequestReferrerPolicy>token;
154
+ }
155
+ }
156
+
157
+ return policy;
158
+ }
159
+
160
+ /**
161
+ * Returns "true" if the request's referrer is potentially trustworthy.
162
+ *
163
+ * @see https://w3c.github.io/webappsec-secure-contexts/#is-origin-trustworthy
164
+ * @param url URL.
165
+ * @returns "true" if the request's referrer is potentially trustworthy.
166
+ */
167
+ private static isURLPotentiallyTrustWorthy(url: URL): boolean {
168
+ // 1. If url is "about:blank" or "about:srcdoc", return "Potentially Trustworthy".
169
+ if (/^about:(blank|srcdoc)$/.test(url.href)) {
170
+ return true;
171
+ }
172
+
173
+ // 2. If url's scheme is "data", return "Potentially Trustworthy".
174
+ if (url.protocol === 'data:') {
175
+ return true;
176
+ }
177
+
178
+ // Note: The origin of blob: and filesystem: URLs is the origin of the context in which they were
179
+ // Created. Therefore, blobs created in a trustworthy origin will themselves be potentially
180
+ // Trustworthy.
181
+ if (/^(blob|filesystem):$/.test(url.protocol)) {
182
+ return true;
183
+ }
184
+
185
+ // 3. Return the result of executing §3.2 Is origin potentially trustworthy? on url's origin.
186
+ return this.isOriginPotentiallyTrustWorthy(url);
187
+ }
188
+
189
+ /**
190
+ * Returns "true" if the request's referrer origin is potentially trustworthy.
191
+ *
192
+ * @see https://w3c.github.io/webappsec-secure-contexts/#is-origin-trustworthy
193
+ * @param url URL.
194
+ * @returns "true" if the request's referrer origin is potentially trustworthy.
195
+ */
196
+ private static isOriginPotentiallyTrustWorthy(url: URL): boolean {
197
+ // 1. If origin is an opaque origin, return "Not Trustworthy".
198
+ // Not applicable
199
+
200
+ // 2. Assert: origin is a tuple origin.
201
+ // Not for implementations
202
+
203
+ // 3. If origin's scheme is either "https" or "wss", return "Potentially Trustworthy".
204
+ if (/^(http|ws)s:$/.test(url.protocol)) {
205
+ return true;
206
+ }
207
+
208
+ // 4. If origin's host component matches one of the CIDR notations 127.0.0.0/8 or ::1/128 [RFC4632], return "Potentially Trustworthy".
209
+ const hostIp = url.host.replace(/(^\[)|(]$)/g, '');
210
+ const hostIPVersion = isIP(hostIp);
211
+
212
+ if (hostIPVersion === 4 && /^127\./.test(hostIp)) {
213
+ return true;
214
+ }
215
+
216
+ if (hostIPVersion === 6 && /^(((0+:){7})|(::(0+:){0,6}))0*1$/.test(hostIp)) {
217
+ return true;
218
+ }
219
+
220
+ // 5. If origin's host component is "localhost" or falls within ".localhost", and the user agent conforms to the name resolution rules in [let-localhost-be-localhost], return "Potentially Trustworthy".
221
+ // We are returning FALSE here because we cannot ensure conformance to
222
+ // Let-localhost-be-loalhost (https://tools.ietf.org/html/draft-west-let-localhost-be-localhost)
223
+ if (url.host === 'localhost' || url.host.endsWith('.localhost')) {
224
+ return false;
225
+ }
226
+
227
+ // 6. If origin's scheme component is file, return "Potentially Trustworthy".
228
+ if (url.protocol === 'file:') {
229
+ return true;
230
+ }
231
+
232
+ // 7. If origin's scheme component is one which the user agent considers to be authenticated, return "Potentially Trustworthy".
233
+ // Not supported
234
+
235
+ // 8. If origin has been configured as a trustworthy origin, return "Potentially Trustworthy".
236
+ // Not supported
237
+
238
+ // 9. Return "Not Trustworthy".
239
+ return false;
240
+ }
241
+ }
@@ -0,0 +1,82 @@
1
+ import DOMException from '../../exception/DOMException';
2
+ import DOMExceptionNameEnum from '../../exception/DOMExceptionNameEnum';
3
+ import IRequestReferrerPolicy from '../types/IRequestReferrerPolicy';
4
+ import IRequestRedirect from '../types/IRequestRedirect';
5
+ import { URL } from 'url';
6
+ import IRequest from '../types/IRequest';
7
+
8
+ const VALID_REFERRER_POLICIES = [
9
+ '',
10
+ 'no-referrer',
11
+ 'no-referrer-when-downgrade',
12
+ 'same-origin',
13
+ 'origin',
14
+ 'strict-origin',
15
+ 'origin-when-cross-origin',
16
+ 'strict-origin-when-cross-origin',
17
+ 'unsafe-url'
18
+ ];
19
+
20
+ const VALID_REDIRECTS = ['error', 'manual', 'follow'];
21
+
22
+ /**
23
+ * Fetch request validation utility.
24
+ */
25
+ export default class FetchRequestValidationUtility {
26
+ /**
27
+ * Validates request body.
28
+ *
29
+ * @throws DOMException
30
+ * @param request Request.
31
+ */
32
+ public static validateBody(request: IRequest): void {
33
+ if (request.body && (request.method === 'GET' || request.method === 'HEAD')) {
34
+ throw new DOMException(
35
+ `Request with GET/HEAD method cannot have body.`,
36
+ DOMExceptionNameEnum.invalidStateError
37
+ );
38
+ }
39
+ }
40
+
41
+ /**
42
+ * Validates request URL.
43
+ *
44
+ * @throws DOMException
45
+ * @param url URL.
46
+ */
47
+ public static validateURL(url: URL): void {
48
+ if (url.username !== '' || url.password !== '') {
49
+ throw new DOMException(
50
+ `${url} is an url with embedded credentials.`,
51
+ DOMExceptionNameEnum.notSupportedError
52
+ );
53
+ }
54
+ }
55
+
56
+ /**
57
+ * Validates request referrer policy.
58
+ *
59
+ * @throws DOMException
60
+ * @param referrerPolicy Referrer policy.
61
+ */
62
+ public static validateReferrerPolicy(referrerPolicy: IRequestReferrerPolicy): void {
63
+ if (!VALID_REFERRER_POLICIES.includes(referrerPolicy)) {
64
+ throw new DOMException(
65
+ `Invalid referrer policy "${referrerPolicy}".`,
66
+ DOMExceptionNameEnum.syntaxError
67
+ );
68
+ }
69
+ }
70
+
71
+ /**
72
+ * Validates request redirect.
73
+ *
74
+ * @throws DOMException
75
+ * @param redirect Redirect.
76
+ */
77
+ public static validateRedirect(redirect: IRequestRedirect): void {
78
+ if (!VALID_REDIRECTS.includes(redirect)) {
79
+ throw new DOMException(`Invalid redirect "${redirect}".`, DOMExceptionNameEnum.syntaxError);
80
+ }
81
+ }
82
+ }
package/src/file/Blob.ts CHANGED
@@ -8,7 +8,7 @@ import IBlob from './IBlob';
8
8
  * https://github.com/jsdom/jsdom/blob/master/lib/jsdom/living/file-api/Blob-impl.js (MIT licensed).
9
9
  */
10
10
  export default class Blob implements IBlob {
11
- public readonly _buffer: Buffer = null;
11
+ public _buffer: Buffer = null;
12
12
  public readonly type: string = '';
13
13
 
14
14
  /**
@@ -136,7 +136,7 @@ export default class Blob implements IBlob {
136
136
  }
137
137
 
138
138
  /**
139
- * Closes the blob.
139
+ * Returns the object converted to string.
140
140
  *
141
141
  * @returns String.
142
142
  */
package/src/file/File.ts CHANGED
@@ -21,7 +21,11 @@ export default class File extends Blob {
21
21
  * @param [options.lastModifier] Last modified. Defaults to Date.now().
22
22
  * @param options.lastModified
23
23
  */
24
- constructor(bits, name, options?: { type?: string; lastModified?: number }) {
24
+ constructor(
25
+ bits: (ArrayBuffer | ArrayBufferView | Blob | Buffer | string)[],
26
+ name: string,
27
+ options?: { type?: string; lastModified?: number }
28
+ ) {
25
29
  super(bits, options);
26
30
 
27
31
  this.name = name.replace(/\//g, ':');
@@ -0,0 +1,237 @@
1
+ import Blob from '../file/Blob';
2
+ import File from '../file/File';
3
+ import IHTMLInputElement from '../nodes/html-input-element/IHTMLInputElement';
4
+ import IHTMLFormElement from '../nodes/html-form-element/IHTMLFormElement';
5
+ import HTMLFormControlsCollection from '../nodes/html-form-element/HTMLFormControlsCollection';
6
+ import IHTMLTextAreaElement from '../nodes/html-text-area-element/IHTMLTextAreaElement';
7
+ import IHTMLSelectElement from '../nodes/html-select-element/IHTMLSelectElement';
8
+ import IHTMLButtonElement from '../nodes/html-button-element/IHTMLButtonElement';
9
+
10
+ type FormDataEntry = {
11
+ name: string;
12
+ value: string | File;
13
+ };
14
+
15
+ const SUBMITTABLE_ELEMENTS = ['BUTTON', 'INPUT', 'OBJECT', 'SELECT', 'TEXTAREA'];
16
+
17
+ /**
18
+ * FormData.
19
+ *
20
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/FormData
21
+ */
22
+ export default class FormData implements Iterable<[string, string | File]> {
23
+ private _entries: FormDataEntry[] = [];
24
+
25
+ /**
26
+ * Constructor.
27
+ *
28
+ * @param [form] Form.
29
+ */
30
+ constructor(form?: IHTMLFormElement) {
31
+ if (form) {
32
+ for (const name of Object.keys((<HTMLFormControlsCollection>form.elements)._namedItems)) {
33
+ const radioNodeList = (<HTMLFormControlsCollection>form.elements)._namedItems[name];
34
+ let element:
35
+ | IHTMLInputElement
36
+ | IHTMLTextAreaElement
37
+ | IHTMLSelectElement
38
+ | IHTMLButtonElement = radioNodeList[0];
39
+
40
+ if (radioNodeList.length > 1) {
41
+ for (const radioNode of radioNodeList) {
42
+ if (radioNode.checked) {
43
+ element = radioNode;
44
+ }
45
+ }
46
+ }
47
+
48
+ if (element.name && SUBMITTABLE_ELEMENTS.includes(element.tagName)) {
49
+ if (element.tagName === 'INPUT' && element.type === 'file') {
50
+ if ((<IHTMLInputElement>element).files.length === 0) {
51
+ this.append(element.name, new File([], '', { type: 'application/octet-stream' }));
52
+ } else {
53
+ for (const file of (<IHTMLInputElement>element).files) {
54
+ this.append(element.name, file);
55
+ }
56
+ }
57
+ } else {
58
+ this.append(element.name, element.value);
59
+ }
60
+ }
61
+ }
62
+ }
63
+ }
64
+
65
+ /**
66
+ * For each.
67
+ *
68
+ * @param callback Callback.
69
+ */
70
+ public forEach(callback: (key: string, value: string | File, thisArg: FormData) => void): void {
71
+ for (const entry of this._entries) {
72
+ callback.call(this, entry.name, entry.value, this);
73
+ }
74
+ }
75
+
76
+ /**
77
+ * Appends a new value onto an existing key.
78
+ *
79
+ * @param name Name.
80
+ * @param value Value.
81
+ * @param [filename] Filename.
82
+ */
83
+ public append(name: string, value: string | Blob | File, filename?: string): void {
84
+ this._entries.push({
85
+ name,
86
+ value: this._parseValue(value, filename)
87
+ });
88
+ }
89
+
90
+ /**
91
+ * Removes a value.
92
+ *
93
+ * @param name Name.
94
+ */
95
+ public delete(name: string): void {
96
+ const newEntries: FormDataEntry[] = [];
97
+ for (const entry of this._entries) {
98
+ if (entry.name !== name) {
99
+ newEntries.push(entry);
100
+ }
101
+ }
102
+ this._entries = newEntries;
103
+ }
104
+
105
+ /**
106
+ * Returns value.
107
+ *
108
+ * @param name Name.
109
+ * @returns Value.
110
+ */
111
+ public get(name: string): string | File | null {
112
+ for (const entry of this._entries) {
113
+ if (entry.name === name) {
114
+ return entry.value;
115
+ }
116
+ }
117
+ return null;
118
+ }
119
+
120
+ /**
121
+ * Returns all values associated with the given name.
122
+ *
123
+ * @param name Name.
124
+ * @returns Values.
125
+ */
126
+ public getAll(name: string): Array<string | File> {
127
+ const values: Array<string | File> = [];
128
+ for (const entry of this._entries) {
129
+ if (entry.name === name) {
130
+ values.push(entry.value);
131
+ }
132
+ }
133
+ return values;
134
+ }
135
+
136
+ /**
137
+ * Returns whether a FormData object contains a certain key.
138
+ *
139
+ * @param name Name.
140
+ * @returns "true" if the FormData object contains the key.
141
+ */
142
+ public has(name: string): boolean {
143
+ for (const entry of this._entries) {
144
+ if (entry.name === name) {
145
+ return true;
146
+ }
147
+ }
148
+ return false;
149
+ }
150
+
151
+ /**
152
+ * Sets a new value for an existing key inside a FormData object, or adds the key/value if it does not already exist.
153
+ *
154
+ * @param name Name.
155
+ * @param value Value.
156
+ * @param [filename] Filename.
157
+ */
158
+ public set(name: string, value: string | Blob | File, filename?: string): void {
159
+ for (const entry of this._entries) {
160
+ if (entry.name === name) {
161
+ entry.value = this._parseValue(value, filename);
162
+ return;
163
+ }
164
+ }
165
+ this.append(name, value);
166
+ }
167
+
168
+ /**
169
+ * Returns an iterator, allowing you to go through all keys of the key/value pairs contained in this object.
170
+ *
171
+ * @returns Iterator.
172
+ */
173
+ public *keys(): IterableIterator<string> {
174
+ for (const entry of this._entries) {
175
+ yield entry.name;
176
+ }
177
+ }
178
+
179
+ /**
180
+ * Returns an iterator, allowing you to go through all values of the key/value pairs contained in this object.
181
+ *
182
+ * @returns Iterator.
183
+ */
184
+ public *values(): IterableIterator<string | File> {
185
+ for (const entry of this._entries) {
186
+ yield entry.value;
187
+ }
188
+ }
189
+
190
+ /**
191
+ * Returns an iterator, allowing you to go through all key/value pairs contained in this object.
192
+ *
193
+ * @returns Iterator.
194
+ */
195
+ public *entries(): IterableIterator<[string, string | File]> {
196
+ for (const entry of this._entries) {
197
+ yield [entry.name, entry.value];
198
+ }
199
+ }
200
+
201
+ /**
202
+ * Iterator.
203
+ *
204
+ * @returns Iterator.
205
+ */
206
+ public *[Symbol.iterator](): IterableIterator<[string, string | File]> {
207
+ for (const entry of this._entries) {
208
+ yield [entry.name, entry.value];
209
+ }
210
+ }
211
+
212
+ /**
213
+ * Parses a value.
214
+ *
215
+ * @param value Value.
216
+ * @param [filename] Filename.
217
+ * @returns Parsed value.
218
+ */
219
+ private _parseValue(value: string | Blob | File, filename?: string): string | File {
220
+ if (value instanceof Blob && !(value instanceof File)) {
221
+ const file = new File([], 'blob', { type: value.type });
222
+ file._buffer = value._buffer;
223
+ return file;
224
+ }
225
+
226
+ if (value instanceof File) {
227
+ if (filename) {
228
+ const file = new File([], filename, { type: value.type, lastModified: value.lastModified });
229
+ file._buffer = value._buffer;
230
+ return file;
231
+ }
232
+ return value;
233
+ }
234
+
235
+ return String(value);
236
+ }
237
+ }
package/src/index.ts CHANGED
@@ -50,6 +50,9 @@ import SVGDocument from './nodes/svg-document/SVGDocument';
50
50
  import Element from './nodes/element/Element';
51
51
  import IElement from './nodes/element/IElement';
52
52
  import IHTMLCollection from './nodes/element/IHTMLCollection';
53
+ import HTMLCollection from './nodes/element/HTMLCollection';
54
+ import HTMLFormControlsCollection from './nodes/html-form-element/HTMLFormControlsCollection';
55
+ import IHTMLFormControlsCollection from './nodes/html-form-element/IHTMLFormControlsCollection';
53
56
  import HTMLElement from './nodes/html-element/HTMLElement';
54
57
  import IHTMLElement from './nodes/html-element/IHTMLElement';
55
58
  import HTMLTemplateElement from './nodes/html-template-element/HTMLTemplateElement';
@@ -115,6 +118,7 @@ import CSSKeyframeRule from './css/rules/CSSKeyframeRule';
115
118
  import CSSKeyframesRule from './css/rules/CSSKeyframesRule';
116
119
  import CSSMediaRule from './css/rules/CSSMediaRule';
117
120
  import CSSStyleRule from './css/rules/CSSStyleRule';
121
+ import CSSSupportsRule from './css/rules/CSSSupportsRule';
118
122
  import Storage from './storage/Storage';
119
123
  import DOMRect from './nodes/element/DOMRect';
120
124
  import Selection from './selection/Selection';
@@ -127,6 +131,15 @@ import ProcessingInstruction from './nodes/processing-instruction/ProcessingInst
127
131
  import IProcessingInstruction from './nodes/processing-instruction/IProcessingInstruction';
128
132
  import FileList from './nodes/html-input-element/FileList';
129
133
  import IFileList from './nodes/html-input-element/IFileList';
134
+ import AbortController from './fetch/AbortController';
135
+ import AbortSignal from './fetch/AbortSignal';
136
+ import Request from './fetch/Request';
137
+ import IRequest from './fetch/types/IRequest';
138
+ import Response from './fetch/Response';
139
+ import IResponse from './fetch/types/IResponse';
140
+ import Headers from './fetch/Headers';
141
+ import IHeaders from './fetch/types/IHeaders';
142
+ import FormData from './form-data/FormData';
130
143
 
131
144
  export {
132
145
  GlobalWindow,
@@ -181,6 +194,9 @@ export {
181
194
  Element,
182
195
  IElement,
183
196
  IHTMLCollection,
197
+ HTMLCollection,
198
+ HTMLFormControlsCollection,
199
+ IHTMLFormControlsCollection,
184
200
  HTMLElement,
185
201
  IHTMLElement,
186
202
  HTMLTemplateElement,
@@ -246,6 +262,7 @@ export {
246
262
  CSSKeyframesRule,
247
263
  CSSMediaRule,
248
264
  CSSStyleRule,
265
+ CSSSupportsRule,
249
266
  Storage,
250
267
  DOMRect,
251
268
  URLSearchParams,
@@ -258,5 +275,14 @@ export {
258
275
  ProcessingInstruction,
259
276
  IProcessingInstruction,
260
277
  FileList,
261
- IFileList
278
+ IFileList,
279
+ AbortController,
280
+ AbortSignal,
281
+ Request,
282
+ IRequest,
283
+ Response,
284
+ IResponse,
285
+ Headers,
286
+ IHeaders,
287
+ FormData
262
288
  };