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.
- 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 +84 -3
- package/lib/nodes/html-button-element/HTMLButtonElement.js +183 -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 +213 -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
@@ -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.
|
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.
|
77
|
+
this.removeAttribute('tabindex');
|
78
78
|
} else {
|
79
|
-
this.
|
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.
|
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.
|
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.
|
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.
|
321
|
+
this.removeAttribute('hidden');
|
322
322
|
} else {
|
323
|
-
this.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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():
|
168
|
-
return this.
|
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:
|
177
|
-
|
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
|
-
*
|
198
|
+
* Submits form. No submit event is raised. In particular, the form's "submit" event handler is not run.
|
182
199
|
*
|
183
|
-
*
|
200
|
+
* In Happy DOM this means that nothing happens.
|
184
201
|
*/
|
185
|
-
public
|
186
|
-
return this.querySelectorAll('input,textarea');
|
187
|
-
}
|
202
|
+
public submit(): void {}
|
188
203
|
|
189
204
|
/**
|
190
|
-
*
|
205
|
+
* Submits form, reports validity and raises submit event.
|
191
206
|
*
|
192
|
-
* @
|
207
|
+
* @param [submitter] Submitter.
|
193
208
|
*/
|
194
|
-
public
|
195
|
-
|
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
|
-
|
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
|
-
|
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
|
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:
|
21
|
-
elements:
|
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():
|
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
|
+
}
|