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
@@ -1,16 +1,73 @@
|
|
1
1
|
import IHTMLCollection from './IHTMLCollection';
|
2
|
-
import INode from '../node/INode';
|
3
2
|
|
4
3
|
/**
|
5
4
|
* Class list.
|
6
5
|
*/
|
7
|
-
export default class HTMLCollection
|
6
|
+
export default class HTMLCollection<T, NamedItem>
|
7
|
+
extends Array
|
8
|
+
implements IHTMLCollection<T, NamedItem>
|
9
|
+
{
|
10
|
+
protected _namedItems: { [k: string]: T[] } = {};
|
11
|
+
|
8
12
|
/**
|
9
13
|
* Returns item by index.
|
10
14
|
*
|
11
15
|
* @param index Index.
|
12
16
|
*/
|
13
|
-
public item(index: number):
|
17
|
+
public item(index: number): T | null {
|
14
18
|
return index >= 0 && this[index] ? this[index] : null;
|
15
19
|
}
|
20
|
+
|
21
|
+
/**
|
22
|
+
* Returns named item.
|
23
|
+
*
|
24
|
+
* @param name Name.
|
25
|
+
* @returns Node.
|
26
|
+
*/
|
27
|
+
public namedItem(name: string): NamedItem | null {
|
28
|
+
return this[name] || null;
|
29
|
+
}
|
30
|
+
|
31
|
+
/**
|
32
|
+
* Appends named item.
|
33
|
+
*
|
34
|
+
* @param node Node.
|
35
|
+
* @param name Name.
|
36
|
+
*/
|
37
|
+
public _appendNamedItem(node: T, name: string): void {
|
38
|
+
if (name) {
|
39
|
+
this._namedItems[name] = this._namedItems[name] || [];
|
40
|
+
|
41
|
+
if (!this._namedItems[name].includes(node)) {
|
42
|
+
this._namedItems[name].push(node);
|
43
|
+
}
|
44
|
+
|
45
|
+
if (!this[name]) {
|
46
|
+
this[name] = this._namedItems[name][0];
|
47
|
+
}
|
48
|
+
}
|
49
|
+
}
|
50
|
+
|
51
|
+
/**
|
52
|
+
* Appends named item.
|
53
|
+
*
|
54
|
+
* @param node Node.
|
55
|
+
* @param name Name.
|
56
|
+
*/
|
57
|
+
public _removeNamedItem(node: T, name: string): void {
|
58
|
+
if (name && this._namedItems[name]) {
|
59
|
+
const index = this._namedItems[name].indexOf(node);
|
60
|
+
|
61
|
+
if (index > -1) {
|
62
|
+
this._namedItems[name].splice(index, 1);
|
63
|
+
|
64
|
+
if (this._namedItems[name].length === 0) {
|
65
|
+
delete this._namedItems[name];
|
66
|
+
delete this[name];
|
67
|
+
} else {
|
68
|
+
this[name] = this._namedItems[name][0];
|
69
|
+
}
|
70
|
+
}
|
71
|
+
}
|
72
|
+
}
|
16
73
|
}
|
@@ -1,11 +1,19 @@
|
|
1
1
|
/**
|
2
2
|
* HTMLCollection.
|
3
3
|
*/
|
4
|
-
export default interface IHTMLCollection<T> extends Array<T> {
|
4
|
+
export default interface IHTMLCollection<T, NamedItem> extends Array<T> {
|
5
5
|
/**
|
6
6
|
* Returns item by index.
|
7
7
|
*
|
8
8
|
* @param index Index.
|
9
9
|
*/
|
10
|
-
item(index: number): T;
|
10
|
+
item(index: number): T | null;
|
11
|
+
|
12
|
+
/**
|
13
|
+
* Returns named item.
|
14
|
+
*
|
15
|
+
* @param name Name.
|
16
|
+
* @returns Node.
|
17
|
+
*/
|
18
|
+
namedItem(name: string): NamedItem | null;
|
11
19
|
}
|
@@ -31,7 +31,7 @@ export default class HTMLAnchorElement extends HTMLElement implements IHTMLAncho
|
|
31
31
|
* @param download Download.
|
32
32
|
*/
|
33
33
|
public set download(download: string) {
|
34
|
-
this.
|
34
|
+
this.setAttribute('download', download);
|
35
35
|
}
|
36
36
|
|
37
37
|
/**
|
@@ -51,7 +51,7 @@ export default class HTMLAnchorElement extends HTMLElement implements IHTMLAncho
|
|
51
51
|
public set hash(hash: string) {
|
52
52
|
if (this._url && !HTMLAnchorElementUtility.isBlobURL(this._url)) {
|
53
53
|
this._url.hash = hash;
|
54
|
-
this.
|
54
|
+
this.setAttribute('href', this._url.toString());
|
55
55
|
}
|
56
56
|
}
|
57
57
|
|
@@ -65,7 +65,7 @@ export default class HTMLAnchorElement extends HTMLElement implements IHTMLAncho
|
|
65
65
|
return this._url.toString();
|
66
66
|
}
|
67
67
|
|
68
|
-
return this.
|
68
|
+
return this.getAttribute('href') || '';
|
69
69
|
}
|
70
70
|
|
71
71
|
/**
|
@@ -74,7 +74,7 @@ export default class HTMLAnchorElement extends HTMLElement implements IHTMLAncho
|
|
74
74
|
* @param href Href.
|
75
75
|
*/
|
76
76
|
public set href(href: string) {
|
77
|
-
this.
|
77
|
+
this.setAttribute('href', href);
|
78
78
|
}
|
79
79
|
|
80
80
|
/**
|
@@ -83,7 +83,7 @@ export default class HTMLAnchorElement extends HTMLElement implements IHTMLAncho
|
|
83
83
|
* @returns Hreflang.
|
84
84
|
*/
|
85
85
|
public get hreflang(): string {
|
86
|
-
return this.
|
86
|
+
return this.getAttribute('hreflang') || '';
|
87
87
|
}
|
88
88
|
|
89
89
|
/**
|
@@ -92,7 +92,7 @@ export default class HTMLAnchorElement extends HTMLElement implements IHTMLAncho
|
|
92
92
|
* @param hreflang Hreflang.
|
93
93
|
*/
|
94
94
|
public set hreflang(hreflang: string) {
|
95
|
-
this.
|
95
|
+
this.setAttribute('hreflang', hreflang);
|
96
96
|
}
|
97
97
|
|
98
98
|
/**
|
@@ -110,7 +110,7 @@ export default class HTMLAnchorElement extends HTMLElement implements IHTMLAncho
|
|
110
110
|
* @returns Ping.
|
111
111
|
*/
|
112
112
|
public get ping(): string {
|
113
|
-
return this.
|
113
|
+
return this.getAttribute('ping') || '';
|
114
114
|
}
|
115
115
|
|
116
116
|
/**
|
@@ -119,7 +119,7 @@ export default class HTMLAnchorElement extends HTMLElement implements IHTMLAncho
|
|
119
119
|
* @param ping Ping.
|
120
120
|
*/
|
121
121
|
public set ping(ping: string) {
|
122
|
-
this.
|
122
|
+
this.setAttribute('ping', ping);
|
123
123
|
}
|
124
124
|
|
125
125
|
/**
|
@@ -139,7 +139,7 @@ export default class HTMLAnchorElement extends HTMLElement implements IHTMLAncho
|
|
139
139
|
public set protocol(protocol: string) {
|
140
140
|
if (this._url && !HTMLAnchorElementUtility.isBlobURL(this._url)) {
|
141
141
|
this._url.protocol = protocol;
|
142
|
-
this.
|
142
|
+
this.setAttribute('href', this._url.toString());
|
143
143
|
}
|
144
144
|
}
|
145
145
|
|
@@ -165,7 +165,7 @@ export default class HTMLAnchorElement extends HTMLElement implements IHTMLAncho
|
|
165
165
|
this._url.protocol != 'file'
|
166
166
|
) {
|
167
167
|
this._url.username = username;
|
168
|
-
this.
|
168
|
+
this.setAttribute('href', this._url.toString());
|
169
169
|
}
|
170
170
|
}
|
171
171
|
|
@@ -191,7 +191,7 @@ export default class HTMLAnchorElement extends HTMLElement implements IHTMLAncho
|
|
191
191
|
this._url.protocol != 'file'
|
192
192
|
) {
|
193
193
|
this._url.password = password;
|
194
|
-
this.
|
194
|
+
this.setAttribute('href', this._url.toString());
|
195
195
|
}
|
196
196
|
}
|
197
197
|
|
@@ -212,7 +212,7 @@ export default class HTMLAnchorElement extends HTMLElement implements IHTMLAncho
|
|
212
212
|
public set pathname(pathname: string) {
|
213
213
|
if (this._url && !HTMLAnchorElementUtility.isBlobURL(this._url)) {
|
214
214
|
this._url.pathname = pathname;
|
215
|
-
this.
|
215
|
+
this.setAttribute('href', this._url.toString());
|
216
216
|
}
|
217
217
|
}
|
218
218
|
|
@@ -238,7 +238,7 @@ export default class HTMLAnchorElement extends HTMLElement implements IHTMLAncho
|
|
238
238
|
this._url.protocol != 'file'
|
239
239
|
) {
|
240
240
|
this._url.port = port;
|
241
|
-
this.
|
241
|
+
this.setAttribute('href', this._url.toString());
|
242
242
|
}
|
243
243
|
}
|
244
244
|
|
@@ -259,7 +259,7 @@ export default class HTMLAnchorElement extends HTMLElement implements IHTMLAncho
|
|
259
259
|
public set host(host: string) {
|
260
260
|
if (this._url && !HTMLAnchorElementUtility.isBlobURL(this._url)) {
|
261
261
|
this._url.host = host;
|
262
|
-
this.
|
262
|
+
this.setAttribute('href', this._url.toString());
|
263
263
|
}
|
264
264
|
}
|
265
265
|
|
@@ -280,7 +280,7 @@ export default class HTMLAnchorElement extends HTMLElement implements IHTMLAncho
|
|
280
280
|
public set hostname(hostname: string) {
|
281
281
|
if (this._url && !HTMLAnchorElementUtility.isBlobURL(this._url)) {
|
282
282
|
this._url.hostname = hostname;
|
283
|
-
this.
|
283
|
+
this.setAttribute('href', this._url.toString());
|
284
284
|
}
|
285
285
|
}
|
286
286
|
|
@@ -290,7 +290,7 @@ export default class HTMLAnchorElement extends HTMLElement implements IHTMLAncho
|
|
290
290
|
* @returns Referrer Policy.
|
291
291
|
*/
|
292
292
|
public get referrerPolicy(): string {
|
293
|
-
return this.
|
293
|
+
return this.getAttribute('referrerPolicy') || '';
|
294
294
|
}
|
295
295
|
|
296
296
|
/**
|
@@ -299,7 +299,7 @@ export default class HTMLAnchorElement extends HTMLElement implements IHTMLAncho
|
|
299
299
|
* @param referrerPolicy Referrer Policy.
|
300
300
|
*/
|
301
301
|
public set referrerPolicy(referrerPolicy: string) {
|
302
|
-
this.
|
302
|
+
this.setAttribute('referrerPolicy', referrerPolicy);
|
303
303
|
}
|
304
304
|
|
305
305
|
/**
|
@@ -308,7 +308,7 @@ export default class HTMLAnchorElement extends HTMLElement implements IHTMLAncho
|
|
308
308
|
* @returns Rel.
|
309
309
|
*/
|
310
310
|
public get rel(): string {
|
311
|
-
return this.
|
311
|
+
return this.getAttribute('rel') || '';
|
312
312
|
}
|
313
313
|
|
314
314
|
/**
|
@@ -317,7 +317,7 @@ export default class HTMLAnchorElement extends HTMLElement implements IHTMLAncho
|
|
317
317
|
* @param rel Rel.
|
318
318
|
*/
|
319
319
|
public set rel(rel: string) {
|
320
|
-
this.
|
320
|
+
this.setAttribute('rel', rel);
|
321
321
|
}
|
322
322
|
|
323
323
|
/**
|
@@ -349,7 +349,7 @@ export default class HTMLAnchorElement extends HTMLElement implements IHTMLAncho
|
|
349
349
|
public set search(search: string) {
|
350
350
|
if (this._url && !HTMLAnchorElementUtility.isBlobURL(this._url)) {
|
351
351
|
this._url.search = search;
|
352
|
-
this.
|
352
|
+
this.setAttribute('href', this._url.toString());
|
353
353
|
}
|
354
354
|
}
|
355
355
|
|
@@ -359,7 +359,7 @@ export default class HTMLAnchorElement extends HTMLElement implements IHTMLAncho
|
|
359
359
|
* @returns target.
|
360
360
|
*/
|
361
361
|
public get target(): string {
|
362
|
-
return this.
|
362
|
+
return this.getAttribute('target') || '';
|
363
363
|
}
|
364
364
|
|
365
365
|
/**
|
@@ -368,7 +368,7 @@ export default class HTMLAnchorElement extends HTMLElement implements IHTMLAncho
|
|
368
368
|
* @param target Target.
|
369
369
|
*/
|
370
370
|
public set target(target: string) {
|
371
|
-
this.
|
371
|
+
this.setAttribute('target', target);
|
372
372
|
}
|
373
373
|
|
374
374
|
/**
|
@@ -395,7 +395,7 @@ export default class HTMLAnchorElement extends HTMLElement implements IHTMLAncho
|
|
395
395
|
* @returns Type.
|
396
396
|
*/
|
397
397
|
public get type(): string {
|
398
|
-
return this.
|
398
|
+
return this.getAttribute('type') || '';
|
399
399
|
}
|
400
400
|
|
401
401
|
/**
|
@@ -404,7 +404,7 @@ export default class HTMLAnchorElement extends HTMLElement implements IHTMLAncho
|
|
404
404
|
* @param type Type.
|
405
405
|
*/
|
406
406
|
public set type(type: string) {
|
407
|
-
this.
|
407
|
+
this.setAttribute('type', type);
|
408
408
|
}
|
409
409
|
|
410
410
|
/**
|
@@ -14,7 +14,7 @@ export default class HTMLBaseElement extends HTMLElement implements IHTMLBaseEle
|
|
14
14
|
* @returns Href.
|
15
15
|
*/
|
16
16
|
public get href(): string {
|
17
|
-
const href = this.
|
17
|
+
const href = this.getAttribute('href');
|
18
18
|
if (href !== null) {
|
19
19
|
return href;
|
20
20
|
}
|
@@ -27,7 +27,7 @@ export default class HTMLBaseElement extends HTMLElement implements IHTMLBaseEle
|
|
27
27
|
* @param href Href.
|
28
28
|
*/
|
29
29
|
public set href(href: string) {
|
30
|
-
this.
|
30
|
+
this.setAttribute('href', href);
|
31
31
|
}
|
32
32
|
|
33
33
|
/**
|
@@ -36,7 +36,7 @@ export default class HTMLBaseElement extends HTMLElement implements IHTMLBaseEle
|
|
36
36
|
* @returns Target.
|
37
37
|
*/
|
38
38
|
public get target(): string {
|
39
|
-
return this.
|
39
|
+
return this.getAttribute('target') || '';
|
40
40
|
}
|
41
41
|
|
42
42
|
/**
|
@@ -45,7 +45,7 @@ export default class HTMLBaseElement extends HTMLElement implements IHTMLBaseEle
|
|
45
45
|
* @param target Target.
|
46
46
|
*/
|
47
47
|
public set target(target: string) {
|
48
|
-
this.
|
48
|
+
this.setAttribute('target', target);
|
49
49
|
}
|
50
50
|
|
51
51
|
/**
|
@@ -1,24 +1,54 @@
|
|
1
|
+
import Event from '../../event/Event';
|
2
|
+
import ValidityState from '../../validity-state/ValidityState';
|
3
|
+
import IAttr from '../attr/IAttr';
|
4
|
+
import IDocument from '../document/IDocument';
|
1
5
|
import HTMLElement from '../html-element/HTMLElement';
|
6
|
+
import HTMLFormElement from '../html-form-element/HTMLFormElement';
|
7
|
+
import IHTMLFormElement from '../html-form-element/IHTMLFormElement';
|
8
|
+
import IHTMLLabelElement from '../html-label-element/IHTMLLabelElement';
|
9
|
+
import INode from '../node/INode';
|
10
|
+
import INodeList from '../node/INodeList';
|
11
|
+
import NodeList from '../node/NodeList';
|
12
|
+
import IShadowRoot from '../shadow-root/IShadowRoot';
|
2
13
|
import IHTMLButtonElement from './IHTMLButtonElement';
|
3
14
|
|
4
15
|
const BUTTON_TYPES = ['submit', 'reset', 'button', 'menu'];
|
5
16
|
|
6
17
|
/**
|
7
|
-
|
8
|
-
We can improve performance a bit if we make the types as a constant.
|
9
18
|
* HTML Button Element.
|
10
19
|
*
|
11
20
|
* Reference:
|
12
21
|
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLButtonElement.
|
13
22
|
*/
|
14
23
|
export default class HTMLButtonElement extends HTMLElement implements IHTMLButtonElement {
|
24
|
+
public readonly validationMessage = '';
|
25
|
+
public readonly validity = new ValidityState(this);
|
26
|
+
|
27
|
+
/**
|
28
|
+
* Returns name.
|
29
|
+
*
|
30
|
+
* @returns Name.
|
31
|
+
*/
|
32
|
+
public get name(): string {
|
33
|
+
return this.getAttribute('name') || '';
|
34
|
+
}
|
35
|
+
|
36
|
+
/**
|
37
|
+
* Sets name.
|
38
|
+
*
|
39
|
+
* @param name Name.
|
40
|
+
*/
|
41
|
+
public set name(name: string) {
|
42
|
+
this.setAttribute('name', name);
|
43
|
+
}
|
44
|
+
|
15
45
|
/**
|
16
46
|
* Returns value.
|
17
47
|
*
|
18
48
|
* @returns Value.
|
19
49
|
*/
|
20
50
|
public get value(): string {
|
21
|
-
return this.
|
51
|
+
return this.getAttribute('value');
|
22
52
|
}
|
23
53
|
|
24
54
|
/**
|
@@ -27,7 +57,7 @@ export default class HTMLButtonElement extends HTMLElement implements IHTMLButto
|
|
27
57
|
* @param value Value.
|
28
58
|
*/
|
29
59
|
public set value(value: string) {
|
30
|
-
this.
|
60
|
+
this.setAttribute('value', value);
|
31
61
|
}
|
32
62
|
|
33
63
|
/**
|
@@ -36,7 +66,7 @@ export default class HTMLButtonElement extends HTMLElement implements IHTMLButto
|
|
36
66
|
* @returns Disabled.
|
37
67
|
*/
|
38
68
|
public get disabled(): boolean {
|
39
|
-
return this.
|
69
|
+
return this.getAttribute('disabled') !== null;
|
40
70
|
}
|
41
71
|
|
42
72
|
/**
|
@@ -46,9 +76,9 @@ export default class HTMLButtonElement extends HTMLElement implements IHTMLButto
|
|
46
76
|
*/
|
47
77
|
public set disabled(disabled: boolean) {
|
48
78
|
if (!disabled) {
|
49
|
-
this.
|
79
|
+
this.removeAttribute('disabled');
|
50
80
|
} else {
|
51
|
-
this.
|
81
|
+
this.setAttribute('disabled', '');
|
52
82
|
}
|
53
83
|
}
|
54
84
|
|
@@ -58,7 +88,7 @@ export default class HTMLButtonElement extends HTMLElement implements IHTMLButto
|
|
58
88
|
* @returns Type
|
59
89
|
*/
|
60
90
|
public get type(): string {
|
61
|
-
return this._sanitizeType(this.
|
91
|
+
return this._sanitizeType(this.getAttribute('type'));
|
62
92
|
}
|
63
93
|
|
64
94
|
/**
|
@@ -67,12 +97,104 @@ export default class HTMLButtonElement extends HTMLElement implements IHTMLButto
|
|
67
97
|
* @param v Type
|
68
98
|
*/
|
69
99
|
public set type(v: string) {
|
70
|
-
this.
|
100
|
+
this.setAttribute('type', this._sanitizeType(v));
|
101
|
+
}
|
102
|
+
|
103
|
+
/**
|
104
|
+
* Returns no validate.
|
105
|
+
*
|
106
|
+
* @returns No validate.
|
107
|
+
*/
|
108
|
+
public get formNoValidate(): boolean {
|
109
|
+
return this.getAttribute('formnovalidate') !== null;
|
110
|
+
}
|
111
|
+
|
112
|
+
/**
|
113
|
+
* Sets no validate.
|
114
|
+
*
|
115
|
+
* @param formNoValidate No validate.
|
116
|
+
*/
|
117
|
+
public set formNoValidate(formNoValidate: boolean) {
|
118
|
+
if (!formNoValidate) {
|
119
|
+
this.removeAttribute('formnovalidate');
|
120
|
+
} else {
|
121
|
+
this.setAttribute('formnovalidate', '');
|
122
|
+
}
|
123
|
+
}
|
124
|
+
|
125
|
+
/**
|
126
|
+
* Returns the parent form element.
|
127
|
+
*
|
128
|
+
* @returns Form.
|
129
|
+
*/
|
130
|
+
public get form(): IHTMLFormElement {
|
131
|
+
return <IHTMLFormElement>this._formNode;
|
132
|
+
}
|
133
|
+
|
134
|
+
/**
|
135
|
+
* Returns the associated label elements.
|
136
|
+
*
|
137
|
+
* @returns Label elements.
|
138
|
+
*/
|
139
|
+
public get labels(): INodeList<IHTMLLabelElement> {
|
140
|
+
const id = this.id;
|
141
|
+
if (id) {
|
142
|
+
const rootNode = <IDocument | IShadowRoot>this.getRootNode();
|
143
|
+
const labels = rootNode.querySelectorAll(`label[for="${id}"]`);
|
144
|
+
|
145
|
+
let parent = this.parentNode;
|
146
|
+
while (parent) {
|
147
|
+
if (parent['tagName'] === 'LABEL') {
|
148
|
+
labels.push(<IHTMLLabelElement>parent);
|
149
|
+
break;
|
150
|
+
}
|
151
|
+
parent = parent.parentNode;
|
152
|
+
}
|
153
|
+
|
154
|
+
return <INodeList<IHTMLLabelElement>>labels;
|
155
|
+
}
|
156
|
+
return new NodeList<IHTMLLabelElement>();
|
157
|
+
}
|
158
|
+
|
159
|
+
/**
|
160
|
+
* Checks validity.
|
161
|
+
*
|
162
|
+
* @returns "true" if the field is valid.
|
163
|
+
*/
|
164
|
+
public checkValidity(): boolean {
|
165
|
+
const valid =
|
166
|
+
this.disabled || this.type === 'reset' || this.type === 'button' || this.validity.valid;
|
167
|
+
if (!valid) {
|
168
|
+
this.dispatchEvent(new Event('invalid', { bubbles: true, cancelable: true }));
|
169
|
+
}
|
170
|
+
return valid;
|
171
|
+
}
|
172
|
+
|
173
|
+
/**
|
174
|
+
* Reports validity.
|
175
|
+
*
|
176
|
+
* @returns Validity.
|
177
|
+
*/
|
178
|
+
public reportValidity(): boolean {
|
179
|
+
return this.checkValidity();
|
71
180
|
}
|
72
181
|
|
73
182
|
/**
|
183
|
+
* Sets validation message.
|
74
184
|
*
|
75
|
-
* @param
|
185
|
+
* @param message Message.
|
186
|
+
*/
|
187
|
+
public setCustomValidity(message: string): void {
|
188
|
+
(<string>this.validationMessage) = String(message);
|
189
|
+
}
|
190
|
+
|
191
|
+
/**
|
192
|
+
* Sanitizes type.
|
193
|
+
*
|
194
|
+
* TODO: We can improve performance a bit if we make the types as a constant.
|
195
|
+
*
|
196
|
+
* @param type Type.
|
197
|
+
* @returns Type sanitized.
|
76
198
|
*/
|
77
199
|
protected _sanitizeType(type: string): string {
|
78
200
|
type = (type && type.toLowerCase()) || 'submit';
|
@@ -83,4 +205,56 @@ export default class HTMLButtonElement extends HTMLElement implements IHTMLButto
|
|
83
205
|
|
84
206
|
return type;
|
85
207
|
}
|
208
|
+
|
209
|
+
/**
|
210
|
+
* @override
|
211
|
+
*/
|
212
|
+
public override setAttributeNode(attribute: IAttr): IAttr {
|
213
|
+
const replacedAttribute = super.setAttributeNode(attribute);
|
214
|
+
const oldValue = replacedAttribute ? replacedAttribute.value : null;
|
215
|
+
|
216
|
+
if ((attribute.name === 'id' || attribute.name === 'name') && this._formNode) {
|
217
|
+
if (oldValue) {
|
218
|
+
(<HTMLFormElement>this._formNode)._removeFormControlItem(this, oldValue);
|
219
|
+
}
|
220
|
+
if (attribute.value) {
|
221
|
+
(<HTMLFormElement>this._formNode)._appendFormControlItem(this, attribute.value);
|
222
|
+
}
|
223
|
+
}
|
224
|
+
|
225
|
+
return replacedAttribute;
|
226
|
+
}
|
227
|
+
|
228
|
+
/**
|
229
|
+
* @override
|
230
|
+
*/
|
231
|
+
public override removeAttributeNode(attribute: IAttr): IAttr {
|
232
|
+
super.removeAttributeNode(attribute);
|
233
|
+
|
234
|
+
if ((attribute.name === 'id' || attribute.name === 'name') && this._formNode) {
|
235
|
+
(<HTMLFormElement>this._formNode)._removeFormControlItem(this, attribute.value);
|
236
|
+
}
|
237
|
+
|
238
|
+
return attribute;
|
239
|
+
}
|
240
|
+
|
241
|
+
/**
|
242
|
+
* @override
|
243
|
+
*/
|
244
|
+
public override _connectToNode(parentNode: INode = null): void {
|
245
|
+
const oldFormNode = <HTMLFormElement>this._formNode;
|
246
|
+
|
247
|
+
super._connectToNode(parentNode);
|
248
|
+
|
249
|
+
if (oldFormNode !== this._formNode) {
|
250
|
+
if (oldFormNode) {
|
251
|
+
oldFormNode._removeFormControlItem(this, this.name);
|
252
|
+
oldFormNode._removeFormControlItem(this, this.id);
|
253
|
+
}
|
254
|
+
if (this._formNode) {
|
255
|
+
(<HTMLFormElement>this._formNode)._appendFormControlItem(this, this.name);
|
256
|
+
(<HTMLFormElement>this._formNode)._appendFormControlItem(this, this.id);
|
257
|
+
}
|
258
|
+
}
|
259
|
+
}
|
86
260
|
}
|
@@ -1,4 +1,7 @@
|
|
1
1
|
import IHTMLElement from '../html-element/IHTMLElement';
|
2
|
+
import IHTMLFormElement from '../html-form-element/IHTMLFormElement';
|
3
|
+
import IHTMLLabelElement from '../html-label-element/IHTMLLabelElement';
|
4
|
+
import INodeList from '../node/INodeList';
|
2
5
|
|
3
6
|
/**
|
4
7
|
* HTML Button Element.
|
@@ -7,7 +10,33 @@ import IHTMLElement from '../html-element/IHTMLElement';
|
|
7
10
|
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLButtonElement.
|
8
11
|
*/
|
9
12
|
export default interface IHTMLButtonElement extends IHTMLElement {
|
10
|
-
|
11
|
-
disabled: boolean;
|
13
|
+
name: string;
|
12
14
|
value: string;
|
15
|
+
disabled: boolean;
|
16
|
+
type: string;
|
17
|
+
formNoValidate: boolean;
|
18
|
+
readonly form: IHTMLFormElement;
|
19
|
+
readonly validationMessage: string;
|
20
|
+
readonly labels: INodeList<IHTMLLabelElement>;
|
21
|
+
|
22
|
+
/**
|
23
|
+
* Checks validity.
|
24
|
+
*
|
25
|
+
* @returns Validity.
|
26
|
+
*/
|
27
|
+
checkValidity(): boolean;
|
28
|
+
|
29
|
+
/**
|
30
|
+
* Reports validity.
|
31
|
+
*
|
32
|
+
* @returns Validity.
|
33
|
+
*/
|
34
|
+
reportValidity(): boolean;
|
35
|
+
|
36
|
+
/**
|
37
|
+
* Sets validation message.
|
38
|
+
*
|
39
|
+
* @param message Message.
|
40
|
+
*/
|
41
|
+
setCustomValidity(message: string): void;
|
13
42
|
}
|
@@ -30,7 +30,7 @@ export default class HTMLDialogElement extends HTMLElement implements IHTMLDialo
|
|
30
30
|
* @param [returnValue] ReturnValue.
|
31
31
|
*/
|
32
32
|
public close(returnValue = ''): void {
|
33
|
-
this.
|
33
|
+
this.removeAttribute('open');
|
34
34
|
this.returnValue = returnValue;
|
35
35
|
this.dispatchEvent(new Event('close'));
|
36
36
|
}
|
@@ -39,13 +39,13 @@ export default class HTMLDialogElement extends HTMLElement implements IHTMLDialo
|
|
39
39
|
* Shows the modal.
|
40
40
|
*/
|
41
41
|
public showModal(): void {
|
42
|
-
this.
|
42
|
+
this.setAttribute('open', '');
|
43
43
|
}
|
44
44
|
|
45
45
|
/**
|
46
46
|
* Shows the dialog.
|
47
47
|
*/
|
48
48
|
public show(): void {
|
49
|
-
this.
|
49
|
+
this.setAttribute('open', '');
|
50
50
|
}
|
51
51
|
}
|