@depup/jsdom 28.1.0-depup.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.
- package/LICENSE.txt +22 -0
- package/README.md +38 -0
- package/changes.json +38 -0
- package/lib/api.js +373 -0
- package/lib/generated/event-sets.js +115 -0
- package/lib/generated/idl/AbortController.js +143 -0
- package/lib/generated/idl/AbortSignal.js +249 -0
- package/lib/generated/idl/AbstractRange.js +171 -0
- package/lib/generated/idl/AddEventListenerOptions.js +53 -0
- package/lib/generated/idl/AssignedNodesOptions.js +28 -0
- package/lib/generated/idl/Attr.js +219 -0
- package/lib/generated/idl/BarProp.js +117 -0
- package/lib/generated/idl/BeforeUnloadEvent.js +139 -0
- package/lib/generated/idl/BinaryType.js +12 -0
- package/lib/generated/idl/Blob.js +253 -0
- package/lib/generated/idl/BlobCallback.js +30 -0
- package/lib/generated/idl/BlobEvent.js +157 -0
- package/lib/generated/idl/BlobEventInit.js +43 -0
- package/lib/generated/idl/BlobPropertyBag.js +42 -0
- package/lib/generated/idl/CDATASection.js +109 -0
- package/lib/generated/idl/CanPlayTypeResult.js +12 -0
- package/lib/generated/idl/CharacterData.js +455 -0
- package/lib/generated/idl/CloseEvent.js +168 -0
- package/lib/generated/idl/CloseEventInit.js +65 -0
- package/lib/generated/idl/Comment.js +120 -0
- package/lib/generated/idl/CompositionEvent.js +219 -0
- package/lib/generated/idl/CompositionEventInit.js +32 -0
- package/lib/generated/idl/Crypto.js +148 -0
- package/lib/generated/idl/CustomElementConstructor.js +34 -0
- package/lib/generated/idl/CustomElementRegistry.js +269 -0
- package/lib/generated/idl/CustomEvent.js +206 -0
- package/lib/generated/idl/CustomEventInit.js +32 -0
- package/lib/generated/idl/DOMException.js +222 -0
- package/lib/generated/idl/DOMImplementation.js +237 -0
- package/lib/generated/idl/DOMParser.js +140 -0
- package/lib/generated/idl/DOMRect.js +276 -0
- package/lib/generated/idl/DOMRectInit.js +76 -0
- package/lib/generated/idl/DOMRectReadOnly.js +285 -0
- package/lib/generated/idl/DOMStringMap.js +299 -0
- package/lib/generated/idl/DOMTokenList.js +539 -0
- package/lib/generated/idl/DeviceMotionEvent.js +183 -0
- package/lib/generated/idl/DeviceMotionEventAcceleration.js +145 -0
- package/lib/generated/idl/DeviceMotionEventAccelerationInit.js +61 -0
- package/lib/generated/idl/DeviceMotionEventInit.js +70 -0
- package/lib/generated/idl/DeviceMotionEventRotationRate.js +145 -0
- package/lib/generated/idl/DeviceMotionEventRotationRateInit.js +61 -0
- package/lib/generated/idl/DeviceOrientationEvent.js +183 -0
- package/lib/generated/idl/DeviceOrientationEventInit.js +80 -0
- package/lib/generated/idl/Document.js +4511 -0
- package/lib/generated/idl/DocumentFragment.js +336 -0
- package/lib/generated/idl/DocumentReadyState.js +12 -0
- package/lib/generated/idl/DocumentType.js +254 -0
- package/lib/generated/idl/Element.js +3720 -0
- package/lib/generated/idl/ElementCreationOptions.js +26 -0
- package/lib/generated/idl/ElementDefinitionOptions.js +29 -0
- package/lib/generated/idl/ElementInternals.js +2152 -0
- package/lib/generated/idl/EndingType.js +12 -0
- package/lib/generated/idl/ErrorEvent.js +192 -0
- package/lib/generated/idl/ErrorEventInit.js +92 -0
- package/lib/generated/idl/Event.js +430 -0
- package/lib/generated/idl/EventHandlerNonNull.js +36 -0
- package/lib/generated/idl/EventInit.js +58 -0
- package/lib/generated/idl/EventListener.js +35 -0
- package/lib/generated/idl/EventListenerOptions.js +28 -0
- package/lib/generated/idl/EventModifierInit.js +221 -0
- package/lib/generated/idl/EventTarget.js +259 -0
- package/lib/generated/idl/External.js +130 -0
- package/lib/generated/idl/File.js +185 -0
- package/lib/generated/idl/FileList.js +298 -0
- package/lib/generated/idl/FilePropertyBag.js +33 -0
- package/lib/generated/idl/FileReader.js +468 -0
- package/lib/generated/idl/FocusEvent.js +144 -0
- package/lib/generated/idl/FocusEventInit.js +36 -0
- package/lib/generated/idl/FormData.js +468 -0
- package/lib/generated/idl/Function.js +42 -0
- package/lib/generated/idl/GetRootNodeOptions.js +31 -0
- package/lib/generated/idl/HTMLAnchorElement.js +1026 -0
- package/lib/generated/idl/HTMLAreaElement.js +825 -0
- package/lib/generated/idl/HTMLAudioElement.js +111 -0
- package/lib/generated/idl/HTMLBRElement.js +156 -0
- package/lib/generated/idl/HTMLBaseElement.js +196 -0
- package/lib/generated/idl/HTMLBodyElement.js +880 -0
- package/lib/generated/idl/HTMLButtonElement.js +525 -0
- package/lib/generated/idl/HTMLCanvasElement.js +307 -0
- package/lib/generated/idl/HTMLCollection.js +352 -0
- package/lib/generated/idl/HTMLDListElement.js +159 -0
- package/lib/generated/idl/HTMLDataElement.js +156 -0
- package/lib/generated/idl/HTMLDataListElement.js +126 -0
- package/lib/generated/idl/HTMLDetailsElement.js +159 -0
- package/lib/generated/idl/HTMLDialogElement.js +159 -0
- package/lib/generated/idl/HTMLDirectoryElement.js +159 -0
- package/lib/generated/idl/HTMLDivElement.js +156 -0
- package/lib/generated/idl/HTMLElement.js +3492 -0
- package/lib/generated/idl/HTMLEmbedElement.js +381 -0
- package/lib/generated/idl/HTMLFieldSetElement.js +332 -0
- package/lib/generated/idl/HTMLFontElement.js +239 -0
- package/lib/generated/idl/HTMLFormControlsCollection.js +318 -0
- package/lib/generated/idl/HTMLFormElement.js +661 -0
- package/lib/generated/idl/HTMLFrameElement.js +513 -0
- package/lib/generated/idl/HTMLFrameSetElement.js +711 -0
- package/lib/generated/idl/HTMLHRElement.js +323 -0
- package/lib/generated/idl/HTMLHeadElement.js +111 -0
- package/lib/generated/idl/HTMLHeadingElement.js +156 -0
- package/lib/generated/idl/HTMLHtmlElement.js +156 -0
- package/lib/generated/idl/HTMLIFrameElement.js +689 -0
- package/lib/generated/idl/HTMLImageElement.js +906 -0
- package/lib/generated/idl/HTMLInputElement.js +1931 -0
- package/lib/generated/idl/HTMLLIElement.js +204 -0
- package/lib/generated/idl/HTMLLabelElement.js +182 -0
- package/lib/generated/idl/HTMLLegendElement.js +169 -0
- package/lib/generated/idl/HTMLLinkElement.js +555 -0
- package/lib/generated/idl/HTMLMapElement.js +171 -0
- package/lib/generated/idl/HTMLMarqueeElement.js +558 -0
- package/lib/generated/idl/HTMLMediaElement.js +900 -0
- package/lib/generated/idl/HTMLMenuElement.js +159 -0
- package/lib/generated/idl/HTMLMetaElement.js +279 -0
- package/lib/generated/idl/HTMLMeterElement.js +368 -0
- package/lib/generated/idl/HTMLModElement.js +217 -0
- package/lib/generated/idl/HTMLOListElement.js +284 -0
- package/lib/generated/idl/HTMLObjectElement.js +945 -0
- package/lib/generated/idl/HTMLOptGroupElement.js +200 -0
- package/lib/generated/idl/HTMLOptionElement.js +379 -0
- package/lib/generated/idl/HTMLOptionsCollection.js +513 -0
- package/lib/generated/idl/HTMLOutputElement.js +395 -0
- package/lib/generated/idl/HTMLParagraphElement.js +156 -0
- package/lib/generated/idl/HTMLParamElement.js +279 -0
- package/lib/generated/idl/HTMLPictureElement.js +111 -0
- package/lib/generated/idl/HTMLPreElement.js +163 -0
- package/lib/generated/idl/HTMLProgressElement.js +232 -0
- package/lib/generated/idl/HTMLQuoteElement.js +176 -0
- package/lib/generated/idl/HTMLScriptElement.js +472 -0
- package/lib/generated/idl/HTMLSelectElement.js +993 -0
- package/lib/generated/idl/HTMLSlotElement.js +195 -0
- package/lib/generated/idl/HTMLSourceElement.js +340 -0
- package/lib/generated/idl/HTMLSpanElement.js +111 -0
- package/lib/generated/idl/HTMLStyleElement.js +210 -0
- package/lib/generated/idl/HTMLTableCaptionElement.js +156 -0
- package/lib/generated/idl/HTMLTableCellElement.js +733 -0
- package/lib/generated/idl/HTMLTableColElement.js +376 -0
- package/lib/generated/idl/HTMLTableElement.js +802 -0
- package/lib/generated/idl/HTMLTableRowElement.js +417 -0
- package/lib/generated/idl/HTMLTableSectionElement.js +349 -0
- package/lib/generated/idl/HTMLTemplateElement.js +124 -0
- package/lib/generated/idl/HTMLTextAreaElement.js +1210 -0
- package/lib/generated/idl/HTMLTimeElement.js +156 -0
- package/lib/generated/idl/HTMLTitleElement.js +155 -0
- package/lib/generated/idl/HTMLTrackElement.js +366 -0
- package/lib/generated/idl/HTMLUListElement.js +200 -0
- package/lib/generated/idl/HTMLUnknownElement.js +109 -0
- package/lib/generated/idl/HTMLVideoElement.js +344 -0
- package/lib/generated/idl/HashChangeEvent.js +157 -0
- package/lib/generated/idl/HashChangeEventInit.js +50 -0
- package/lib/generated/idl/Headers.js +418 -0
- package/lib/generated/idl/History.js +266 -0
- package/lib/generated/idl/InputEvent.js +168 -0
- package/lib/generated/idl/InputEventInit.js +68 -0
- package/lib/generated/idl/KeyboardEvent.js +445 -0
- package/lib/generated/idl/KeyboardEventInit.js +116 -0
- package/lib/generated/idl/Location.js +404 -0
- package/lib/generated/idl/MessageEvent.js +317 -0
- package/lib/generated/idl/MessageEventInit.js +100 -0
- package/lib/generated/idl/MimeType.js +156 -0
- package/lib/generated/idl/MimeTypeArray.js +326 -0
- package/lib/generated/idl/MouseEvent.js +595 -0
- package/lib/generated/idl/MouseEventInit.js +189 -0
- package/lib/generated/idl/MutationCallback.js +34 -0
- package/lib/generated/idl/MutationObserver.js +178 -0
- package/lib/generated/idl/MutationObserverInit.js +121 -0
- package/lib/generated/idl/MutationRecord.js +229 -0
- package/lib/generated/idl/NamedNodeMap.js +529 -0
- package/lib/generated/idl/Navigator.js +326 -0
- package/lib/generated/idl/Node.js +765 -0
- package/lib/generated/idl/NodeFilter.js +75 -0
- package/lib/generated/idl/NodeIterator.js +207 -0
- package/lib/generated/idl/NodeList.js +302 -0
- package/lib/generated/idl/OnBeforeUnloadEventHandlerNonNull.js +42 -0
- package/lib/generated/idl/OnErrorEventHandlerNonNull.js +56 -0
- package/lib/generated/idl/PageTransitionEvent.js +144 -0
- package/lib/generated/idl/PageTransitionEventInit.js +35 -0
- package/lib/generated/idl/Performance.js +142 -0
- package/lib/generated/idl/Plugin.js +359 -0
- package/lib/generated/idl/PluginArray.js +336 -0
- package/lib/generated/idl/PointerEvent.js +324 -0
- package/lib/generated/idl/PointerEventInit.js +241 -0
- package/lib/generated/idl/PopStateEvent.js +144 -0
- package/lib/generated/idl/PopStateEventInit.js +32 -0
- package/lib/generated/idl/ProcessingInstruction.js +122 -0
- package/lib/generated/idl/ProgressEvent.js +170 -0
- package/lib/generated/idl/ProgressEventInit.js +65 -0
- package/lib/generated/idl/PromiseRejectionEvent.js +157 -0
- package/lib/generated/idl/PromiseRejectionEventInit.js +42 -0
- package/lib/generated/idl/RadioNodeList.js +296 -0
- package/lib/generated/idl/Range.js +643 -0
- package/lib/generated/idl/SVGAnimatedPreserveAspectRatio.js +136 -0
- package/lib/generated/idl/SVGAnimatedRect.js +136 -0
- package/lib/generated/idl/SVGAnimatedString.js +149 -0
- package/lib/generated/idl/SVGBoundingBoxOptions.js +64 -0
- package/lib/generated/idl/SVGDefsElement.js +109 -0
- package/lib/generated/idl/SVGDescElement.js +109 -0
- package/lib/generated/idl/SVGElement.js +3157 -0
- package/lib/generated/idl/SVGGElement.js +109 -0
- package/lib/generated/idl/SVGGraphicsElement.js +139 -0
- package/lib/generated/idl/SVGMetadataElement.js +109 -0
- package/lib/generated/idl/SVGNumber.js +132 -0
- package/lib/generated/idl/SVGPreserveAspectRatio.js +196 -0
- package/lib/generated/idl/SVGRect.js +210 -0
- package/lib/generated/idl/SVGSVGElement.js +786 -0
- package/lib/generated/idl/SVGStringList.js +511 -0
- package/lib/generated/idl/SVGSwitchElement.js +109 -0
- package/lib/generated/idl/SVGSymbolElement.js +146 -0
- package/lib/generated/idl/SVGTitleElement.js +109 -0
- package/lib/generated/idl/Screen.js +180 -0
- package/lib/generated/idl/ScrollBehavior.js +12 -0
- package/lib/generated/idl/ScrollIntoViewOptions.js +45 -0
- package/lib/generated/idl/ScrollLogicalPosition.js +14 -0
- package/lib/generated/idl/ScrollOptions.js +30 -0
- package/lib/generated/idl/ScrollRestoration.js +12 -0
- package/lib/generated/idl/Selection.js +571 -0
- package/lib/generated/idl/SelectionMode.js +12 -0
- package/lib/generated/idl/ShadowRoot.js +189 -0
- package/lib/generated/idl/ShadowRootInit.js +30 -0
- package/lib/generated/idl/ShadowRootMode.js +12 -0
- package/lib/generated/idl/StaticRange.js +123 -0
- package/lib/generated/idl/StaticRangeInit.js +72 -0
- package/lib/generated/idl/Storage.js +397 -0
- package/lib/generated/idl/StorageEvent.js +318 -0
- package/lib/generated/idl/StorageEventInit.js +99 -0
- package/lib/generated/idl/StyleSheetList.js +300 -0
- package/lib/generated/idl/SubmitEvent.js +144 -0
- package/lib/generated/idl/SubmitEventInit.js +36 -0
- package/lib/generated/idl/SupportedType.js +18 -0
- package/lib/generated/idl/Text.js +170 -0
- package/lib/generated/idl/TextDecodeOptions.js +28 -0
- package/lib/generated/idl/TextDecoder.js +211 -0
- package/lib/generated/idl/TextDecoderOptions.js +43 -0
- package/lib/generated/idl/TextEncoder.js +176 -0
- package/lib/generated/idl/TextEncoderEncodeIntoResult.js +42 -0
- package/lib/generated/idl/TextTrackKind.js +12 -0
- package/lib/generated/idl/TouchEvent.js +222 -0
- package/lib/generated/idl/TouchEventInit.js +89 -0
- package/lib/generated/idl/TransitionEvent.js +170 -0
- package/lib/generated/idl/TransitionEventInit.js +65 -0
- package/lib/generated/idl/TreeWalker.js +255 -0
- package/lib/generated/idl/UIEvent.js +235 -0
- package/lib/generated/idl/UIEventInit.js +62 -0
- package/lib/generated/idl/ValidityState.js +249 -0
- package/lib/generated/idl/VisibilityState.js +12 -0
- package/lib/generated/idl/VoidFunction.js +26 -0
- package/lib/generated/idl/WebSocket.js +480 -0
- package/lib/generated/idl/WheelEvent.js +191 -0
- package/lib/generated/idl/WheelEventInit.js +71 -0
- package/lib/generated/idl/XMLDocument.js +109 -0
- package/lib/generated/idl/XMLHttpRequest.js +663 -0
- package/lib/generated/idl/XMLHttpRequestEventTarget.js +334 -0
- package/lib/generated/idl/XMLHttpRequestResponseType.js +14 -0
- package/lib/generated/idl/XMLHttpRequestUpload.js +109 -0
- package/lib/generated/idl/XMLSerializer.js +132 -0
- package/lib/generated/idl/utils.js +252 -0
- package/lib/generated/js-globals.json +332 -0
- package/lib/jsdom/browser/Window.js +952 -0
- package/lib/jsdom/browser/default-stylesheet.css +415 -0
- package/lib/jsdom/browser/not-implemented.js +20 -0
- package/lib/jsdom/browser/parser/html.js +208 -0
- package/lib/jsdom/browser/parser/index.js +37 -0
- package/lib/jsdom/browser/parser/xml.js +202 -0
- package/lib/jsdom/browser/resources/async-resource-queue.js +114 -0
- package/lib/jsdom/browser/resources/decompress-interceptor.js +184 -0
- package/lib/jsdom/browser/resources/jsdom-dispatcher.js +756 -0
- package/lib/jsdom/browser/resources/per-document-resource-loader.js +116 -0
- package/lib/jsdom/browser/resources/request-interceptor.js +171 -0
- package/lib/jsdom/browser/resources/request-manager.js +33 -0
- package/lib/jsdom/browser/resources/resource-queue.js +142 -0
- package/lib/jsdom/browser/resources/stream-handler.js +89 -0
- package/lib/jsdom/level2/style.js +65 -0
- package/lib/jsdom/level3/xpath.js +1875 -0
- package/lib/jsdom/living/aborting/AbortController-impl.js +17 -0
- package/lib/jsdom/living/aborting/AbortSignal-impl.js +131 -0
- package/lib/jsdom/living/attributes/Attr-impl.js +60 -0
- package/lib/jsdom/living/attributes/NamedNodeMap-impl.js +78 -0
- package/lib/jsdom/living/attributes.js +312 -0
- package/lib/jsdom/living/constraint-validation/DefaultConstraintValidation-impl.js +75 -0
- package/lib/jsdom/living/constraint-validation/ValidityState-impl.js +66 -0
- package/lib/jsdom/living/crypto/Crypto-impl.js +68 -0
- package/lib/jsdom/living/cssom/StyleSheetList-impl.js +38 -0
- package/lib/jsdom/living/custom-elements/CustomElementRegistry-impl.js +279 -0
- package/lib/jsdom/living/custom-elements/ElementInternals-impl.js +56 -0
- package/lib/jsdom/living/deviceorientation/DeviceMotionEventAcceleration-impl.js +7 -0
- package/lib/jsdom/living/deviceorientation/DeviceMotionEventRotationRate-impl.js +7 -0
- package/lib/jsdom/living/documents.js +15 -0
- package/lib/jsdom/living/domparsing/DOMParser-impl.js +59 -0
- package/lib/jsdom/living/domparsing/InnerHTML-impl.js +30 -0
- package/lib/jsdom/living/domparsing/XMLSerializer-impl.js +18 -0
- package/lib/jsdom/living/domparsing/parse5-adapter-serialization.js +63 -0
- package/lib/jsdom/living/domparsing/serialization.js +36 -0
- package/lib/jsdom/living/encoding/TextDecoder-impl.js +25 -0
- package/lib/jsdom/living/encoding/TextEncoder-impl.js +26 -0
- package/lib/jsdom/living/events/BeforeUnloadEvent-impl.js +12 -0
- package/lib/jsdom/living/events/BlobEvent-impl.js +14 -0
- package/lib/jsdom/living/events/CloseEvent-impl.js +10 -0
- package/lib/jsdom/living/events/CompositionEvent-impl.js +20 -0
- package/lib/jsdom/living/events/CustomEvent-impl.js +21 -0
- package/lib/jsdom/living/events/DeviceMotionEvent-impl.js +49 -0
- package/lib/jsdom/living/events/DeviceOrientationEvent-impl.js +10 -0
- package/lib/jsdom/living/events/ErrorEvent-impl.js +14 -0
- package/lib/jsdom/living/events/Event-impl.js +195 -0
- package/lib/jsdom/living/events/EventModifierMixin-impl.js +24 -0
- package/lib/jsdom/living/events/EventTarget-impl.js +438 -0
- package/lib/jsdom/living/events/FocusEvent-impl.js +9 -0
- package/lib/jsdom/living/events/HashChangeEvent-impl.js +14 -0
- package/lib/jsdom/living/events/InputEvent-impl.js +11 -0
- package/lib/jsdom/living/events/KeyboardEvent-impl.js +29 -0
- package/lib/jsdom/living/events/MessageEvent-impl.js +25 -0
- package/lib/jsdom/living/events/MouseEvent-impl.js +72 -0
- package/lib/jsdom/living/events/PageTransitionEvent-impl.js +20 -0
- package/lib/jsdom/living/events/PointerEvent-impl.js +21 -0
- package/lib/jsdom/living/events/PopStateEvent-impl.js +9 -0
- package/lib/jsdom/living/events/ProgressEvent-impl.js +14 -0
- package/lib/jsdom/living/events/PromiseRejectionEvent-impl.js +14 -0
- package/lib/jsdom/living/events/StorageEvent-impl.js +26 -0
- package/lib/jsdom/living/events/SubmitEvent-impl.js +13 -0
- package/lib/jsdom/living/events/TouchEvent-impl.js +14 -0
- package/lib/jsdom/living/events/TransitionEvent-impl.js +10 -0
- package/lib/jsdom/living/events/UIEvent-impl.js +43 -0
- package/lib/jsdom/living/events/WheelEvent-impl.js +12 -0
- package/lib/jsdom/living/fetch/Headers-impl.js +173 -0
- package/lib/jsdom/living/fetch/header-list.js +158 -0
- package/lib/jsdom/living/fetch/header-types.js +205 -0
- package/lib/jsdom/living/fetch/header-utils.js +26 -0
- package/lib/jsdom/living/file-api/Blob-impl.js +125 -0
- package/lib/jsdom/living/file-api/File-impl.js +12 -0
- package/lib/jsdom/living/file-api/FileList-impl.js +15 -0
- package/lib/jsdom/living/file-api/FileReader-impl.js +148 -0
- package/lib/jsdom/living/geometry/DOMRect-impl.js +39 -0
- package/lib/jsdom/living/geometry/DOMRectReadOnly-impl.js +72 -0
- package/lib/jsdom/living/helpers/binary-data.js +63 -0
- package/lib/jsdom/living/helpers/by-id-cache.js +67 -0
- package/lib/jsdom/living/helpers/colors.js +245 -0
- package/lib/jsdom/living/helpers/create-element.js +329 -0
- package/lib/jsdom/living/helpers/create-event-accessor.js +209 -0
- package/lib/jsdom/living/helpers/custom-elements.js +272 -0
- package/lib/jsdom/living/helpers/dates-and-times.js +270 -0
- package/lib/jsdom/living/helpers/details.js +15 -0
- package/lib/jsdom/living/helpers/encoding.js +60 -0
- package/lib/jsdom/living/helpers/events.js +24 -0
- package/lib/jsdom/living/helpers/focusing.js +104 -0
- package/lib/jsdom/living/helpers/form-controls.js +309 -0
- package/lib/jsdom/living/helpers/html-constructor.js +78 -0
- package/lib/jsdom/living/helpers/internal-constants.js +12 -0
- package/lib/jsdom/living/helpers/is-window.js +18 -0
- package/lib/jsdom/living/helpers/iterable-weak-set.js +48 -0
- package/lib/jsdom/living/helpers/json.js +7 -0
- package/lib/jsdom/living/helpers/mutation-observers.js +198 -0
- package/lib/jsdom/living/helpers/namespaces.js +16 -0
- package/lib/jsdom/living/helpers/node.js +108 -0
- package/lib/jsdom/living/helpers/number-and-date-inputs.js +195 -0
- package/lib/jsdom/living/helpers/ordered-set.js +104 -0
- package/lib/jsdom/living/helpers/page-transition-event.js +9 -0
- package/lib/jsdom/living/helpers/runtime-script-errors.js +75 -0
- package/lib/jsdom/living/helpers/shadow-dom.js +285 -0
- package/lib/jsdom/living/helpers/strings.js +168 -0
- package/lib/jsdom/living/helpers/style-rules.js +404 -0
- package/lib/jsdom/living/helpers/stylesheets.js +148 -0
- package/lib/jsdom/living/helpers/svg/basic-types.js +41 -0
- package/lib/jsdom/living/helpers/svg/render.js +46 -0
- package/lib/jsdom/living/helpers/system-colors.js +147 -0
- package/lib/jsdom/living/helpers/text.js +19 -0
- package/lib/jsdom/living/helpers/traversal.js +72 -0
- package/lib/jsdom/living/helpers/validate-names.js +65 -0
- package/lib/jsdom/living/hr-time/Performance-impl.js +22 -0
- package/lib/jsdom/living/interfaces.js +252 -0
- package/lib/jsdom/living/mutation-observer/MutationObserver-impl.js +95 -0
- package/lib/jsdom/living/mutation-observer/MutationRecord-impl.js +37 -0
- package/lib/jsdom/living/navigator/MimeType-impl.js +3 -0
- package/lib/jsdom/living/navigator/MimeTypeArray-impl.js +21 -0
- package/lib/jsdom/living/navigator/Navigator-impl.js +29 -0
- package/lib/jsdom/living/navigator/NavigatorConcurrentHardware-impl.js +8 -0
- package/lib/jsdom/living/navigator/NavigatorCookies-impl.js +7 -0
- package/lib/jsdom/living/navigator/NavigatorID-impl.js +37 -0
- package/lib/jsdom/living/navigator/NavigatorLanguage-impl.js +9 -0
- package/lib/jsdom/living/navigator/NavigatorOnLine-impl.js +7 -0
- package/lib/jsdom/living/navigator/NavigatorPlugins-impl.js +8 -0
- package/lib/jsdom/living/navigator/Plugin-impl.js +3 -0
- package/lib/jsdom/living/navigator/PluginArray-impl.js +23 -0
- package/lib/jsdom/living/node-document-position.js +10 -0
- package/lib/jsdom/living/node-type.js +16 -0
- package/lib/jsdom/living/node.js +331 -0
- package/lib/jsdom/living/nodes/CDATASection-impl.js +16 -0
- package/lib/jsdom/living/nodes/CharacterData-impl.js +118 -0
- package/lib/jsdom/living/nodes/ChildNode-impl.js +80 -0
- package/lib/jsdom/living/nodes/Comment-impl.js +20 -0
- package/lib/jsdom/living/nodes/DOMImplementation-impl.js +120 -0
- package/lib/jsdom/living/nodes/DOMStringMap-impl.js +64 -0
- package/lib/jsdom/living/nodes/DOMTokenList-impl.js +171 -0
- package/lib/jsdom/living/nodes/Document-impl.js +1000 -0
- package/lib/jsdom/living/nodes/DocumentFragment-impl.js +44 -0
- package/lib/jsdom/living/nodes/DocumentOrShadowRoot-impl.js +28 -0
- package/lib/jsdom/living/nodes/DocumentType-impl.js +24 -0
- package/lib/jsdom/living/nodes/Element-impl.js +584 -0
- package/lib/jsdom/living/nodes/ElementCSSInlineStyle-impl.js +22 -0
- package/lib/jsdom/living/nodes/ElementContentEditable-impl.js +7 -0
- package/lib/jsdom/living/nodes/GlobalEventHandlers-impl.js +81 -0
- package/lib/jsdom/living/nodes/HTMLAnchorElement-impl.js +50 -0
- package/lib/jsdom/living/nodes/HTMLAreaElement-impl.js +43 -0
- package/lib/jsdom/living/nodes/HTMLAudioElement-impl.js +9 -0
- package/lib/jsdom/living/nodes/HTMLBRElement-impl.js +9 -0
- package/lib/jsdom/living/nodes/HTMLBaseElement-impl.js +44 -0
- package/lib/jsdom/living/nodes/HTMLBodyElement-impl.js +12 -0
- package/lib/jsdom/living/nodes/HTMLButtonElement-impl.js +79 -0
- package/lib/jsdom/living/nodes/HTMLCanvasElement-impl.js +136 -0
- package/lib/jsdom/living/nodes/HTMLCollection-impl.js +96 -0
- package/lib/jsdom/living/nodes/HTMLDListElement-impl.js +9 -0
- package/lib/jsdom/living/nodes/HTMLDataElement-impl.js +9 -0
- package/lib/jsdom/living/nodes/HTMLDataListElement-impl.js +20 -0
- package/lib/jsdom/living/nodes/HTMLDetailsElement-impl.js +35 -0
- package/lib/jsdom/living/nodes/HTMLDialogElement-impl.js +9 -0
- package/lib/jsdom/living/nodes/HTMLDirectoryElement-impl.js +9 -0
- package/lib/jsdom/living/nodes/HTMLDivElement-impl.js +9 -0
- package/lib/jsdom/living/nodes/HTMLElement-impl.js +211 -0
- package/lib/jsdom/living/nodes/HTMLEmbedElement-impl.js +8 -0
- package/lib/jsdom/living/nodes/HTMLFieldSetElement-impl.js +43 -0
- package/lib/jsdom/living/nodes/HTMLFontElement-impl.js +9 -0
- package/lib/jsdom/living/nodes/HTMLFormControlsCollection-impl.js +33 -0
- package/lib/jsdom/living/nodes/HTMLFormElement-impl.js +248 -0
- package/lib/jsdom/living/nodes/HTMLFrameElement-impl.js +266 -0
- package/lib/jsdom/living/nodes/HTMLFrameSetElement-impl.js +12 -0
- package/lib/jsdom/living/nodes/HTMLHRElement-impl.js +9 -0
- package/lib/jsdom/living/nodes/HTMLHeadElement-impl.js +9 -0
- package/lib/jsdom/living/nodes/HTMLHeadingElement-impl.js +9 -0
- package/lib/jsdom/living/nodes/HTMLHtmlElement-impl.js +9 -0
- package/lib/jsdom/living/nodes/HTMLHyperlinkElementUtils-impl.js +368 -0
- package/lib/jsdom/living/nodes/HTMLIFrameElement-impl.js +9 -0
- package/lib/jsdom/living/nodes/HTMLImageElement-impl.js +127 -0
- package/lib/jsdom/living/nodes/HTMLInputElement-impl.js +1097 -0
- package/lib/jsdom/living/nodes/HTMLLIElement-impl.js +9 -0
- package/lib/jsdom/living/nodes/HTMLLabelElement-impl.js +94 -0
- package/lib/jsdom/living/nodes/HTMLLegendElement-impl.js +18 -0
- package/lib/jsdom/living/nodes/HTMLLinkElement-impl.js +107 -0
- package/lib/jsdom/living/nodes/HTMLMapElement-impl.js +13 -0
- package/lib/jsdom/living/nodes/HTMLMarqueeElement-impl.js +9 -0
- package/lib/jsdom/living/nodes/HTMLMediaElement-impl.js +138 -0
- package/lib/jsdom/living/nodes/HTMLMenuElement-impl.js +9 -0
- package/lib/jsdom/living/nodes/HTMLMetaElement-impl.js +9 -0
- package/lib/jsdom/living/nodes/HTMLMeterElement-impl.js +180 -0
- package/lib/jsdom/living/nodes/HTMLModElement-impl.js +9 -0
- package/lib/jsdom/living/nodes/HTMLOListElement-impl.js +22 -0
- package/lib/jsdom/living/nodes/HTMLObjectElement-impl.js +26 -0
- package/lib/jsdom/living/nodes/HTMLOptGroupElement-impl.js +9 -0
- package/lib/jsdom/living/nodes/HTMLOptionElement-impl.js +146 -0
- package/lib/jsdom/living/nodes/HTMLOptionsCollection-impl.js +110 -0
- package/lib/jsdom/living/nodes/HTMLOrSVGElement-impl.js +88 -0
- package/lib/jsdom/living/nodes/HTMLOutputElement-impl.js +88 -0
- package/lib/jsdom/living/nodes/HTMLParagraphElement-impl.js +9 -0
- package/lib/jsdom/living/nodes/HTMLParamElement-impl.js +9 -0
- package/lib/jsdom/living/nodes/HTMLPictureElement-impl.js +9 -0
- package/lib/jsdom/living/nodes/HTMLPreElement-impl.js +9 -0
- package/lib/jsdom/living/nodes/HTMLProgressElement-impl.js +72 -0
- package/lib/jsdom/living/nodes/HTMLQuoteElement-impl.js +9 -0
- package/lib/jsdom/living/nodes/HTMLScriptElement-impl.js +255 -0
- package/lib/jsdom/living/nodes/HTMLSelectElement-impl.js +283 -0
- package/lib/jsdom/living/nodes/HTMLSlotElement-impl.js +59 -0
- package/lib/jsdom/living/nodes/HTMLSourceElement-impl.js +8 -0
- package/lib/jsdom/living/nodes/HTMLSpanElement-impl.js +9 -0
- package/lib/jsdom/living/nodes/HTMLStyleElement-impl.js +76 -0
- package/lib/jsdom/living/nodes/HTMLTableCaptionElement-impl.js +9 -0
- package/lib/jsdom/living/nodes/HTMLTableCellElement-impl.js +73 -0
- package/lib/jsdom/living/nodes/HTMLTableColElement-impl.js +9 -0
- package/lib/jsdom/living/nodes/HTMLTableElement-impl.js +236 -0
- package/lib/jsdom/living/nodes/HTMLTableRowElement-impl.js +88 -0
- package/lib/jsdom/living/nodes/HTMLTableSectionElement-impl.js +61 -0
- package/lib/jsdom/living/nodes/HTMLTemplateElement-impl.js +67 -0
- package/lib/jsdom/living/nodes/HTMLTextAreaElement-impl.js +244 -0
- package/lib/jsdom/living/nodes/HTMLTimeElement-impl.js +9 -0
- package/lib/jsdom/living/nodes/HTMLTitleElement-impl.js +18 -0
- package/lib/jsdom/living/nodes/HTMLTrackElement-impl.js +13 -0
- package/lib/jsdom/living/nodes/HTMLUListElement-impl.js +9 -0
- package/lib/jsdom/living/nodes/HTMLUnknownElement-impl.js +9 -0
- package/lib/jsdom/living/nodes/HTMLVideoElement-impl.js +17 -0
- package/lib/jsdom/living/nodes/LinkStyle-impl.js +2 -0
- package/lib/jsdom/living/nodes/Node-impl.js +1179 -0
- package/lib/jsdom/living/nodes/NodeList-impl.js +43 -0
- package/lib/jsdom/living/nodes/NonDocumentTypeChildNode-impl.js +28 -0
- package/lib/jsdom/living/nodes/NonElementParentNode-impl.js +11 -0
- package/lib/jsdom/living/nodes/ParentNode-impl.js +90 -0
- package/lib/jsdom/living/nodes/ProcessingInstruction-impl.js +22 -0
- package/lib/jsdom/living/nodes/RadioNodeList-impl.js +49 -0
- package/lib/jsdom/living/nodes/SVGDefsElement-impl.js +9 -0
- package/lib/jsdom/living/nodes/SVGDescElement-impl.js +9 -0
- package/lib/jsdom/living/nodes/SVGElement-impl.js +64 -0
- package/lib/jsdom/living/nodes/SVGGElement-impl.js +9 -0
- package/lib/jsdom/living/nodes/SVGGraphicsElement-impl.js +16 -0
- package/lib/jsdom/living/nodes/SVGMetadataElement-impl.js +9 -0
- package/lib/jsdom/living/nodes/SVGSVGElement-impl.js +40 -0
- package/lib/jsdom/living/nodes/SVGSwitchElement-impl.js +9 -0
- package/lib/jsdom/living/nodes/SVGSymbolElement-impl.js +9 -0
- package/lib/jsdom/living/nodes/SVGTests-impl.js +42 -0
- package/lib/jsdom/living/nodes/SVGTitleElement-impl.js +9 -0
- package/lib/jsdom/living/nodes/ShadowRoot-impl.js +41 -0
- package/lib/jsdom/living/nodes/Slotable-impl.js +48 -0
- package/lib/jsdom/living/nodes/Text-impl.js +96 -0
- package/lib/jsdom/living/nodes/WindowEventHandlers-impl.js +14 -0
- package/lib/jsdom/living/nodes/XMLDocument-impl.js +4 -0
- package/lib/jsdom/living/range/AbstractRange-impl.js +43 -0
- package/lib/jsdom/living/range/Range-impl.js +902 -0
- package/lib/jsdom/living/range/StaticRange-impl.js +39 -0
- package/lib/jsdom/living/range/boundary-point.js +47 -0
- package/lib/jsdom/living/selection/Selection-impl.js +358 -0
- package/lib/jsdom/living/svg/SVGAnimatedPreserveAspectRatio-impl.js +24 -0
- package/lib/jsdom/living/svg/SVGAnimatedRect-impl.js +122 -0
- package/lib/jsdom/living/svg/SVGAnimatedString-impl.js +42 -0
- package/lib/jsdom/living/svg/SVGListBase.js +195 -0
- package/lib/jsdom/living/svg/SVGNumber-impl.js +48 -0
- package/lib/jsdom/living/svg/SVGPreserveAspectRatio-impl.js +100 -0
- package/lib/jsdom/living/svg/SVGRect-impl.js +143 -0
- package/lib/jsdom/living/svg/SVGStringList-impl.js +16 -0
- package/lib/jsdom/living/traversal/NodeIterator-impl.js +107 -0
- package/lib/jsdom/living/traversal/TreeWalker-impl.js +217 -0
- package/lib/jsdom/living/traversal/helpers.js +44 -0
- package/lib/jsdom/living/webidl/DOMException-impl.js +46 -0
- package/lib/jsdom/living/websockets/WebSocket-impl.js +211 -0
- package/lib/jsdom/living/webstorage/Storage-impl.js +102 -0
- package/lib/jsdom/living/window/BarProp-impl.js +10 -0
- package/lib/jsdom/living/window/External-impl.js +9 -0
- package/lib/jsdom/living/window/History-impl.js +148 -0
- package/lib/jsdom/living/window/Location-impl.js +227 -0
- package/lib/jsdom/living/window/Screen-impl.js +13 -0
- package/lib/jsdom/living/window/SessionHistory.js +163 -0
- package/lib/jsdom/living/window/navigation.js +87 -0
- package/lib/jsdom/living/window-properties.js +241 -0
- package/lib/jsdom/living/xhr/FormData-impl.js +191 -0
- package/lib/jsdom/living/xhr/XMLHttpRequest-impl.js +1057 -0
- package/lib/jsdom/living/xhr/XMLHttpRequestEventTarget-impl.js +17 -0
- package/lib/jsdom/living/xhr/XMLHttpRequestUpload-impl.js +4 -0
- package/lib/jsdom/living/xhr/multipart-form-data.js +99 -0
- package/lib/jsdom/living/xhr/xhr-sync-worker.js +51 -0
- package/lib/jsdom/living/xhr/xhr-utils.js +206 -0
- package/lib/jsdom/utils.js +105 -0
- package/lib/jsdom/virtual-console.js +46 -0
- package/package.json +143 -0
|
@@ -0,0 +1,1097 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const DOMException = require("../../../generated/idl/DOMException");
|
|
3
|
+
const FileList = require("../../../generated/idl/FileList");
|
|
4
|
+
const Decimal = require("decimal.js");
|
|
5
|
+
const HTMLElementImpl = require("./HTMLElement-impl").implementation;
|
|
6
|
+
const idlUtils = require("../../../generated/idl/utils");
|
|
7
|
+
const DefaultConstraintValidationImpl =
|
|
8
|
+
require("../constraint-validation/DefaultConstraintValidation-impl").implementation;
|
|
9
|
+
const ValidityState = require("../../../generated/idl/ValidityState");
|
|
10
|
+
const { mixin } = require("../../utils");
|
|
11
|
+
const { domSymbolTree, cloningSteps } = require("../helpers/internal-constants");
|
|
12
|
+
const { getLabelsForLabelable, formOwner } = require("../helpers/form-controls");
|
|
13
|
+
const { fireAnEvent } = require("../helpers/events");
|
|
14
|
+
const {
|
|
15
|
+
isDisabled,
|
|
16
|
+
isValidEmailAddress,
|
|
17
|
+
isValidAbsoluteURL,
|
|
18
|
+
sanitizeValueByType
|
|
19
|
+
} = require("../helpers/form-controls");
|
|
20
|
+
const {
|
|
21
|
+
asciiCaseInsensitiveMatch,
|
|
22
|
+
asciiLowercase,
|
|
23
|
+
parseFloatingPointNumber,
|
|
24
|
+
splitOnCommas
|
|
25
|
+
} = require("../helpers/strings");
|
|
26
|
+
const { isDate } = require("../helpers/dates-and-times");
|
|
27
|
+
const {
|
|
28
|
+
convertStringToNumberByType,
|
|
29
|
+
convertStringToDateByType,
|
|
30
|
+
serializeDateByType,
|
|
31
|
+
convertNumberToStringByType
|
|
32
|
+
} = require("../helpers/number-and-date-inputs");
|
|
33
|
+
|
|
34
|
+
const filesSymbol = Symbol("files");
|
|
35
|
+
|
|
36
|
+
// https://html.spec.whatwg.org/multipage/input.html#attr-input-type
|
|
37
|
+
const inputAllowedTypes = new Set([
|
|
38
|
+
"hidden", "text", "search", "tel", "url", "email", "password", "date",
|
|
39
|
+
"month", "week", "time", "datetime-local", "number", "range", "color", "checkbox", "radio",
|
|
40
|
+
"file", "submit", "image", "reset", "button"
|
|
41
|
+
]);
|
|
42
|
+
|
|
43
|
+
// https://html.spec.whatwg.org/multipage/input.html#concept-input-apply
|
|
44
|
+
|
|
45
|
+
const variableLengthSelectionAllowedTypes = new Set(["text", "search", "url", "tel", "password"]);
|
|
46
|
+
const numericTypes = new Set(["date", "month", "week", "time", "datetime-local", "number", "range"]);
|
|
47
|
+
|
|
48
|
+
const applicableTypesForIDLMember = {
|
|
49
|
+
valueAsDate: new Set(["date", "month", "week", "time"]),
|
|
50
|
+
valueAsNumber: numericTypes,
|
|
51
|
+
|
|
52
|
+
select: new Set([
|
|
53
|
+
"text", "search", "url", "tel", "email", "password", "date", "month", "week",
|
|
54
|
+
"time", "datetime-local", "number", "color", "file"
|
|
55
|
+
]),
|
|
56
|
+
selectionStart: variableLengthSelectionAllowedTypes,
|
|
57
|
+
selectionEnd: variableLengthSelectionAllowedTypes,
|
|
58
|
+
selectionDirection: variableLengthSelectionAllowedTypes,
|
|
59
|
+
setRangeText: variableLengthSelectionAllowedTypes,
|
|
60
|
+
setSelectionRange: variableLengthSelectionAllowedTypes,
|
|
61
|
+
stepDown: numericTypes,
|
|
62
|
+
stepUp: numericTypes
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const lengthPatternSizeTypes = new Set(["text", "search", "url", "tel", "email", "password"]);
|
|
66
|
+
const readonlyTypes =
|
|
67
|
+
new Set([...lengthPatternSizeTypes, "date", "month", "week", "time", "datetime-local", "number"]);
|
|
68
|
+
|
|
69
|
+
const applicableTypesForContentAttribute = {
|
|
70
|
+
list: new Set(["text", "search", "url", "tel", "email", ...numericTypes, "color"]),
|
|
71
|
+
max: numericTypes,
|
|
72
|
+
maxlength: lengthPatternSizeTypes,
|
|
73
|
+
min: numericTypes,
|
|
74
|
+
minlength: lengthPatternSizeTypes,
|
|
75
|
+
multiple: new Set(["email", "file"]),
|
|
76
|
+
pattern: lengthPatternSizeTypes,
|
|
77
|
+
readonly: readonlyTypes,
|
|
78
|
+
required: new Set([...readonlyTypes, "checkbox", "radio", "file"]),
|
|
79
|
+
step: numericTypes
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const valueAttributeDefaultMode = new Set(["hidden", "submit", "image", "reset", "button"]);
|
|
83
|
+
const valueAttributeDefaultOnMode = new Set(["checkbox", "radio"]);
|
|
84
|
+
|
|
85
|
+
function valueAttributeMode(type) {
|
|
86
|
+
if (valueAttributeDefaultMode.has(type)) {
|
|
87
|
+
return "default";
|
|
88
|
+
}
|
|
89
|
+
if (valueAttributeDefaultOnMode.has(type)) {
|
|
90
|
+
return "default/on";
|
|
91
|
+
}
|
|
92
|
+
if (type === "file") {
|
|
93
|
+
return "filename";
|
|
94
|
+
}
|
|
95
|
+
return "value";
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function getTypeFromAttribute(typeAttribute) {
|
|
99
|
+
if (typeof typeAttribute !== "string") {
|
|
100
|
+
return "text";
|
|
101
|
+
}
|
|
102
|
+
const type = asciiLowercase(typeAttribute);
|
|
103
|
+
return inputAllowedTypes.has(type) ? type : "text";
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
class HTMLInputElementImpl extends HTMLElementImpl {
|
|
107
|
+
constructor(globalObject, args, privateData) {
|
|
108
|
+
super(globalObject, args, privateData);
|
|
109
|
+
|
|
110
|
+
this._selectionStart = this._selectionEnd = 0;
|
|
111
|
+
this._selectionDirection = "none";
|
|
112
|
+
this._value = "";
|
|
113
|
+
this._dirtyValue = false;
|
|
114
|
+
this._checkedness = false;
|
|
115
|
+
this._dirtyCheckedness = false;
|
|
116
|
+
|
|
117
|
+
this._preCheckedRadioState = null;
|
|
118
|
+
this._legacyActivationBehaviorPreviousIndeterminateState = false;
|
|
119
|
+
|
|
120
|
+
this.indeterminate = false;
|
|
121
|
+
|
|
122
|
+
this._customValidityErrorMessage = "";
|
|
123
|
+
|
|
124
|
+
this._labels = null;
|
|
125
|
+
|
|
126
|
+
this._hasActivationBehavior = true;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// https://html.spec.whatwg.org/multipage/input.html#concept-input-value-string-number
|
|
130
|
+
get _convertStringToNumber() {
|
|
131
|
+
return convertStringToNumberByType[this.type];
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
get _convertNumberToString() {
|
|
135
|
+
return convertNumberToStringByType[this.type];
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
get _convertDateToString() {
|
|
139
|
+
return serializeDateByType[this.type];
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
get _convertStringToDate() {
|
|
143
|
+
return convertStringToDateByType[this.type];
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
_isStepAligned(v) {
|
|
147
|
+
return new Decimal(v).minus(this._stepBase)
|
|
148
|
+
.modulo(this._allowedValueStep)
|
|
149
|
+
.isZero();
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// Returns a Decimal.
|
|
153
|
+
_stepAlign(v, roundUp) {
|
|
154
|
+
const allowedValueStep = this._allowedValueStep;
|
|
155
|
+
const stepBase = this._stepBase;
|
|
156
|
+
|
|
157
|
+
return new Decimal(v).minus(stepBase)
|
|
158
|
+
.toNearest(allowedValueStep, roundUp ? Decimal.ROUND_UP : Decimal.ROUND_DOWN)
|
|
159
|
+
.add(stepBase);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// For <input>, https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#concept-fe-value
|
|
163
|
+
// is a simple value that is gotten and set, not computed.
|
|
164
|
+
_getValue() {
|
|
165
|
+
return this._value;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
_legacyPreActivationBehavior() {
|
|
169
|
+
if (this.type === "checkbox") {
|
|
170
|
+
this.checked = !this.checked;
|
|
171
|
+
this._legacyActivationBehaviorPreviousIndeterminateState = this.indeterminate;
|
|
172
|
+
this.indeterminate = false;
|
|
173
|
+
} else if (this.type === "radio") {
|
|
174
|
+
this._preCheckedRadioState = this.checked;
|
|
175
|
+
this.checked = true;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
_legacyCanceledActivationBehavior() {
|
|
180
|
+
if (this.type === "checkbox") {
|
|
181
|
+
this.checked = !this.checked;
|
|
182
|
+
this.indeterminate = this._legacyActivationBehaviorPreviousIndeterminateState;
|
|
183
|
+
} else if (this.type === "radio") {
|
|
184
|
+
if (this._preCheckedRadioState !== null) {
|
|
185
|
+
this.checked = this._preCheckedRadioState;
|
|
186
|
+
this._preCheckedRadioState = null;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
_activationBehavior(event) {
|
|
192
|
+
if (!this._mutable && this.type !== "checkbox" && this.type !== "radio") {
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
const { form } = this;
|
|
197
|
+
|
|
198
|
+
if (this.type === "checkbox" || (this.type === "radio" && !this._preCheckedRadioState)) {
|
|
199
|
+
if (this.isConnected) {
|
|
200
|
+
fireAnEvent("input", this, undefined, { bubbles: true });
|
|
201
|
+
fireAnEvent("change", this, undefined, { bubbles: true });
|
|
202
|
+
}
|
|
203
|
+
} else if (form && this.type === "image") {
|
|
204
|
+
// https://html.spec.whatwg.org/multipage/input.html#image-button-state-(type=image):input-activation-behavior
|
|
205
|
+
|
|
206
|
+
// TODO: if/when layout is implemented, record the selected coordinate at the start of dispatch and use it here,
|
|
207
|
+
// rather than relying on these getters that just mirror pageX/Y outside of dispatch
|
|
208
|
+
this._selectedCoordinate = { x: event.offsetX, y: event.offsetY };
|
|
209
|
+
form._doRequestSubmit(this);
|
|
210
|
+
} else if (form && this.type === "submit") {
|
|
211
|
+
form._doRequestSubmit(this);
|
|
212
|
+
} else if (form && this.type === "reset") {
|
|
213
|
+
form._doReset();
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
_attrModified(name, value, oldVal) {
|
|
218
|
+
const wrapper = idlUtils.wrapperForImpl(this);
|
|
219
|
+
if (!this._dirtyValue && name === "value") {
|
|
220
|
+
this._value = sanitizeValueByType(this, wrapper.defaultValue);
|
|
221
|
+
}
|
|
222
|
+
if (!this._dirtyCheckedness && name === "checked") {
|
|
223
|
+
this._checkedness = wrapper.defaultChecked;
|
|
224
|
+
if (this._checkedness) {
|
|
225
|
+
this._removeOtherRadioCheckedness();
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
if (name === "name" || name === "type") {
|
|
230
|
+
if (this._checkedness) {
|
|
231
|
+
this._removeOtherRadioCheckedness();
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
if (name === "type") {
|
|
236
|
+
const prevType = getTypeFromAttribute(oldVal);
|
|
237
|
+
const curType = getTypeFromAttribute(value);
|
|
238
|
+
// When an input element's type attribute changes state…
|
|
239
|
+
if (prevType !== curType) {
|
|
240
|
+
const prevValueMode = valueAttributeMode(prevType);
|
|
241
|
+
const curValueMode = valueAttributeMode(curType);
|
|
242
|
+
if (prevValueMode === "value" && this._value !== "" &&
|
|
243
|
+
(curValueMode === "default" || curValueMode === "default/on")) {
|
|
244
|
+
this.setAttributeNS(null, "value", this._value);
|
|
245
|
+
} else if (prevValueMode !== "value" && curValueMode === "value") {
|
|
246
|
+
this._value = this.getAttributeNS(null, "value") || "";
|
|
247
|
+
this._dirtyValue = false;
|
|
248
|
+
} else if (prevValueMode !== "filename" && curValueMode === "filename") {
|
|
249
|
+
this._value = "";
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
this._signalATypeChange();
|
|
253
|
+
|
|
254
|
+
this._value = sanitizeValueByType(this, this._value);
|
|
255
|
+
|
|
256
|
+
const previouslySelectable = this._idlMemberApplies("setRangeText", prevType);
|
|
257
|
+
const nowSelectable = this._idlMemberApplies("setRangeText", curType);
|
|
258
|
+
if (!previouslySelectable && nowSelectable) {
|
|
259
|
+
this._selectionStart = 0;
|
|
260
|
+
this._selectionEnd = 0;
|
|
261
|
+
this._selectionDirection = "none";
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
super._attrModified(name, value, oldVal);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
// https://html.spec.whatwg.org/multipage/input.html#signal-a-type-change
|
|
270
|
+
_signalATypeChange() {
|
|
271
|
+
if (this._checkedness) {
|
|
272
|
+
this._removeOtherRadioCheckedness();
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
_formReset() {
|
|
277
|
+
const wrapper = idlUtils.wrapperForImpl(this);
|
|
278
|
+
this._value = sanitizeValueByType(this, wrapper.defaultValue);
|
|
279
|
+
this._dirtyValue = false;
|
|
280
|
+
this._checkedness = wrapper.defaultChecked;
|
|
281
|
+
this._dirtyCheckedness = false;
|
|
282
|
+
if (this._checkedness) {
|
|
283
|
+
this._removeOtherRadioCheckedness();
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
_changedFormOwner() {
|
|
288
|
+
if (this._checkedness) {
|
|
289
|
+
this._removeOtherRadioCheckedness();
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
get _otherRadioGroupElements() {
|
|
294
|
+
const wrapper = idlUtils.wrapperForImpl(this);
|
|
295
|
+
const root = this._radioButtonGroupRoot;
|
|
296
|
+
if (!root) {
|
|
297
|
+
return [];
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
const result = [];
|
|
301
|
+
|
|
302
|
+
const descendants = domSymbolTree.treeIterator(root);
|
|
303
|
+
for (const candidate of descendants) {
|
|
304
|
+
if (candidate._radioButtonGroupRoot !== root) {
|
|
305
|
+
continue;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
const candidateWrapper = idlUtils.wrapperForImpl(candidate);
|
|
309
|
+
if (!candidateWrapper.name || candidateWrapper.name !== wrapper.name) {
|
|
310
|
+
continue;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
if (candidate !== this) {
|
|
314
|
+
result.push(candidate);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
return result;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
_removeOtherRadioCheckedness() {
|
|
321
|
+
for (const radioGroupElement of this._otherRadioGroupElements) {
|
|
322
|
+
radioGroupElement._checkedness = false;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
get _radioButtonGroupRoot() {
|
|
327
|
+
const wrapper = idlUtils.wrapperForImpl(this);
|
|
328
|
+
if (this.type !== "radio" || !wrapper.name) {
|
|
329
|
+
return null;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
let e = domSymbolTree.parent(this);
|
|
333
|
+
while (e) {
|
|
334
|
+
// root node of this home sub tree
|
|
335
|
+
// or the form element we belong to
|
|
336
|
+
if (!domSymbolTree.parent(e) || e._localName === "form") {
|
|
337
|
+
return e;
|
|
338
|
+
}
|
|
339
|
+
e = domSymbolTree.parent(e);
|
|
340
|
+
}
|
|
341
|
+
return null;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
_someInRadioGroup(name) {
|
|
345
|
+
if (this[name]) {
|
|
346
|
+
return true;
|
|
347
|
+
}
|
|
348
|
+
return this._otherRadioGroupElements.some(radioGroupElement => radioGroupElement[name]);
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
get _mutable() {
|
|
352
|
+
return !isDisabled(this) && !this._hasAttributeAndApplies("readonly");
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
get labels() {
|
|
356
|
+
return getLabelsForLabelable(this);
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
get form() {
|
|
360
|
+
return formOwner(this);
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
get checked() {
|
|
364
|
+
return this._checkedness;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
set checked(checked) {
|
|
368
|
+
this._checkedness = Boolean(checked);
|
|
369
|
+
this._dirtyCheckedness = true;
|
|
370
|
+
if (this._checkedness) {
|
|
371
|
+
this._removeOtherRadioCheckedness();
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
get value() {
|
|
376
|
+
switch (valueAttributeMode(this.type)) {
|
|
377
|
+
// https://html.spec.whatwg.org/multipage/input.html#dom-input-value-value
|
|
378
|
+
case "value":
|
|
379
|
+
return this._getValue();
|
|
380
|
+
// https://html.spec.whatwg.org/multipage/input.html#dom-input-value-default
|
|
381
|
+
case "default": {
|
|
382
|
+
const attr = this.getAttributeNS(null, "value");
|
|
383
|
+
return attr !== null ? attr : "";
|
|
384
|
+
}
|
|
385
|
+
// https://html.spec.whatwg.org/multipage/input.html#dom-input-value-default-on
|
|
386
|
+
case "default/on": {
|
|
387
|
+
const attr = this.getAttributeNS(null, "value");
|
|
388
|
+
return attr !== null ? attr : "on";
|
|
389
|
+
}
|
|
390
|
+
// https://html.spec.whatwg.org/multipage/input.html#dom-input-value-filename
|
|
391
|
+
case "filename":
|
|
392
|
+
return this.files.length ? "C:\\fakepath\\" + this.files[0].name : "";
|
|
393
|
+
default:
|
|
394
|
+
throw new Error("jsdom internal error: unknown value attribute mode");
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
set value(val) {
|
|
399
|
+
switch (valueAttributeMode(this.type)) {
|
|
400
|
+
// https://html.spec.whatwg.org/multipage/input.html#dom-input-value-value
|
|
401
|
+
case "value": {
|
|
402
|
+
const oldValue = this._value;
|
|
403
|
+
this._value = sanitizeValueByType(this, val);
|
|
404
|
+
this._dirtyValue = true;
|
|
405
|
+
|
|
406
|
+
if (oldValue !== this._value) {
|
|
407
|
+
this._selectionStart = this._selectionEnd = this._getValueLength();
|
|
408
|
+
this._selectionDirection = "none";
|
|
409
|
+
}
|
|
410
|
+
break;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
// https://html.spec.whatwg.org/multipage/input.html#dom-input-value-default
|
|
414
|
+
// https://html.spec.whatwg.org/multipage/input.html#dom-input-value-default-on
|
|
415
|
+
case "default":
|
|
416
|
+
case "default/on":
|
|
417
|
+
this.setAttributeNS(null, "value", val);
|
|
418
|
+
break;
|
|
419
|
+
|
|
420
|
+
// https://html.spec.whatwg.org/multipage/input.html#dom-input-value-filename
|
|
421
|
+
case "filename":
|
|
422
|
+
if (val === "") {
|
|
423
|
+
this.files.length = 0;
|
|
424
|
+
} else {
|
|
425
|
+
throw DOMException.create(this._globalObject, [
|
|
426
|
+
"This input element accepts a filename, which may only be programmatically set to the empty string.",
|
|
427
|
+
"InvalidStateError"
|
|
428
|
+
]);
|
|
429
|
+
}
|
|
430
|
+
break;
|
|
431
|
+
|
|
432
|
+
default:
|
|
433
|
+
throw new Error("jsdom internal error: unknown value attribute mode");
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
// https://html.spec.whatwg.org/multipage/input.html#dom-input-valueasdate
|
|
438
|
+
get valueAsDate() {
|
|
439
|
+
if (!this._idlMemberApplies("valueAsDate")) {
|
|
440
|
+
return null;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
const window = this._ownerDocument._defaultView;
|
|
444
|
+
const convertedValue = this._convertStringToDate(this._value);
|
|
445
|
+
|
|
446
|
+
if (convertedValue instanceof Date) {
|
|
447
|
+
return new window.Date(convertedValue.getTime());
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
return null;
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
set valueAsDate(v) {
|
|
454
|
+
if (!this._idlMemberApplies("valueAsDate")) {
|
|
455
|
+
throw DOMException.create(this._globalObject, [
|
|
456
|
+
"Failed to set the 'valueAsDate' property on 'HTMLInputElement': This input element does not support Date " +
|
|
457
|
+
"values.",
|
|
458
|
+
"InvalidStateError"
|
|
459
|
+
]);
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
if (v !== null && !isDate(v)) {
|
|
463
|
+
throw new TypeError("Failed to set the 'valueAsDate' property on 'HTMLInputElement': The provided value is " +
|
|
464
|
+
"not a Date.");
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
if (v === null || isNaN(v)) {
|
|
468
|
+
this._value = "";
|
|
469
|
+
return;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
this._value = this._convertDateToString(v);
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
// https://html.spec.whatwg.org/multipage/input.html#dom-input-valueasnumber
|
|
476
|
+
get valueAsNumber() {
|
|
477
|
+
if (!this._idlMemberApplies("valueAsNumber")) {
|
|
478
|
+
return NaN;
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
const parsedValue = this._convertStringToNumber(this._value);
|
|
482
|
+
return parsedValue !== null ? parsedValue : NaN;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
set valueAsNumber(v) {
|
|
486
|
+
if (!isFinite(v) && !isNaN(v)) {
|
|
487
|
+
throw new TypeError("Failed to set infinite value as Number");
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
if (!this._idlMemberApplies("valueAsNumber")) {
|
|
491
|
+
throw DOMException.create(this._globalObject, [
|
|
492
|
+
"Failed to set the 'valueAsNumber' property on 'HTMLInputElement': This input element does not support " +
|
|
493
|
+
"Number values.",
|
|
494
|
+
"InvalidStateError"
|
|
495
|
+
]);
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
if (isNaN(v)) {
|
|
499
|
+
this._value = "";
|
|
500
|
+
} else {
|
|
501
|
+
this._value = this._convertNumberToString(v);
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
// https://html.spec.whatwg.org/multipage/input.html#dom-input-stepup
|
|
506
|
+
_stepUpdate(n, isUp) {
|
|
507
|
+
const methodName = isUp ? "stepUp" : "stepDown";
|
|
508
|
+
if (!this._idlMemberApplies(methodName)) {
|
|
509
|
+
throw DOMException.create(this._globalObject, [
|
|
510
|
+
`Failed to invoke '${methodName}' method on 'HTMLInputElement': ` +
|
|
511
|
+
"This input element does not support Number values.",
|
|
512
|
+
"InvalidStateError"
|
|
513
|
+
]);
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
const allowedValueStep = this._allowedValueStep;
|
|
517
|
+
if (allowedValueStep === null) {
|
|
518
|
+
throw DOMException.create(this._globalObject, [
|
|
519
|
+
`Failed to invoke '${methodName}' method on 'HTMLInputElement': ` +
|
|
520
|
+
"This input element does not support value step.",
|
|
521
|
+
"InvalidStateError"
|
|
522
|
+
]);
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
const min = this._minimum;
|
|
526
|
+
const max = this._maximum;
|
|
527
|
+
|
|
528
|
+
if (min !== null && max !== null) {
|
|
529
|
+
if (min > max) {
|
|
530
|
+
return;
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
const candidateStepValue = this._stepAlign(Decimal.add(min, allowedValueStep), /* roundUp = */ false);
|
|
534
|
+
if (candidateStepValue.lt(min) || candidateStepValue.gt(max)) {
|
|
535
|
+
return;
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
let value = 0;
|
|
540
|
+
try {
|
|
541
|
+
value = this.valueAsNumber;
|
|
542
|
+
if (isNaN(value)) { // Empty value is parsed as NaN.
|
|
543
|
+
value = 0;
|
|
544
|
+
}
|
|
545
|
+
} catch {
|
|
546
|
+
// Step 5. Default value is 0.
|
|
547
|
+
}
|
|
548
|
+
value = new Decimal(value);
|
|
549
|
+
|
|
550
|
+
const valueBeforeStepping = value;
|
|
551
|
+
|
|
552
|
+
if (!this._isStepAligned(value)) {
|
|
553
|
+
value = this._stepAlign(value, /* roundUp = */ isUp);
|
|
554
|
+
} else {
|
|
555
|
+
let delta = Decimal.mul(n, allowedValueStep);
|
|
556
|
+
if (!isUp) {
|
|
557
|
+
delta = delta.neg();
|
|
558
|
+
}
|
|
559
|
+
value = value.add(delta);
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
if (min !== null && value.lt(min)) {
|
|
563
|
+
value = this._stepAlign(min, /* roundUp = */ true);
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
if (max !== null && value.gt(max)) {
|
|
567
|
+
value = this._stepAlign(max, /* roundUp = */ false);
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
if (isUp ? value.lt(valueBeforeStepping) : value.gt(valueBeforeStepping)) {
|
|
571
|
+
return;
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
this._value = this._convertNumberToString(value.toNumber());
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
stepDown(n = 1) {
|
|
578
|
+
return this._stepUpdate(n, false);
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
stepUp(n = 1) {
|
|
582
|
+
return this._stepUpdate(n, true);
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
get files() {
|
|
586
|
+
if (this.type === "file") {
|
|
587
|
+
this[filesSymbol] ||= FileList.createImpl(this._globalObject);
|
|
588
|
+
} else {
|
|
589
|
+
this[filesSymbol] = null;
|
|
590
|
+
}
|
|
591
|
+
return this[filesSymbol];
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
set files(value) {
|
|
595
|
+
if (this.type === "file" && value !== null) {
|
|
596
|
+
this[filesSymbol] = value;
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
get type() {
|
|
601
|
+
const typeAttribute = this.getAttributeNS(null, "type");
|
|
602
|
+
return getTypeFromAttribute(typeAttribute);
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
set type(type) {
|
|
606
|
+
this.setAttributeNS(null, "type", type);
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
_dispatchSelectEvent() {
|
|
610
|
+
setTimeout(() => fireAnEvent("select", this, undefined, { bubbles: true, cancelable: false }), 0);
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
_getValueLength() {
|
|
614
|
+
return typeof this.value === "string" ? this.value.length : 0;
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
select() {
|
|
618
|
+
if (!this._idlMemberApplies("select")) {
|
|
619
|
+
return;
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
this._selectionStart = 0;
|
|
623
|
+
this._selectionEnd = this._getValueLength();
|
|
624
|
+
this._selectionDirection = "none";
|
|
625
|
+
this._dispatchSelectEvent();
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
get selectionStart() {
|
|
629
|
+
if (!this._idlMemberApplies("selectionStart")) {
|
|
630
|
+
return null;
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
return this._selectionStart;
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
set selectionStart(start) {
|
|
637
|
+
if (!this._idlMemberApplies("selectionStart")) {
|
|
638
|
+
throw DOMException.create(this._globalObject, ["The object is in an invalid state.", "InvalidStateError"]);
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
this.setSelectionRange(start, Math.max(start, this._selectionEnd), this._selectionDirection);
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
get selectionEnd() {
|
|
645
|
+
if (!this._idlMemberApplies("selectionEnd")) {
|
|
646
|
+
return null;
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
return this._selectionEnd;
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
set selectionEnd(end) {
|
|
653
|
+
if (!this._idlMemberApplies("selectionEnd")) {
|
|
654
|
+
throw DOMException.create(this._globalObject, ["The object is in an invalid state.", "InvalidStateError"]);
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
this.setSelectionRange(this._selectionStart, end, this._selectionDirection);
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
get selectionDirection() {
|
|
661
|
+
if (!this._idlMemberApplies("selectionDirection")) {
|
|
662
|
+
return null;
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
return this._selectionDirection;
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
set selectionDirection(dir) {
|
|
669
|
+
if (!this._idlMemberApplies("selectionDirection")) {
|
|
670
|
+
throw DOMException.create(this._globalObject, ["The object is in an invalid state.", "InvalidStateError"]);
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
this.setSelectionRange(this._selectionStart, this._selectionEnd, dir);
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
setSelectionRange(start, end, dir) {
|
|
677
|
+
if (!this._idlMemberApplies("setSelectionRange")) {
|
|
678
|
+
throw DOMException.create(this._globalObject, ["The object is in an invalid state.", "InvalidStateError"]);
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
this._selectionEnd = Math.min(end, this._getValueLength());
|
|
682
|
+
this._selectionStart = Math.min(start, this._selectionEnd);
|
|
683
|
+
this._selectionDirection = dir === "forward" || dir === "backward" ? dir : "none";
|
|
684
|
+
this._dispatchSelectEvent();
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
setRangeText(repl, start, end, selectionMode = "preserve") {
|
|
688
|
+
if (!this._idlMemberApplies("setRangeText")) {
|
|
689
|
+
throw DOMException.create(this._globalObject, ["The object is in an invalid state.", "InvalidStateError"]);
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
if (arguments.length < 2) {
|
|
693
|
+
start = this._selectionStart;
|
|
694
|
+
end = this._selectionEnd;
|
|
695
|
+
} else if (start > end) {
|
|
696
|
+
throw DOMException.create(this._globalObject, ["The index is not in the allowed range.", "IndexSizeError"]);
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
start = Math.min(start, this._getValueLength());
|
|
700
|
+
end = Math.min(end, this._getValueLength());
|
|
701
|
+
|
|
702
|
+
const val = this.value;
|
|
703
|
+
let selStart = this._selectionStart;
|
|
704
|
+
let selEnd = this._selectionEnd;
|
|
705
|
+
|
|
706
|
+
this.value = val.slice(0, start) + repl + val.slice(end);
|
|
707
|
+
|
|
708
|
+
const newEnd = start + repl.length;
|
|
709
|
+
|
|
710
|
+
if (selectionMode === "select") {
|
|
711
|
+
this.setSelectionRange(start, newEnd);
|
|
712
|
+
} else if (selectionMode === "start") {
|
|
713
|
+
this.setSelectionRange(start, start);
|
|
714
|
+
} else if (selectionMode === "end") {
|
|
715
|
+
this.setSelectionRange(newEnd, newEnd);
|
|
716
|
+
} else { // preserve
|
|
717
|
+
const delta = repl.length - (end - start);
|
|
718
|
+
|
|
719
|
+
if (selStart > end) {
|
|
720
|
+
selStart += delta;
|
|
721
|
+
} else if (selStart > start) {
|
|
722
|
+
selStart = start;
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
if (selEnd > end) {
|
|
726
|
+
selEnd += delta;
|
|
727
|
+
} else if (selEnd > start) {
|
|
728
|
+
selEnd = newEnd;
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
this.setSelectionRange(selStart, selEnd);
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
// https://html.spec.whatwg.org/multipage/input.html#the-list-attribute
|
|
736
|
+
get list() {
|
|
737
|
+
const id = this._getAttributeIfApplies("list");
|
|
738
|
+
if (!id) {
|
|
739
|
+
return null;
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
const el = this.getRootNode({}).getElementById(id);
|
|
743
|
+
|
|
744
|
+
if (el && el.localName === "datalist") {
|
|
745
|
+
return el;
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
return null;
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
// https://html.spec.whatwg.org/multipage/input.html#the-min-and-max-attributes
|
|
752
|
+
get _minimum() {
|
|
753
|
+
let min = this._defaultMinimum;
|
|
754
|
+
const attr = this._getAttributeIfApplies("min");
|
|
755
|
+
if (attr !== null && this._convertStringToNumber !== undefined) {
|
|
756
|
+
const parsed = this._convertStringToNumber(attr);
|
|
757
|
+
if (parsed !== null) {
|
|
758
|
+
min = parsed;
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
return min;
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
get _maximum() {
|
|
765
|
+
let max = this._defaultMaximum;
|
|
766
|
+
const attr = this._getAttributeIfApplies("max");
|
|
767
|
+
if (attr !== null && this._convertStringToNumber !== undefined) {
|
|
768
|
+
const parsed = this._convertStringToNumber(attr);
|
|
769
|
+
if (parsed !== null) {
|
|
770
|
+
max = parsed;
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
return max;
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
get _defaultMinimum() {
|
|
777
|
+
if (this.type === "range") {
|
|
778
|
+
return 0;
|
|
779
|
+
}
|
|
780
|
+
return null;
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
get _defaultMaximum() {
|
|
784
|
+
if (this.type === "range") {
|
|
785
|
+
return 100;
|
|
786
|
+
}
|
|
787
|
+
return null;
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
// https://html.spec.whatwg.org/multipage/input.html#concept-input-step
|
|
791
|
+
get _allowedValueStep() {
|
|
792
|
+
if (!this._contentAttributeApplies("step")) {
|
|
793
|
+
return null;
|
|
794
|
+
}
|
|
795
|
+
const attr = this.getAttributeNS(null, "step");
|
|
796
|
+
if (attr === null) {
|
|
797
|
+
return this._defaultStep * this._stepScaleFactor;
|
|
798
|
+
}
|
|
799
|
+
if (asciiCaseInsensitiveMatch(attr, "any")) {
|
|
800
|
+
return null;
|
|
801
|
+
}
|
|
802
|
+
const parsedStep = parseFloatingPointNumber(attr);
|
|
803
|
+
if (parsedStep === null || parsedStep <= 0) {
|
|
804
|
+
return this._defaultStep * this._stepScaleFactor;
|
|
805
|
+
}
|
|
806
|
+
return parsedStep * this._stepScaleFactor;
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
// https://html.spec.whatwg.org/multipage/input.html#concept-input-step-scale
|
|
810
|
+
get _stepScaleFactor() {
|
|
811
|
+
const dayInMilliseconds = 24 * 60 * 60 * 1000;
|
|
812
|
+
switch (this.type) {
|
|
813
|
+
case "week":
|
|
814
|
+
return 7 * dayInMilliseconds;
|
|
815
|
+
case "date":
|
|
816
|
+
return dayInMilliseconds;
|
|
817
|
+
case "datetime-local":
|
|
818
|
+
case "datetime":
|
|
819
|
+
case "time":
|
|
820
|
+
return 1000;
|
|
821
|
+
}
|
|
822
|
+
return 1;
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
// https://html.spec.whatwg.org/multipage/input.html#concept-input-step-default
|
|
826
|
+
get _defaultStep() {
|
|
827
|
+
if (this.type === "datetime-local" || this.type === "datetime" || this.type === "time") {
|
|
828
|
+
return 60;
|
|
829
|
+
}
|
|
830
|
+
return 1;
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
// https://html.spec.whatwg.org/multipage/input.html#concept-input-min-zero
|
|
834
|
+
get _stepBase() {
|
|
835
|
+
if (this._hasAttributeAndApplies("min")) {
|
|
836
|
+
const min = this._convertStringToNumber(this.getAttributeNS(null, "min"));
|
|
837
|
+
if (min !== null) {
|
|
838
|
+
return min;
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
if (this.hasAttributeNS(null, "value")) {
|
|
842
|
+
const value = this._convertStringToNumber(this.getAttributeNS(null, "value"));
|
|
843
|
+
if (value !== null) {
|
|
844
|
+
return value;
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
if (this._defaultStepBase !== null) {
|
|
848
|
+
return this._defaultStepBase;
|
|
849
|
+
}
|
|
850
|
+
return 0;
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
// https://html.spec.whatwg.org/multipage/input.html#concept-input-step-default-base
|
|
854
|
+
get _defaultStepBase() {
|
|
855
|
+
if (this.type === "week") {
|
|
856
|
+
// The start of week 1970-W01
|
|
857
|
+
return -259200000;
|
|
858
|
+
}
|
|
859
|
+
return null;
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
// https://html.spec.whatwg.org/multipage/input.html#common-input-element-attributes
|
|
863
|
+
// When an attribute doesn't apply to an input element, user agents must ignore the attribute.
|
|
864
|
+
_contentAttributeApplies(attribute) {
|
|
865
|
+
return applicableTypesForContentAttribute[attribute].has(this.type);
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
_hasAttributeAndApplies(attribute) {
|
|
869
|
+
return this._contentAttributeApplies(attribute) && this.hasAttributeNS(null, attribute);
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
_getAttributeIfApplies(attribute) {
|
|
873
|
+
if (this._contentAttributeApplies(attribute)) {
|
|
874
|
+
return this.getAttributeNS(null, attribute);
|
|
875
|
+
}
|
|
876
|
+
return null;
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
_idlMemberApplies(member, type = this.type) {
|
|
880
|
+
return applicableTypesForIDLMember[member].has(type);
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
_barredFromConstraintValidationSpecialization() {
|
|
884
|
+
// https://html.spec.whatwg.org/multipage/input.html#hidden-state-(type=hidden)
|
|
885
|
+
// https://html.spec.whatwg.org/multipage/input.html#reset-button-state-(type=reset)
|
|
886
|
+
// https://html.spec.whatwg.org/multipage/input.html#button-state-(type=button)
|
|
887
|
+
const willNotValidateTypes = new Set(["hidden", "reset", "button"]);
|
|
888
|
+
// https://html.spec.whatwg.org/multipage/input.html#attr-input-readonly
|
|
889
|
+
const readOnly = this._hasAttributeAndApplies("readonly");
|
|
890
|
+
|
|
891
|
+
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#attr-fe-disabled
|
|
892
|
+
return willNotValidateTypes.has(this.type) || readOnly;
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
// https://html.spec.whatwg.org/multipage/input.html#concept-input-required
|
|
896
|
+
get _required() {
|
|
897
|
+
return this._hasAttributeAndApplies("required");
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
// https://html.spec.whatwg.org/multipage/input.html#has-a-periodic-domain
|
|
901
|
+
get _hasAPeriodicDomain() {
|
|
902
|
+
return this.type === "time";
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
// https://html.spec.whatwg.org/multipage/input.html#has-a-reversed-range
|
|
906
|
+
get _hasAReversedRange() {
|
|
907
|
+
return this._hasAPeriodicDomain && this._maximum < this._minimum;
|
|
908
|
+
}
|
|
909
|
+
|
|
910
|
+
get validity() {
|
|
911
|
+
if (!this._validity) {
|
|
912
|
+
// Constraint validation: When an element has a reversed range, and the result of applying
|
|
913
|
+
// the algorithm to convert a string to a number to the string given by the element's value
|
|
914
|
+
// is a number, and the number obtained from that algorithm is more than the maximum and less
|
|
915
|
+
// than the minimum, the element is simultaneously suffering from an underflow and suffering
|
|
916
|
+
// from an overflow.
|
|
917
|
+
const reversedRangeSufferingOverUnderflow = () => {
|
|
918
|
+
const parsedValue = this._convertStringToNumber(this._value);
|
|
919
|
+
return parsedValue !== null && parsedValue > this._maximum && parsedValue < this._minimum;
|
|
920
|
+
};
|
|
921
|
+
|
|
922
|
+
const state = {
|
|
923
|
+
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#suffering-from-being-missing
|
|
924
|
+
valueMissing: () => {
|
|
925
|
+
// https://html.spec.whatwg.org/multipage/input.html#the-required-attribute
|
|
926
|
+
// Constraint validation: If the element is required, and its value IDL attribute applies
|
|
927
|
+
// and is in the mode value, and the element is mutable, and the element's value is the
|
|
928
|
+
// empty string, then the element is suffering from being missing.
|
|
929
|
+
//
|
|
930
|
+
// Note: As of today, the value IDL attribute always applies.
|
|
931
|
+
if (this._required && valueAttributeMode(this.type) === "value" && this._mutable && this._value === "") {
|
|
932
|
+
return true;
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
switch (this.type) {
|
|
936
|
+
// https://html.spec.whatwg.org/multipage/input.html#checkbox-state-(type=checkbox)
|
|
937
|
+
// Constraint validation: If the element is required and its checkedness is
|
|
938
|
+
// false, then the element is suffering from being missing.
|
|
939
|
+
case "checkbox":
|
|
940
|
+
if (this._required && !this._checkedness) {
|
|
941
|
+
return true;
|
|
942
|
+
}
|
|
943
|
+
break;
|
|
944
|
+
|
|
945
|
+
// https://html.spec.whatwg.org/multipage/input.html#radio-button-state-(type=radio)
|
|
946
|
+
// Constraint validation: If an element in the radio button group is required,
|
|
947
|
+
// and all of the input elements in the radio button group have a checkedness
|
|
948
|
+
// that is false, then the element is suffering from being missing.
|
|
949
|
+
case "radio":
|
|
950
|
+
if (this._someInRadioGroup("_required") && !this._someInRadioGroup("checked")) {
|
|
951
|
+
return true;
|
|
952
|
+
}
|
|
953
|
+
break;
|
|
954
|
+
|
|
955
|
+
// https://html.spec.whatwg.org/multipage/input.html#file-upload-state-(type=file)
|
|
956
|
+
// Constraint validation: If the element is required and the list of selected files is
|
|
957
|
+
// empty, then the element is suffering from being missing.
|
|
958
|
+
case "file":
|
|
959
|
+
if (this._required && this.files.length === 0) {
|
|
960
|
+
return true;
|
|
961
|
+
}
|
|
962
|
+
break;
|
|
963
|
+
}
|
|
964
|
+
|
|
965
|
+
return false;
|
|
966
|
+
},
|
|
967
|
+
|
|
968
|
+
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#suffering-from-being-too-long
|
|
969
|
+
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#attr-fe-maxlength
|
|
970
|
+
// jsdom has no way at the moment to emulate a user interaction, so tooLong/tooShort have
|
|
971
|
+
// to be set to false.
|
|
972
|
+
tooLong: () => false,
|
|
973
|
+
|
|
974
|
+
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#suffering-from-being-too-short
|
|
975
|
+
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#attr-fe-minlength
|
|
976
|
+
tooShort: () => false,
|
|
977
|
+
|
|
978
|
+
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#suffering-from-an-overflow
|
|
979
|
+
rangeOverflow: () => {
|
|
980
|
+
// https://html.spec.whatwg.org/multipage/input.html#the-min-and-max-attributes
|
|
981
|
+
if (this._hasAReversedRange) {
|
|
982
|
+
return reversedRangeSufferingOverUnderflow();
|
|
983
|
+
}
|
|
984
|
+
// Constraint validation: When the element has a maximum and does not have a reversed
|
|
985
|
+
// range, and the result of applying the algorithm to convert a string to a number to the
|
|
986
|
+
// string given by the element's value is a number, and the number obtained from that
|
|
987
|
+
// algorithm is more than the maximum, the element is suffering from an overflow.
|
|
988
|
+
if (this._maximum !== null) {
|
|
989
|
+
const parsedValue = this._convertStringToNumber(this._value);
|
|
990
|
+
if (parsedValue !== null && parsedValue > this._maximum) {
|
|
991
|
+
return true;
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
return false;
|
|
995
|
+
},
|
|
996
|
+
|
|
997
|
+
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#suffering-from-an-underflow
|
|
998
|
+
rangeUnderflow: () => {
|
|
999
|
+
// https://html.spec.whatwg.org/multipage/input.html#the-min-and-max-attributes
|
|
1000
|
+
if (this._hasAReversedRange) {
|
|
1001
|
+
return reversedRangeSufferingOverUnderflow();
|
|
1002
|
+
}
|
|
1003
|
+
// Constraint validation: When the element has a minimum and does not have a reversed
|
|
1004
|
+
// range, and the result of applying the algorithm to convert a string to a number to the
|
|
1005
|
+
// string given by the element's value is a number, and the number obtained from that
|
|
1006
|
+
// algorithm is less than the minimum, the element is suffering from an underflow.
|
|
1007
|
+
if (this._minimum !== null) {
|
|
1008
|
+
const parsedValue = this._convertStringToNumber(this._value);
|
|
1009
|
+
if (parsedValue !== null && parsedValue < this._minimum) {
|
|
1010
|
+
return true;
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
return false;
|
|
1014
|
+
},
|
|
1015
|
+
|
|
1016
|
+
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#suffering-from-a-pattern-mismatch
|
|
1017
|
+
patternMismatch: () => {
|
|
1018
|
+
// https://html.spec.whatwg.org/multipage/input.html#the-pattern-attribute
|
|
1019
|
+
if (this._value === "" || !this._hasAttributeAndApplies("pattern")) {
|
|
1020
|
+
return false;
|
|
1021
|
+
}
|
|
1022
|
+
let regExp;
|
|
1023
|
+
try {
|
|
1024
|
+
const pattern = this.getAttributeNS(null, "pattern");
|
|
1025
|
+
// The pattern attribute should be matched against the entire value, not just any
|
|
1026
|
+
// subset, so add ^ and $ anchors. But also check the validity of the regex itself
|
|
1027
|
+
// first.
|
|
1028
|
+
new RegExp(pattern, "v"); // eslint-disable-line no-new
|
|
1029
|
+
regExp = new RegExp("^(?:" + pattern + ")$", "v");
|
|
1030
|
+
} catch {
|
|
1031
|
+
return false;
|
|
1032
|
+
}
|
|
1033
|
+
if (this._hasAttributeAndApplies("multiple")) {
|
|
1034
|
+
return !splitOnCommas(this._value).every(value => regExp.test(value));
|
|
1035
|
+
}
|
|
1036
|
+
return !regExp.test(this._value);
|
|
1037
|
+
},
|
|
1038
|
+
|
|
1039
|
+
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#suffering-from-a-step-mismatch
|
|
1040
|
+
// https://html.spec.whatwg.org/multipage/input.html#attr-input-step
|
|
1041
|
+
stepMismatch: () => {
|
|
1042
|
+
const allowedValueStep = this._allowedValueStep;
|
|
1043
|
+
if (allowedValueStep === null) {
|
|
1044
|
+
return false;
|
|
1045
|
+
}
|
|
1046
|
+
const number = this._convertStringToNumber(this._value);
|
|
1047
|
+
return number !== null && !this._isStepAligned(number);
|
|
1048
|
+
},
|
|
1049
|
+
|
|
1050
|
+
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#suffering-from-a-type-mismatch
|
|
1051
|
+
typeMismatch: () => {
|
|
1052
|
+
switch (this.type) {
|
|
1053
|
+
// https://html.spec.whatwg.org/multipage/input.html#url-state-(type=url)
|
|
1054
|
+
// Constraint validation: While the value of the element is neither the empty string
|
|
1055
|
+
// nor a valid absolute URL, the element is suffering from a type mismatch.
|
|
1056
|
+
case "url":
|
|
1057
|
+
if (this._value !== "" && !isValidAbsoluteURL(this._value)) {
|
|
1058
|
+
return true;
|
|
1059
|
+
}
|
|
1060
|
+
break;
|
|
1061
|
+
|
|
1062
|
+
// https://html.spec.whatwg.org/multipage/input.html#e-mail-state-(type=email)
|
|
1063
|
+
// Constraint validation [multiple=false]: While the value of the element is neither the empty
|
|
1064
|
+
// string nor a single valid e - mail address, the element is suffering from a type mismatch.
|
|
1065
|
+
// Constraint validation [multiple=true]: While the value of the element is not a valid e-mail address list,
|
|
1066
|
+
// the element is suffering from a type mismatch.
|
|
1067
|
+
case "email":
|
|
1068
|
+
if (this._value !== "" && !isValidEmailAddress(this._getValue(), this.hasAttributeNS(null, "multiple"))) {
|
|
1069
|
+
return true;
|
|
1070
|
+
}
|
|
1071
|
+
break;
|
|
1072
|
+
}
|
|
1073
|
+
return false;
|
|
1074
|
+
}
|
|
1075
|
+
};
|
|
1076
|
+
|
|
1077
|
+
this._validity = ValidityState.createImpl(this._globalObject, [], {
|
|
1078
|
+
element: this,
|
|
1079
|
+
state
|
|
1080
|
+
});
|
|
1081
|
+
}
|
|
1082
|
+
return this._validity;
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1085
|
+
[cloningSteps](copy, node) {
|
|
1086
|
+
copy._value = node._value;
|
|
1087
|
+
copy._checkedness = node._checkedness;
|
|
1088
|
+
copy._dirtyValue = node._dirtyValue;
|
|
1089
|
+
copy._dirtyCheckedness = node._dirtyCheckedness;
|
|
1090
|
+
}
|
|
1091
|
+
}
|
|
1092
|
+
|
|
1093
|
+
mixin(HTMLInputElementImpl.prototype, DefaultConstraintValidationImpl.prototype);
|
|
1094
|
+
|
|
1095
|
+
module.exports = {
|
|
1096
|
+
implementation: HTMLInputElementImpl
|
|
1097
|
+
};
|