happy-dom 8.9.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.
- package/README.md +2 -2
- package/lib/cookie/CookieJar.js +1 -1
- package/lib/cookie/CookieJar.js.map +1 -1
- package/lib/dom-token-list/DOMTokenList.js +24 -20
- package/lib/dom-token-list/DOMTokenList.js.map +1 -1
- package/lib/event/EventTarget.js +6 -3
- package/lib/event/EventTarget.js.map +1 -1
- package/lib/exception/DOMExceptionNameEnum.d.ts +5 -1
- package/lib/exception/DOMExceptionNameEnum.js +4 -0
- package/lib/exception/DOMExceptionNameEnum.js.map +1 -1
- package/lib/fetch/AbortController.d.ts +19 -0
- package/lib/fetch/AbortController.js +30 -0
- package/lib/fetch/AbortController.js.map +1 -0
- package/lib/fetch/AbortSignal.d.ts +25 -0
- package/lib/fetch/AbortSignal.js +51 -0
- package/lib/fetch/AbortSignal.js.map +1 -0
- package/lib/fetch/Fetch.d.ts +117 -0
- package/lib/fetch/Fetch.js +530 -0
- package/lib/fetch/Fetch.js.map +1 -0
- package/lib/fetch/Headers.d.ts +81 -3
- package/lib/fetch/Headers.js +139 -24
- package/lib/fetch/Headers.js.map +1 -1
- package/lib/fetch/Request.d.ts +56 -32
- package/lib/fetch/Request.js +165 -110
- package/lib/fetch/Request.js.map +1 -1
- package/lib/fetch/{ResourceFetchHandler.d.ts → ResourceFetch.d.ts} +1 -1
- package/lib/fetch/{ResourceFetchHandler.js → ResourceFetch.js} +5 -5
- package/lib/fetch/ResourceFetch.js.map +1 -0
- package/lib/fetch/Response.d.ts +60 -26
- package/lib/fetch/Response.js +196 -104
- package/lib/fetch/Response.js.map +1 -1
- package/lib/fetch/data-uri/DataURIParser.d.ts +20 -0
- package/lib/fetch/data-uri/DataURIParser.js +60 -0
- package/lib/fetch/data-uri/DataURIParser.js.map +1 -0
- package/lib/fetch/multipart/MultipartFormDataParser.d.ts +40 -0
- package/lib/fetch/multipart/MultipartFormDataParser.js +81 -0
- package/lib/fetch/multipart/MultipartFormDataParser.js.map +1 -0
- package/lib/fetch/multipart/MultipartReader.d.ts +49 -0
- package/lib/fetch/multipart/MultipartReader.js +178 -0
- package/lib/fetch/multipart/MultipartReader.js.map +1 -0
- package/lib/fetch/types/IHeaders.d.ts +71 -0
- package/lib/fetch/{IHeaders.js.map → types/IHeaders.js.map} +1 -1
- package/lib/fetch/types/IHeadersInit.js.map +1 -0
- package/lib/fetch/types/IRequest.d.ts +60 -0
- package/lib/fetch/{IRequest.js.map → types/IRequest.js.map} +1 -1
- package/lib/fetch/types/IRequestBody.d.ts +7 -0
- package/lib/fetch/{IBody.js → types/IRequestBody.js} +1 -1
- package/lib/fetch/types/IRequestBody.js.map +1 -0
- package/lib/fetch/types/IRequestCredentials.d.ts +2 -0
- package/lib/fetch/types/IRequestCredentials.js +3 -0
- package/lib/fetch/types/IRequestCredentials.js.map +1 -0
- package/lib/fetch/{RequestInfo.d.ts → types/IRequestInfo.d.ts} +2 -2
- package/lib/fetch/types/IRequestInfo.js +3 -0
- package/lib/fetch/types/IRequestInfo.js.map +1 -0
- package/lib/fetch/types/IRequestInit.d.ts +21 -0
- package/lib/fetch/types/IRequestInit.js.map +1 -0
- package/lib/fetch/types/IRequestRedirect.d.ts +2 -0
- package/lib/fetch/types/IRequestRedirect.js +3 -0
- package/lib/fetch/types/IRequestRedirect.js.map +1 -0
- package/lib/fetch/types/IRequestReferrerPolicy.d.ts +2 -0
- package/lib/fetch/types/IRequestReferrerPolicy.js +3 -0
- package/lib/fetch/types/IRequestReferrerPolicy.js.map +1 -0
- package/lib/fetch/types/IResponse.d.ts +27 -0
- package/lib/fetch/{IResponse.js.map → types/IResponse.js.map} +1 -1
- package/lib/fetch/types/IResponseBody.d.ts +7 -0
- package/lib/fetch/types/IResponseBody.js +3 -0
- package/lib/fetch/types/IResponseBody.js.map +1 -0
- package/lib/fetch/types/IResponseInit.d.ts +9 -0
- package/lib/fetch/types/IResponseInit.js.map +1 -0
- package/lib/fetch/utilities/FetchBodyUtility.d.ts +44 -0
- package/lib/fetch/utilities/FetchBodyUtility.js +156 -0
- package/lib/fetch/utilities/FetchBodyUtility.js.map +1 -0
- package/lib/fetch/utilities/FetchCORSUtility.d.ts +12 -0
- package/lib/fetch/utilities/FetchCORSUtility.js +20 -0
- package/lib/fetch/utilities/FetchCORSUtility.js.map +1 -0
- package/lib/fetch/utilities/FetchRequestHeaderUtility.d.ts +12 -0
- package/lib/fetch/utilities/FetchRequestHeaderUtility.js +45 -0
- package/lib/fetch/utilities/FetchRequestHeaderUtility.js.map +1 -0
- package/lib/fetch/utilities/FetchRequestReferrerUtility.d.ts +55 -0
- package/lib/fetch/utilities/FetchRequestReferrerUtility.js +194 -0
- package/lib/fetch/utilities/FetchRequestReferrerUtility.js.map +1 -0
- package/lib/fetch/utilities/FetchRequestValidationUtility.d.ts +38 -0
- package/lib/fetch/utilities/FetchRequestValidationUtility.js +70 -0
- package/lib/fetch/utilities/FetchRequestValidationUtility.js.map +1 -0
- package/lib/file/Blob.d.ts +2 -2
- package/lib/file/Blob.js +1 -1
- package/lib/file/Blob.js.map +1 -1
- package/lib/file/File.d.ts +2 -1
- package/lib/file/File.js.map +1 -1
- package/lib/form-data/FormData.d.ts +98 -0
- package/lib/form-data/FormData.js +212 -0
- package/lib/form-data/FormData.js.map +1 -0
- package/lib/index.d.ts +14 -1
- package/lib/index.js +20 -2
- package/lib/index.js.map +1 -1
- package/lib/nodes/document/Document.d.ts +5 -17
- package/lib/nodes/document/Document.js +11 -54
- package/lib/nodes/document/Document.js.map +1 -1
- package/lib/nodes/document/IDocument.d.ts +1 -1
- package/lib/nodes/document-fragment/DocumentFragment.d.ts +3 -14
- package/lib/nodes/document-fragment/DocumentFragment.js +7 -51
- package/lib/nodes/document-fragment/DocumentFragment.js.map +1 -1
- package/lib/nodes/document-fragment/IDocumentFragment.d.ts +2 -1
- package/lib/nodes/element/Element.d.ts +8 -8
- package/lib/nodes/element/Element.js +28 -45
- package/lib/nodes/element/Element.js.map +1 -1
- package/lib/nodes/element/ElementUtility.d.ts +32 -0
- package/lib/nodes/element/ElementUtility.js +105 -0
- package/lib/nodes/element/ElementUtility.js.map +1 -0
- package/lib/nodes/element/HTMLCollection.d.ts +26 -3
- package/lib/nodes/element/HTMLCollection.js +51 -0
- package/lib/nodes/element/HTMLCollection.js.map +1 -1
- package/lib/nodes/element/IHTMLCollection.d.ts +9 -2
- package/lib/nodes/html-anchor-element/HTMLAnchorElement.js +24 -24
- package/lib/nodes/html-anchor-element/HTMLAnchorElement.js.map +1 -1
- package/lib/nodes/html-base-element/HTMLBaseElement.js +4 -4
- package/lib/nodes/html-base-element/HTMLBaseElement.js.map +1 -1
- package/lib/nodes/html-button-element/HTMLButtonElement.d.ts +79 -3
- package/lib/nodes/html-button-element/HTMLButtonElement.js +158 -10
- package/lib/nodes/html-button-element/HTMLButtonElement.js.map +1 -1
- package/lib/nodes/html-button-element/IHTMLButtonElement.d.ts +28 -2
- package/lib/nodes/html-dialog-element/HTMLDialogElement.js +3 -3
- package/lib/nodes/html-dialog-element/HTMLDialogElement.js.map +1 -1
- package/lib/nodes/html-element/HTMLElement.js +12 -12
- package/lib/nodes/html-element/HTMLElement.js.map +1 -1
- package/lib/nodes/html-form-element/HTMLFormControlsCollection.d.ts +32 -0
- package/lib/nodes/html-form-element/HTMLFormControlsCollection.js +58 -0
- package/lib/nodes/html-form-element/HTMLFormControlsCollection.js.map +1 -0
- package/lib/nodes/html-form-element/HTMLFormElement.d.ts +37 -17
- package/lib/nodes/html-form-element/HTMLFormElement.js +128 -37
- package/lib/nodes/html-form-element/HTMLFormElement.js.map +1 -1
- package/lib/nodes/html-form-element/IHTMLFormControlsCollection.d.ts +25 -0
- package/lib/nodes/html-form-element/IHTMLFormControlsCollection.js +3 -0
- package/lib/nodes/html-form-element/IHTMLFormControlsCollection.js.map +1 -0
- package/lib/nodes/html-form-element/IHTMLFormElement.d.ts +16 -6
- package/lib/nodes/html-form-element/IRadioNodeList.d.ts +15 -0
- package/lib/nodes/html-form-element/IRadioNodeList.js +3 -0
- package/lib/nodes/html-form-element/IRadioNodeList.js.map +1 -0
- package/lib/nodes/html-form-element/RadioNodeList.d.ts +16 -0
- package/lib/nodes/html-form-element/RadioNodeList.js +28 -0
- package/lib/nodes/html-form-element/RadioNodeList.js.map +1 -0
- package/lib/nodes/html-image-element/HTMLImageElement.js +19 -19
- package/lib/nodes/html-image-element/HTMLImageElement.js.map +1 -1
- package/lib/nodes/html-input-element/HTMLInputElement.d.ts +43 -19
- package/lib/nodes/html-input-element/HTMLInputElement.js +206 -111
- package/lib/nodes/html-input-element/HTMLInputElement.js.map +1 -1
- package/lib/nodes/html-input-element/IHTMLInputElement.d.ts +14 -1
- package/lib/nodes/html-label-element/HTMLLabelElement.js +3 -7
- package/lib/nodes/html-label-element/HTMLLabelElement.js.map +1 -1
- package/lib/nodes/html-link-element/HTMLLinkElement.js +21 -21
- package/lib/nodes/html-link-element/HTMLLinkElement.js.map +1 -1
- package/lib/nodes/html-media-element/HTMLMediaElement.js +21 -21
- package/lib/nodes/html-media-element/HTMLMediaElement.js.map +1 -1
- package/lib/nodes/html-meta-element/HTMLMetaElement.js +8 -8
- package/lib/nodes/html-meta-element/HTMLMetaElement.js.map +1 -1
- package/lib/nodes/html-opt-group-element/HTMLOptGroupElement.js +6 -6
- package/lib/nodes/html-opt-group-element/HTMLOptGroupElement.js.map +1 -1
- package/lib/nodes/html-option-element/HTMLOptionElement.d.ts +3 -4
- package/lib/nodes/html-option-element/HTMLOptionElement.js +26 -29
- package/lib/nodes/html-option-element/HTMLOptionElement.js.map +1 -1
- package/lib/nodes/html-script-element/HTMLScriptElement.js +16 -16
- package/lib/nodes/html-script-element/HTMLScriptElement.js.map +1 -1
- package/lib/nodes/html-script-element/ScriptUtility.js +5 -5
- package/lib/nodes/html-script-element/ScriptUtility.js.map +1 -1
- package/lib/nodes/{html-option-element → html-select-element}/HTMLOptionsCollection.d.ts +5 -6
- package/lib/nodes/{html-option-element → html-select-element}/HTMLOptionsCollection.js.map +1 -1
- package/lib/nodes/html-select-element/HTMLSelectElement.d.ts +42 -41
- package/lib/nodes/html-select-element/HTMLSelectElement.js +134 -138
- package/lib/nodes/html-select-element/HTMLSelectElement.js.map +1 -1
- package/lib/nodes/{html-option-element → html-select-element}/IHTMLOptionsCollection.d.ts +4 -5
- package/lib/nodes/html-select-element/IHTMLOptionsCollection.js.map +1 -0
- package/lib/nodes/html-select-element/IHTMLSelectElement.d.ts +22 -2
- package/lib/nodes/html-slot-element/HTMLSlotElement.js +2 -2
- package/lib/nodes/html-slot-element/HTMLSlotElement.js.map +1 -1
- package/lib/nodes/html-style-element/HTMLStyleElement.js +7 -7
- package/lib/nodes/html-style-element/HTMLStyleElement.js.map +1 -1
- package/lib/nodes/html-text-area-element/HTMLTextAreaElement.d.ts +55 -2
- package/lib/nodes/html-text-area-element/HTMLTextAreaElement.js +150 -40
- package/lib/nodes/html-text-area-element/HTMLTextAreaElement.js.map +1 -1
- package/lib/nodes/html-text-area-element/IHTMLTextAreaElement.d.ts +16 -0
- package/lib/nodes/node/Node.d.ts +12 -1
- package/lib/nodes/node/Node.js +50 -4
- package/lib/nodes/node/Node.js.map +1 -1
- package/lib/nodes/node/NodeList.d.ts +2 -3
- package/lib/nodes/node/NodeList.js.map +1 -1
- package/lib/nodes/parent-node/IParentNode.d.ts +4 -4
- package/lib/nodes/parent-node/ParentNodeUtility.d.ts +3 -3
- package/lib/nodes/parent-node/ParentNodeUtility.js +13 -11
- package/lib/nodes/parent-node/ParentNodeUtility.js.map +1 -1
- package/lib/nodes/text/Text.d.ts +13 -0
- package/lib/nodes/text/Text.js +30 -0
- package/lib/nodes/text/Text.js.map +1 -1
- package/lib/query-selector/QuerySelector.js +2 -2
- package/lib/query-selector/QuerySelector.js.map +1 -1
- package/lib/query-selector/SelectorItem.js +2 -0
- package/lib/query-selector/SelectorItem.js.map +1 -1
- package/lib/validity-state/ValidityState.d.ts +87 -0
- package/lib/validity-state/ValidityState.js +171 -0
- package/lib/validity-state/ValidityState.js.map +1 -0
- package/lib/window/GlobalWindow.d.ts +0 -8
- package/lib/window/GlobalWindow.js +0 -2
- package/lib/window/GlobalWindow.js.map +1 -1
- package/lib/window/INodeJSGlobal.d.ts +71 -0
- package/lib/window/INodeJSGlobal.js +2 -0
- package/lib/window/INodeJSGlobal.js.map +1 -0
- package/lib/window/IWindow.d.ts +30 -10
- package/lib/window/Window.d.ts +36 -20
- package/lib/window/Window.js +16 -9
- package/lib/window/Window.js.map +1 -1
- package/lib/xml-http-request/XMLHttpRequest.js +20 -12
- package/lib/xml-http-request/XMLHttpRequest.js.map +1 -1
- package/lib/xml-parser/XMLParser.js +1 -1
- package/lib/xml-parser/XMLParser.js.map +1 -1
- package/package.json +2 -3
- package/src/cookie/CookieJar.ts +1 -1
- package/src/dom-token-list/DOMTokenList.ts +24 -20
- package/src/event/EventTarget.ts +7 -3
- package/src/exception/DOMExceptionNameEnum.ts +5 -1
- package/src/fetch/AbortController.ts +26 -0
- package/src/fetch/AbortSignal.ts +44 -0
- package/src/fetch/Fetch.ts +666 -0
- package/src/fetch/Headers.ts +151 -3
- package/src/fetch/Request.ts +226 -94
- package/src/fetch/{ResourceFetchHandler.ts → ResourceFetch.ts} +3 -3
- package/src/fetch/Response.ts +252 -89
- package/src/fetch/data-uri/DataURIParser.ts +66 -0
- package/src/fetch/multipart/MultipartFormDataParser.ts +113 -0
- package/src/fetch/multipart/MultipartReader.ts +217 -0
- package/src/fetch/types/IHeaders.ts +80 -0
- package/src/fetch/types/IRequest.ts +65 -0
- package/src/fetch/types/IRequestBody.ts +15 -0
- package/src/fetch/types/IRequestCredentials.ts +2 -0
- package/src/fetch/types/IRequestInfo.ts +6 -0
- package/src/fetch/types/IRequestInit.ts +21 -0
- package/src/fetch/types/IRequestRedirect.ts +3 -0
- package/src/fetch/types/IRequestReferrerPolicy.ts +11 -0
- package/src/fetch/types/IResponse.ts +27 -0
- package/src/fetch/types/IResponseBody.ts +15 -0
- package/src/fetch/types/IResponseInit.ts +10 -0
- package/src/fetch/utilities/FetchBodyUtility.ts +175 -0
- package/src/fetch/utilities/FetchCORSUtility.ts +18 -0
- package/src/fetch/utilities/FetchRequestHeaderUtility.ts +47 -0
- package/src/fetch/utilities/FetchRequestReferrerUtility.ts +241 -0
- package/src/fetch/utilities/FetchRequestValidationUtility.ts +82 -0
- package/src/file/Blob.ts +2 -2
- package/src/file/File.ts +5 -1
- package/src/form-data/FormData.ts +237 -0
- package/src/index.ts +27 -1
- package/src/nodes/document/Document.ts +23 -64
- package/src/nodes/document/IDocument.ts +1 -1
- package/src/nodes/document-fragment/DocumentFragment.ts +9 -59
- package/src/nodes/document-fragment/IDocumentFragment.ts +2 -1
- package/src/nodes/element/Element.ts +43 -56
- package/src/nodes/element/ElementUtility.ts +137 -0
- package/src/nodes/element/HTMLCollection.ts +60 -3
- package/src/nodes/element/IHTMLCollection.ts +10 -2
- package/src/nodes/html-anchor-element/HTMLAnchorElement.ts +24 -24
- package/src/nodes/html-base-element/HTMLBaseElement.ts +4 -4
- package/src/nodes/html-button-element/HTMLButtonElement.ts +184 -10
- package/src/nodes/html-button-element/IHTMLButtonElement.ts +31 -2
- package/src/nodes/html-dialog-element/HTMLDialogElement.ts +3 -3
- package/src/nodes/html-element/HTMLElement.ts +12 -12
- package/src/nodes/html-form-element/HTMLFormControlsCollection.ts +76 -0
- package/src/nodes/html-form-element/HTMLFormElement.ts +147 -41
- package/src/nodes/html-form-element/IHTMLFormControlsCollection.ts +45 -0
- package/src/nodes/html-form-element/IHTMLFormElement.ts +17 -6
- package/src/nodes/html-form-element/IRadioNodeList.ts +16 -0
- package/src/nodes/html-form-element/RadioNodeList.ts +24 -0
- package/src/nodes/html-image-element/HTMLImageElement.ts +19 -19
- package/src/nodes/html-input-element/HTMLInputElement.ts +232 -113
- package/src/nodes/html-input-element/IHTMLInputElement.ts +20 -1
- package/src/nodes/html-label-element/HTMLLabelElement.ts +3 -7
- package/src/nodes/html-link-element/HTMLLinkElement.ts +21 -21
- package/src/nodes/html-media-element/HTMLMediaElement.ts +21 -21
- package/src/nodes/html-meta-element/HTMLMetaElement.ts +8 -8
- package/src/nodes/html-opt-group-element/HTMLOptGroupElement.ts +6 -6
- package/src/nodes/html-option-element/HTMLOptionElement.ts +29 -30
- package/src/nodes/html-script-element/HTMLScriptElement.ts +16 -16
- package/src/nodes/html-script-element/ScriptUtility.ts +5 -5
- package/src/nodes/{html-option-element → html-select-element}/HTMLOptionsCollection.ts +5 -9
- package/src/nodes/html-select-element/HTMLSelectElement.ts +159 -170
- package/src/nodes/{html-option-element → html-select-element}/IHTMLOptionsCollection.ts +4 -8
- package/src/nodes/html-select-element/IHTMLSelectElement.ts +25 -2
- package/src/nodes/html-slot-element/HTMLSlotElement.ts +2 -2
- package/src/nodes/html-style-element/HTMLStyleElement.ts +7 -7
- package/src/nodes/html-text-area-element/HTMLTextAreaElement.ts +174 -41
- package/src/nodes/html-text-area-element/IHTMLTextAreaElement.ts +18 -0
- package/src/nodes/node/Node.ts +61 -6
- package/src/nodes/node/NodeList.ts +2 -3
- package/src/nodes/parent-node/IParentNode.ts +7 -4
- package/src/nodes/parent-node/ParentNodeUtility.ts +25 -15
- package/src/nodes/text/Text.ts +38 -0
- package/src/query-selector/QuerySelector.ts +2 -2
- package/src/query-selector/SelectorItem.ts +3 -0
- package/src/validity-state/ValidityState.ts +211 -0
- package/src/window/GlobalWindow.ts +0 -2
- package/src/window/INodeJSGlobal.ts +70 -0
- package/src/window/IWindow.ts +32 -10
- package/src/window/Window.ts +37 -20
- package/src/xml-http-request/XMLHttpRequest.ts +27 -26
- package/src/xml-parser/XMLParser.ts +1 -1
- package/lib/fetch/FetchHandler.d.ts +0 -18
- package/lib/fetch/FetchHandler.js +0 -83
- package/lib/fetch/FetchHandler.js.map +0 -1
- package/lib/fetch/IAbortSignal.d.ts +0 -16
- package/lib/fetch/IAbortSignal.js +0 -4
- package/lib/fetch/IAbortSignal.js.map +0 -1
- package/lib/fetch/IBody.d.ts +0 -17
- package/lib/fetch/IBody.js.map +0 -1
- package/lib/fetch/IHeaders.d.ts +0 -18
- package/lib/fetch/IHeadersInit.js.map +0 -1
- package/lib/fetch/IRequest.d.ts +0 -18
- package/lib/fetch/IRequestInit.d.ts +0 -16
- package/lib/fetch/IRequestInit.js.map +0 -1
- package/lib/fetch/IResponse.d.ts +0 -20
- package/lib/fetch/IResponseInit.d.ts +0 -9
- package/lib/fetch/IResponseInit.js.map +0 -1
- package/lib/fetch/RequestInfo.js +0 -3
- package/lib/fetch/RequestInfo.js.map +0 -1
- package/lib/fetch/ResourceFetchHandler.js.map +0 -1
- package/lib/form-data/IFormData.d.ts +0 -32
- package/lib/form-data/IFormData.js +0 -3
- package/lib/form-data/IFormData.js.map +0 -1
- package/lib/location/RelativeURL.d.ts +0 -15
- package/lib/location/RelativeURL.js +0 -19
- package/lib/location/RelativeURL.js.map +0 -1
- package/lib/nodes/element/HTMLCollectionFactory.d.ts +0 -21
- package/lib/nodes/element/HTMLCollectionFactory.js +0 -31
- package/lib/nodes/element/HTMLCollectionFactory.js.map +0 -1
- package/lib/nodes/html-option-element/IHTMLOptionsCollection.js.map +0 -1
- package/lib/nodes/node/NodeListFactory.d.ts +0 -21
- package/lib/nodes/node/NodeListFactory.js +0 -31
- package/lib/nodes/node/NodeListFactory.js.map +0 -1
- package/lib/nodes/validity-state/ValidityState.d.ts +0 -52
- package/lib/nodes/validity-state/ValidityState.js +0 -81
- package/lib/nodes/validity-state/ValidityState.js.map +0 -1
- package/src/fetch/FetchHandler.ts +0 -90
- package/src/fetch/IAbortSignal.ts +0 -34
- package/src/fetch/IBody.ts +0 -18
- package/src/fetch/IHeaders.ts +0 -18
- package/src/fetch/IRequest.ts +0 -59
- package/src/fetch/IRequestInit.ts +0 -41
- package/src/fetch/IResponse.ts +0 -22
- package/src/fetch/IResponseInit.ts +0 -10
- package/src/fetch/RequestInfo.ts +0 -6
- package/src/form-data/IFormData.ts +0 -33
- package/src/location/RelativeURL.ts +0 -17
- package/src/nodes/element/HTMLCollectionFactory.ts +0 -31
- package/src/nodes/node/NodeListFactory.ts +0 -31
- package/src/nodes/validity-state/ValidityState.ts +0 -84
- /package/lib/fetch/{IHeaders.js → types/IHeaders.js} +0 -0
- /package/lib/fetch/{IHeadersInit.d.ts → types/IHeadersInit.d.ts} +0 -0
- /package/lib/fetch/{IHeadersInit.js → types/IHeadersInit.js} +0 -0
- /package/lib/fetch/{IRequest.js → types/IRequest.js} +0 -0
- /package/lib/fetch/{IRequestInit.js → types/IRequestInit.js} +0 -0
- /package/lib/fetch/{IResponse.js → types/IResponse.js} +0 -0
- /package/lib/fetch/{IResponseInit.js → types/IResponseInit.js} +0 -0
- /package/lib/nodes/{html-option-element → html-select-element}/HTMLOptionsCollection.js +0 -0
- /package/lib/nodes/{html-option-element → html-select-element}/IHTMLOptionsCollection.js +0 -0
- /package/src/fetch/{IHeadersInit.ts → types/IHeadersInit.ts} +0 -0
package/src/fetch/Headers.ts
CHANGED
@@ -1,7 +1,155 @@
|
|
1
|
-
import
|
2
|
-
import
|
1
|
+
import DOMException from '../exception/DOMException';
|
2
|
+
import DOMExceptionNameEnum from '../exception/DOMExceptionNameEnum';
|
3
|
+
import IHeaders from './types/IHeaders';
|
4
|
+
import IHeadersInit from './types/IHeadersInit';
|
3
5
|
|
4
6
|
/**
|
5
7
|
* Fetch headers.
|
8
|
+
*
|
9
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/Headers
|
6
10
|
*/
|
7
|
-
export default class Headers
|
11
|
+
export default class Headers implements IHeaders {
|
12
|
+
public _entries: { [k: string]: { name: string; value: string } } = {};
|
13
|
+
|
14
|
+
/**
|
15
|
+
* Constructor.
|
16
|
+
*
|
17
|
+
* @param init Headers init.
|
18
|
+
*/
|
19
|
+
constructor(init?: IHeadersInit) {
|
20
|
+
if (init) {
|
21
|
+
if (init instanceof Headers) {
|
22
|
+
this._entries = JSON.parse(JSON.stringify(init._entries));
|
23
|
+
} else if (Array.isArray(init)) {
|
24
|
+
for (const entry of init) {
|
25
|
+
if (entry.length !== 2) {
|
26
|
+
throw new DOMException(
|
27
|
+
'Failed to construct "Headers": The provided init is not a valid array.',
|
28
|
+
DOMExceptionNameEnum.invalidStateError
|
29
|
+
);
|
30
|
+
}
|
31
|
+
this.append(entry[0], entry[1]);
|
32
|
+
}
|
33
|
+
} else {
|
34
|
+
for (const name of Object.keys(init)) {
|
35
|
+
this.set(name, init[name]);
|
36
|
+
}
|
37
|
+
}
|
38
|
+
}
|
39
|
+
}
|
40
|
+
|
41
|
+
/**
|
42
|
+
* Appends a new value onto an existing header inside a Headers object, or adds the header if it does not already exist.
|
43
|
+
*
|
44
|
+
* @param name Name.
|
45
|
+
* @param value Value.
|
46
|
+
*/
|
47
|
+
public append(name: string, value: string): void {
|
48
|
+
const lowerName = name.toLowerCase();
|
49
|
+
if (this._entries[lowerName]) {
|
50
|
+
this._entries[lowerName].value += `, ${value}`;
|
51
|
+
} else {
|
52
|
+
this._entries[lowerName] = {
|
53
|
+
name,
|
54
|
+
value
|
55
|
+
};
|
56
|
+
}
|
57
|
+
}
|
58
|
+
|
59
|
+
/**
|
60
|
+
* Removes an header.
|
61
|
+
*
|
62
|
+
* @param name Name.
|
63
|
+
*/
|
64
|
+
public delete(name: string): void {
|
65
|
+
delete this._entries[name.toLowerCase()];
|
66
|
+
}
|
67
|
+
|
68
|
+
/**
|
69
|
+
* Returns header value.
|
70
|
+
*
|
71
|
+
* @param name Name.
|
72
|
+
* @returns Value.
|
73
|
+
*/
|
74
|
+
public get(name: string): string | null {
|
75
|
+
return this._entries[name.toLowerCase()]?.value || null;
|
76
|
+
}
|
77
|
+
|
78
|
+
/**
|
79
|
+
* Sets a new value for an existing header inside a Headers object, or adds the header if it does not already exist.
|
80
|
+
*
|
81
|
+
* @param name Name.
|
82
|
+
* @param value Value.
|
83
|
+
*/
|
84
|
+
public set(name: string, value: string): void {
|
85
|
+
this._entries[name.toLowerCase()] = {
|
86
|
+
name,
|
87
|
+
value
|
88
|
+
};
|
89
|
+
}
|
90
|
+
|
91
|
+
/**
|
92
|
+
* Returns whether an Headers object contains a certain key.
|
93
|
+
*
|
94
|
+
* @param name Name.
|
95
|
+
* @returns "true" if the Headers object contains the key.
|
96
|
+
*/
|
97
|
+
public has(name: string): boolean {
|
98
|
+
return !!this._entries[name.toLowerCase()];
|
99
|
+
}
|
100
|
+
|
101
|
+
/**
|
102
|
+
* Executes a callback function once per each key/value pair in the Headers object.
|
103
|
+
*
|
104
|
+
* @param callback Callback.
|
105
|
+
*/
|
106
|
+
public forEach(callback: (name: string, value: string, thisArg: IHeaders) => void): void {
|
107
|
+
for (const key of Object.keys(this._entries)) {
|
108
|
+
callback(this._entries[key].value, this._entries[key].name, this);
|
109
|
+
}
|
110
|
+
}
|
111
|
+
|
112
|
+
/**
|
113
|
+
* Returns an iterator, allowing you to go through all keys of the key/value pairs contained in this object.
|
114
|
+
*
|
115
|
+
* @returns Iterator.
|
116
|
+
*/
|
117
|
+
public *keys(): IterableIterator<string> {
|
118
|
+
for (const header of Object.values(this._entries)) {
|
119
|
+
yield header.name;
|
120
|
+
}
|
121
|
+
}
|
122
|
+
|
123
|
+
/**
|
124
|
+
* Returns an iterator, allowing you to go through all values of the key/value pairs contained in this object.
|
125
|
+
*
|
126
|
+
* @returns Iterator.
|
127
|
+
*/
|
128
|
+
public *values(): IterableIterator<string> {
|
129
|
+
for (const header of Object.values(this._entries)) {
|
130
|
+
yield header.value;
|
131
|
+
}
|
132
|
+
}
|
133
|
+
|
134
|
+
/**
|
135
|
+
* Returns an iterator, allowing you to go through all key/value pairs contained in this object.
|
136
|
+
*
|
137
|
+
* @returns Iterator.
|
138
|
+
*/
|
139
|
+
public *entries(): IterableIterator<[string, string]> {
|
140
|
+
for (const header of Object.values(this._entries)) {
|
141
|
+
yield [header.name, header.value];
|
142
|
+
}
|
143
|
+
}
|
144
|
+
|
145
|
+
/**
|
146
|
+
* Iterator.
|
147
|
+
*
|
148
|
+
* @returns Iterator.
|
149
|
+
*/
|
150
|
+
public *[Symbol.iterator](): IterableIterator<[string, string]> {
|
151
|
+
for (const header of Object.values(this._entries)) {
|
152
|
+
yield [header.name, header.value];
|
153
|
+
}
|
154
|
+
}
|
155
|
+
}
|
package/src/fetch/Request.ts
CHANGED
@@ -1,159 +1,291 @@
|
|
1
|
-
import * as NodeFetch from 'node-fetch';
|
2
|
-
import IRequest from './IRequest';
|
3
1
|
import IBlob from '../file/IBlob';
|
4
2
|
import IDocument from '../nodes/document/IDocument';
|
3
|
+
import IRequestInit from './types/IRequestInit';
|
4
|
+
import { URL } from 'url';
|
5
|
+
import DOMException from '../exception/DOMException';
|
6
|
+
import DOMExceptionNameEnum from '../exception/DOMExceptionNameEnum';
|
7
|
+
import IRequestInfo from './types/IRequestInfo';
|
8
|
+
import IRequest from './types/IRequest';
|
9
|
+
import Headers from './Headers';
|
10
|
+
import FetchBodyUtility from './utilities/FetchBodyUtility';
|
11
|
+
import AbortSignal from './AbortSignal';
|
12
|
+
import Stream from 'stream';
|
13
|
+
import Blob from '../file/Blob';
|
14
|
+
import { TextDecoder } from 'util';
|
15
|
+
import FetchRequestValidationUtility from './utilities/FetchRequestValidationUtility';
|
16
|
+
import IRequestReferrerPolicy from './types/IRequestReferrerPolicy';
|
17
|
+
import IRequestRedirect from './types/IRequestRedirect';
|
18
|
+
import FetchRequestReferrerUtility from './utilities/FetchRequestReferrerUtility';
|
19
|
+
import FetchRequestHeaderUtility from './utilities/FetchRequestHeaderUtility';
|
20
|
+
import IRequestCredentials from './types/IRequestCredentials';
|
5
21
|
|
6
22
|
/**
|
7
23
|
* Fetch request.
|
24
|
+
*
|
25
|
+
* Based on:
|
26
|
+
* https://github.com/node-fetch/node-fetch/blob/main/src/request.js
|
27
|
+
*
|
28
|
+
* @see https://fetch.spec.whatwg.org/#request-class
|
8
29
|
*/
|
9
|
-
export default class Request
|
30
|
+
export default class Request implements IRequest {
|
10
31
|
// Owner document is set by a sub-class in the Window constructor
|
11
32
|
public static _ownerDocument: IDocument = null;
|
12
33
|
public readonly _ownerDocument: IDocument = null;
|
13
34
|
|
35
|
+
// Public properties
|
36
|
+
public readonly method: string;
|
37
|
+
public readonly body: Stream.Readable | null;
|
38
|
+
public readonly headers: Headers;
|
39
|
+
public readonly redirect: IRequestRedirect;
|
40
|
+
public readonly referrerPolicy: IRequestReferrerPolicy;
|
41
|
+
public readonly signal: AbortSignal;
|
42
|
+
public readonly bodyUsed: boolean = false;
|
43
|
+
public readonly credentials: IRequestCredentials;
|
44
|
+
|
45
|
+
// Internal properties
|
46
|
+
public readonly _contentLength: number | null = null;
|
47
|
+
public readonly _contentType: string | null = null;
|
48
|
+
public _referrer: '' | 'no-referrer' | 'client' | URL = 'client';
|
49
|
+
public readonly _url: URL;
|
50
|
+
public readonly _bodyBuffer: Buffer | null;
|
51
|
+
|
14
52
|
/**
|
15
53
|
* Constructor.
|
16
54
|
*
|
17
55
|
* @param input Input.
|
18
56
|
* @param [init] Init.
|
19
57
|
*/
|
20
|
-
constructor(input:
|
21
|
-
super(input, init);
|
58
|
+
constructor(input: IRequestInfo, init?: IRequestInit) {
|
22
59
|
this._ownerDocument = (<typeof Request>this.constructor)._ownerDocument;
|
60
|
+
|
61
|
+
if (!input) {
|
62
|
+
throw new TypeError(`Failed to contruct 'Request': 1 argument required, only 0 present.`);
|
63
|
+
}
|
64
|
+
|
65
|
+
this.method = (init?.method || (<Request>input).method || 'GET').toUpperCase();
|
66
|
+
|
67
|
+
const { stream, buffer, contentType, contentLength } = FetchBodyUtility.getBodyStream(
|
68
|
+
input instanceof Request && (input._bodyBuffer || input.body)
|
69
|
+
? input._bodyBuffer || FetchBodyUtility.cloneRequestBodyStream(input)
|
70
|
+
: init?.body
|
71
|
+
);
|
72
|
+
|
73
|
+
this._bodyBuffer = buffer;
|
74
|
+
this.body = stream;
|
75
|
+
this.credentials = init?.credentials || (<Request>input).credentials || 'same-origin';
|
76
|
+
this.headers = new Headers(init?.headers || (<Request>input).headers || {});
|
77
|
+
|
78
|
+
FetchRequestHeaderUtility.removeForbiddenHeaders(this.headers);
|
79
|
+
|
80
|
+
if (contentLength) {
|
81
|
+
this._contentLength = contentLength;
|
82
|
+
} else if (!this.body && (this.method === 'POST' || this.method === 'PUT')) {
|
83
|
+
this._contentLength = 0;
|
84
|
+
}
|
85
|
+
|
86
|
+
if (contentType) {
|
87
|
+
this._contentType = contentType;
|
88
|
+
} else if (input instanceof Request && input._contentType) {
|
89
|
+
this._contentType = input._contentType;
|
90
|
+
}
|
91
|
+
|
92
|
+
this.redirect = init?.redirect || (<Request>input).redirect || 'follow';
|
93
|
+
this.referrerPolicy = <IRequestReferrerPolicy>(
|
94
|
+
(init?.referrerPolicy || (<Request>input).referrerPolicy || '').toLowerCase()
|
95
|
+
);
|
96
|
+
this.signal = init?.signal || (<Request>input).signal || new AbortSignal();
|
97
|
+
this._referrer = FetchRequestReferrerUtility.getInitialReferrer(
|
98
|
+
this._ownerDocument,
|
99
|
+
init?.referrer !== null && init?.referrer !== undefined
|
100
|
+
? init?.referrer
|
101
|
+
: (<Request>input).referrer
|
102
|
+
);
|
103
|
+
|
104
|
+
if (input instanceof URL) {
|
105
|
+
this._url = input;
|
106
|
+
} else {
|
107
|
+
try {
|
108
|
+
if (input instanceof Request && input.url) {
|
109
|
+
this._url = new URL(input.url, this._ownerDocument.location);
|
110
|
+
} else {
|
111
|
+
this._url = new URL(<string>input, this._ownerDocument.location);
|
112
|
+
}
|
113
|
+
} catch (error) {
|
114
|
+
throw new DOMException(
|
115
|
+
`Failed to construct 'Request. Invalid URL "${input}" on document location '${
|
116
|
+
this._ownerDocument.location
|
117
|
+
}'.${
|
118
|
+
this._ownerDocument.location.origin === 'null'
|
119
|
+
? ' Relative URLs are not permitted on current document location.'
|
120
|
+
: ''
|
121
|
+
}`,
|
122
|
+
DOMExceptionNameEnum.notSupportedError
|
123
|
+
);
|
124
|
+
}
|
125
|
+
}
|
126
|
+
|
127
|
+
FetchRequestValidationUtility.validateBody(this);
|
128
|
+
FetchRequestValidationUtility.validateURL(this._url);
|
129
|
+
FetchRequestValidationUtility.validateReferrerPolicy(this.referrerPolicy);
|
130
|
+
FetchRequestValidationUtility.validateRedirect(this.redirect);
|
23
131
|
}
|
24
132
|
|
25
133
|
/**
|
26
|
-
* Returns
|
134
|
+
* Returns referrer.
|
27
135
|
*
|
28
|
-
* @returns
|
136
|
+
* @returns Referrer.
|
29
137
|
*/
|
30
|
-
public
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
}
|
138
|
+
public get referrer(): string {
|
139
|
+
if (!this._referrer || this._referrer === 'no-referrer') {
|
140
|
+
return '';
|
141
|
+
}
|
142
|
+
|
143
|
+
if (this._referrer === 'client') {
|
144
|
+
return 'about:client';
|
145
|
+
}
|
146
|
+
|
147
|
+
return this._referrer.toString();
|
38
148
|
}
|
39
149
|
|
40
150
|
/**
|
41
|
-
* Returns
|
151
|
+
* Returns URL.
|
42
152
|
*
|
43
|
-
* @returns
|
153
|
+
* @returns URL.
|
44
154
|
*/
|
45
|
-
public
|
46
|
-
return
|
47
|
-
const taskID = this._handlePromiseStart();
|
48
|
-
super
|
49
|
-
.blob()
|
50
|
-
.then(this._handlePromiseEnd.bind(this, resolve, reject, taskID))
|
51
|
-
.catch(this._handlePromiseError.bind(this, reject));
|
52
|
-
});
|
155
|
+
public get url(): string {
|
156
|
+
return this._url.href;
|
53
157
|
}
|
54
158
|
|
55
159
|
/**
|
56
|
-
* Returns
|
160
|
+
* Returns string tag.
|
57
161
|
*
|
58
|
-
* @returns
|
162
|
+
* @returns String tag.
|
59
163
|
*/
|
60
|
-
public
|
61
|
-
return
|
62
|
-
const taskID = this._handlePromiseStart();
|
63
|
-
super
|
64
|
-
.buffer()
|
65
|
-
.then(this._handlePromiseEnd.bind(this, resolve, reject, taskID))
|
66
|
-
.catch(this._handlePromiseError.bind(this, reject));
|
67
|
-
});
|
164
|
+
public get [Symbol.toStringTag](): string {
|
165
|
+
return 'Request';
|
68
166
|
}
|
69
167
|
|
70
168
|
/**
|
71
|
-
* Returns
|
169
|
+
* Returns array buffer.
|
72
170
|
*
|
73
|
-
* @returns
|
171
|
+
* @returns Array buffer.
|
74
172
|
*/
|
75
|
-
public
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
.
|
80
|
-
|
81
|
-
|
82
|
-
|
173
|
+
public async arrayBuffer(): Promise<ArrayBuffer> {
|
174
|
+
if (this.bodyUsed) {
|
175
|
+
throw new DOMException(
|
176
|
+
`Body has already been used for "${this.url}".`,
|
177
|
+
DOMExceptionNameEnum.invalidStateError
|
178
|
+
);
|
179
|
+
}
|
180
|
+
|
181
|
+
(<boolean>this.bodyUsed) = true;
|
182
|
+
|
183
|
+
const taskManager = this._ownerDocument.defaultView.happyDOM.asyncTaskManager;
|
184
|
+
const taskID = taskManager.startTask(() => this.signal._abort());
|
185
|
+
let buffer: Buffer;
|
186
|
+
|
187
|
+
try {
|
188
|
+
buffer = await FetchBodyUtility.consumeBodyStream(this.body);
|
189
|
+
} catch (error) {
|
190
|
+
taskManager.endTask(taskID);
|
191
|
+
throw error;
|
192
|
+
}
|
193
|
+
|
194
|
+
taskManager.endTask(taskID);
|
195
|
+
|
196
|
+
return buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength);
|
83
197
|
}
|
84
198
|
|
85
199
|
/**
|
86
|
-
* Returns
|
200
|
+
* Returns blob.
|
87
201
|
*
|
88
|
-
* @returns
|
202
|
+
* @returns Blob.
|
89
203
|
*/
|
90
|
-
public
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
.then(this._handlePromiseEnd.bind(this, resolve, reject, taskID))
|
96
|
-
.catch(this._handlePromiseError.bind(this, reject));
|
97
|
-
});
|
204
|
+
public async blob(): Promise<IBlob> {
|
205
|
+
const type = this.headers.get('content-type') || '';
|
206
|
+
const buffer = await this.arrayBuffer();
|
207
|
+
|
208
|
+
return new Blob([buffer], { type });
|
98
209
|
}
|
99
210
|
|
100
211
|
/**
|
101
|
-
* Returns
|
212
|
+
* Returns buffer.
|
102
213
|
*
|
103
|
-
* @returns
|
214
|
+
* @returns Buffer.
|
104
215
|
*/
|
105
|
-
public
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
.
|
110
|
-
|
111
|
-
|
112
|
-
|
216
|
+
public async buffer(): Promise<Buffer> {
|
217
|
+
if (this.bodyUsed) {
|
218
|
+
throw new DOMException(
|
219
|
+
`Body has already been used for "${this.url}".`,
|
220
|
+
DOMExceptionNameEnum.invalidStateError
|
221
|
+
);
|
222
|
+
}
|
223
|
+
|
224
|
+
(<boolean>this.bodyUsed) = true;
|
225
|
+
|
226
|
+
const taskManager = this._ownerDocument.defaultView.happyDOM.asyncTaskManager;
|
227
|
+
const taskID = taskManager.startTask(() => this.signal._abort());
|
228
|
+
let buffer: Buffer;
|
229
|
+
|
230
|
+
try {
|
231
|
+
buffer = await FetchBodyUtility.consumeBodyStream(this.body);
|
232
|
+
} catch (error) {
|
233
|
+
taskManager.endTask(taskID);
|
234
|
+
throw error;
|
235
|
+
}
|
236
|
+
|
237
|
+
taskManager.endTask(taskID);
|
238
|
+
|
239
|
+
return buffer;
|
113
240
|
}
|
114
241
|
|
115
242
|
/**
|
116
|
-
*
|
243
|
+
* Returns text.
|
117
244
|
*
|
118
|
-
* @returns
|
245
|
+
* @returns Text.
|
119
246
|
*/
|
120
|
-
|
247
|
+
public async text(): Promise<string> {
|
248
|
+
if (this.bodyUsed) {
|
249
|
+
throw new DOMException(
|
250
|
+
`Body has already been used for "${this.url}".`,
|
251
|
+
DOMExceptionNameEnum.invalidStateError
|
252
|
+
);
|
253
|
+
}
|
254
|
+
|
255
|
+
(<boolean>this.bodyUsed) = true;
|
256
|
+
|
121
257
|
const taskManager = this._ownerDocument.defaultView.happyDOM.asyncTaskManager;
|
122
|
-
|
258
|
+
const taskID = taskManager.startTask(() => this.signal._abort());
|
259
|
+
let buffer: Buffer;
|
260
|
+
|
261
|
+
try {
|
262
|
+
buffer = await FetchBodyUtility.consumeBodyStream(this.body);
|
263
|
+
} catch (error) {
|
264
|
+
taskManager.endTask(taskID);
|
265
|
+
throw error;
|
266
|
+
}
|
267
|
+
|
268
|
+
taskManager.endTask(taskID);
|
269
|
+
|
270
|
+
return new TextDecoder().decode(buffer);
|
123
271
|
}
|
124
272
|
|
125
273
|
/**
|
126
|
-
*
|
274
|
+
* Returns json.
|
127
275
|
*
|
128
|
-
* @
|
129
|
-
* @param reject Reject.
|
130
|
-
* @param taskID Task ID.
|
131
|
-
* @param response Response.
|
276
|
+
* @returns JSON.
|
132
277
|
*/
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
taskID: number,
|
137
|
-
response: unknown
|
138
|
-
): void {
|
139
|
-
const taskManager = this._ownerDocument.defaultView.happyDOM.asyncTaskManager;
|
140
|
-
if (taskManager.getTaskCount() === 0) {
|
141
|
-
reject(new Error('Failed to complete fetch request. Task was canceled.'));
|
142
|
-
} else {
|
143
|
-
resolve(response);
|
144
|
-
taskManager.endTask(taskID);
|
145
|
-
}
|
278
|
+
public async json(): Promise<string> {
|
279
|
+
const text = await this.text();
|
280
|
+
return JSON.parse(text);
|
146
281
|
}
|
147
282
|
|
148
283
|
/**
|
149
|
-
*
|
284
|
+
* Clones request.
|
150
285
|
*
|
151
|
-
* @
|
152
|
-
* @param reject
|
286
|
+
* @returns Clone.
|
153
287
|
*/
|
154
|
-
|
155
|
-
|
156
|
-
reject(error);
|
157
|
-
taskManager.cancelAll(error);
|
288
|
+
public clone(): IRequest {
|
289
|
+
return <IRequest>new Request(this);
|
158
290
|
}
|
159
291
|
}
|
@@ -1,11 +1,11 @@
|
|
1
|
-
import RelativeURL from '../location/RelativeURL';
|
2
1
|
import DOMException from '../exception/DOMException';
|
3
2
|
import IDocument from '../nodes/document/IDocument';
|
3
|
+
import { URL } from 'url';
|
4
4
|
|
5
5
|
/**
|
6
6
|
* Helper class for performing fetch of resources.
|
7
7
|
*/
|
8
|
-
export default class
|
8
|
+
export default class ResourceFetch {
|
9
9
|
/**
|
10
10
|
* Returns resource data asynchronously.
|
11
11
|
*
|
@@ -32,7 +32,7 @@ export default class ResourceFetchHandler {
|
|
32
32
|
*/
|
33
33
|
public static fetchSync(document: IDocument, url: string): string {
|
34
34
|
// We want to only load SyncRequest when it is needed to improve performance and not have direct dependencies to server side packages.
|
35
|
-
const absoluteURL =
|
35
|
+
const absoluteURL = new URL(url, document.defaultView.location).href;
|
36
36
|
|
37
37
|
const xhr = new document.defaultView.XMLHttpRequest();
|
38
38
|
xhr.open('GET', absoluteURL, false);
|