├── .editorconfig ├── .eslintignore ├── .eslintrc.cjs ├── .github ├── CODEOWNERS ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── bug_report.md │ ├── custom.md │ └── feature_request.md └── workflows │ ├── auto-assign.yml │ ├── pull_request.yml │ └── release.yml ├── .gitignore ├── .husky ├── .gitignore ├── commit-msg └── pre-commit ├── .npmrc ├── .prettierignore ├── .prettierrc.cjs ├── .vscode └── extensions.json ├── CODE_OF_CONDUCT.md ├── LICENSE ├── README.md ├── SECURITY.md ├── cspell.json ├── docs ├── contributing.md ├── happy-dom-logo.jpg └── happy-dom-logo.jpg~ ├── package-lock.json ├── package.json ├── packages ├── global-registrator │ ├── .editorconfig │ ├── .gitignore │ ├── .npmignore │ ├── .prettierrc.cjs │ ├── LICENSE │ ├── README.md │ ├── package.json │ ├── src │ │ ├── GlobalRegistrator.ts │ │ └── index.ts │ ├── test │ │ ├── bun │ │ │ └── Bun.test.js │ │ └── react │ │ │ ├── React.test.tsx │ │ │ ├── ReactComponent.tsx │ │ │ └── tsconfig.json │ └── tsconfig.json ├── happy-dom │ ├── .editorconfig │ ├── .gitignore │ ├── .npmignore │ ├── .prettierrc.cjs │ ├── LICENSE │ ├── README.md │ ├── bin │ │ ├── build-version-file.cjs │ │ └── change-file-extension.cjs │ ├── package.json │ ├── src │ │ ├── PropertySymbol.ts │ │ ├── async-task-manager │ │ │ └── AsyncTaskManager.ts │ │ ├── base64 │ │ │ └── Base64.ts │ │ ├── browser │ │ │ ├── Browser.ts │ │ │ ├── BrowserContext.ts │ │ │ ├── BrowserFrame.ts │ │ │ ├── BrowserPage.ts │ │ │ ├── BrowserSettingsFactory.ts │ │ │ ├── DefaultBrowserPageViewport.ts │ │ │ ├── DefaultBrowserSettings.ts │ │ │ ├── detached-browser │ │ │ │ ├── DetachedBrowser.ts │ │ │ │ ├── DetachedBrowserContext.ts │ │ │ │ ├── DetachedBrowserFrame.ts │ │ │ │ └── DetachedBrowserPage.ts │ │ │ ├── enums │ │ │ │ ├── BrowserErrorCaptureEnum.ts │ │ │ │ └── BrowserNavigationCrossOriginPolicyEnum.ts │ │ │ ├── types │ │ │ │ ├── IBrowser.ts │ │ │ │ ├── IBrowserContext.ts │ │ │ │ ├── IBrowserFrame.ts │ │ │ │ ├── IBrowserPage.ts │ │ │ │ ├── IBrowserPageViewport.ts │ │ │ │ ├── IBrowserSettings.ts │ │ │ │ ├── IGoToOptions.ts │ │ │ │ ├── IOptionalBrowserPageViewport.ts │ │ │ │ ├── IOptionalBrowserSettings.ts │ │ │ │ └── IReloadOptions.ts │ │ │ └── utilities │ │ │ │ ├── BrowserExceptionObserver.ts │ │ │ │ ├── BrowserFrameFactory.ts │ │ │ │ ├── BrowserFrameNavigator.ts │ │ │ │ ├── BrowserFrameScriptEvaluator.ts │ │ │ │ ├── BrowserFrameURL.ts │ │ │ │ ├── BrowserFrameValidator.ts │ │ │ │ └── BrowserPageUtility.ts │ │ ├── clipboard │ │ │ ├── Clipboard.ts │ │ │ └── ClipboardItem.ts │ │ ├── config │ │ │ ├── HTMLElementConfig.ts │ │ │ ├── HTMLElementConfigContentModelEnum.ts │ │ │ ├── IHTMLElementTagNameMap.ts │ │ │ ├── ISVGElementTagNameMap.ts │ │ │ ├── NamespaceURI.ts │ │ │ └── SVGElementConfig.ts │ │ ├── console │ │ │ ├── IVirtualConsoleLogEntry.ts │ │ │ ├── IVirtualConsoleLogGroup.ts │ │ │ ├── IVirtualConsolePrinter.ts │ │ │ ├── VirtualConsole.ts │ │ │ ├── VirtualConsolePrinter.ts │ │ │ ├── enums │ │ │ │ ├── VirtualConsoleLogLevelEnum.ts │ │ │ │ └── VirtualConsoleLogTypeEnum.ts │ │ │ └── utilities │ │ │ │ └── VirtualConsoleLogEntryStringifier.ts │ │ ├── cookie │ │ │ ├── CookieContainer.ts │ │ │ ├── DefaultCookie.ts │ │ │ ├── ICookie.ts │ │ │ ├── ICookieContainer.ts │ │ │ ├── IOptionalCookie.ts │ │ │ ├── enums │ │ │ │ └── CookieSameSiteEnum.ts │ │ │ └── urilities │ │ │ │ ├── CookieExpireUtility.ts │ │ │ │ ├── CookieStringUtility.ts │ │ │ │ └── CookieURLUtility.ts │ │ ├── css │ │ │ ├── CSS.ts │ │ │ ├── CSSRule.ts │ │ │ ├── CSSRuleTypeEnum.ts │ │ │ ├── CSSStyleSheet.ts │ │ │ ├── CSSUnitValue.ts │ │ │ ├── CSSUnits.ts │ │ │ ├── MediaList.ts │ │ │ ├── declaration │ │ │ │ ├── CSSStyleDeclaration.ts │ │ │ │ ├── computed-style │ │ │ │ │ ├── CSSStyleDeclarationComputedStyle.ts │ │ │ │ │ └── config │ │ │ │ │ │ ├── CSSStyleDeclarationElementDefaultCSS.ts │ │ │ │ │ │ ├── CSSStyleDeclarationElementInheritedProperties.ts │ │ │ │ │ │ └── CSSStyleDeclarationElementMeasurementProperties.ts │ │ │ │ ├── css-parser │ │ │ │ │ └── CSSStyleDeclarationCSSParser.ts │ │ │ │ ├── measurement-converter │ │ │ │ │ └── CSSMeasurementConverter.ts │ │ │ │ └── property-manager │ │ │ │ │ ├── CSSStyleDeclarationPropertyGetParser.ts │ │ │ │ │ ├── CSSStyleDeclarationPropertyManager.ts │ │ │ │ │ ├── CSSStyleDeclarationPropertySetParser.ts │ │ │ │ │ ├── CSSStyleDeclarationValueParser.ts │ │ │ │ │ └── ICSSStyleDeclarationPropertyValue.ts │ │ │ ├── rules │ │ │ │ ├── CSSContainerRule.ts │ │ │ │ ├── CSSFontFaceRule.ts │ │ │ │ ├── CSSKeyframeRule.ts │ │ │ │ ├── CSSKeyframesRule.ts │ │ │ │ ├── CSSMediaRule.ts │ │ │ │ ├── CSSStyleRule.ts │ │ │ │ └── CSSSupportsRule.ts │ │ │ └── utilities │ │ │ │ ├── CSSEscaper.ts │ │ │ │ └── CSSParser.ts │ │ ├── custom-element │ │ │ ├── CustomElementReactionStack.ts │ │ │ ├── CustomElementRegistry.ts │ │ │ ├── CustomElementUtility.ts │ │ │ └── ICustomElementDefinition.ts │ │ ├── dom-implementation │ │ │ └── DOMImplementation.ts │ │ ├── dom-parser │ │ │ └── DOMParser.ts │ │ ├── dom │ │ │ ├── DOMPoint.ts │ │ │ ├── DOMPointReadOnly.ts │ │ │ ├── DOMRect.ts │ │ │ ├── DOMRectList.ts │ │ │ ├── DOMRectReadOnly.ts │ │ │ ├── DOMStringMap.ts │ │ │ ├── DOMStringMapUtility.ts │ │ │ ├── DOMTokenList.ts │ │ │ ├── IDOMPointInit.ts │ │ │ ├── IDOMRectInit.ts │ │ │ └── dom-matrix │ │ │ │ ├── DOMMatrix.ts │ │ │ │ ├── DOMMatrixReadOnly.ts │ │ │ │ ├── IDOMMatrixCompatibleObject.ts │ │ │ │ ├── IDOMMatrixJSON.ts │ │ │ │ ├── TDOMMatrix2DArray.ts │ │ │ │ ├── TDOMMatrix3DArray.ts │ │ │ │ └── TDOMMatrixInit.ts │ │ ├── event │ │ │ ├── DataTransfer.ts │ │ │ ├── DataTransferItem.ts │ │ │ ├── DataTransferItemList.ts │ │ │ ├── Event.ts │ │ │ ├── EventPhaseEnum.ts │ │ │ ├── EventTarget.ts │ │ │ ├── IEventInit.ts │ │ │ ├── IEventListenerOptions.ts │ │ │ ├── ITouchInit.ts │ │ │ ├── IUIEventInit.ts │ │ │ ├── MessagePort.ts │ │ │ ├── TEventListener.ts │ │ │ ├── TEventListenerFunction.ts │ │ │ ├── TEventListenerObject.ts │ │ │ ├── Touch.ts │ │ │ ├── UIEvent.ts │ │ │ └── events │ │ │ │ ├── AnimationEvent.ts │ │ │ │ ├── ClipboardEvent.ts │ │ │ │ ├── CustomEvent.ts │ │ │ │ ├── ErrorEvent.ts │ │ │ │ ├── FocusEvent.ts │ │ │ │ ├── HashChangeEvent.ts │ │ │ │ ├── IAnimationEventInit.ts │ │ │ │ ├── IClipboardEventInit.ts │ │ │ │ ├── ICustomEventInit.ts │ │ │ │ ├── IErrorEventInit.ts │ │ │ │ ├── IFocusEventInit.ts │ │ │ │ ├── IHashChangeEventInit.ts │ │ │ │ ├── IInputEventInit.ts │ │ │ │ ├── IKeyboardEventInit.ts │ │ │ │ ├── IMediaQueryListEventInit.ts │ │ │ │ ├── IMediaQueryListInit.ts │ │ │ │ ├── IMessageEventInit.ts │ │ │ │ ├── IMouseEventInit.ts │ │ │ │ ├── IPointerEventInit.ts │ │ │ │ ├── IProgressEventInit.ts │ │ │ │ ├── IStorageEventInit.ts │ │ │ │ ├── ISubmitEventInit.ts │ │ │ │ ├── ITouchEventInit.ts │ │ │ │ ├── IWheelEventInit.ts │ │ │ │ ├── InputEvent.ts │ │ │ │ ├── KeyboardEvent.ts │ │ │ │ ├── MediaQueryListEvent.ts │ │ │ │ ├── MediaStreamTrackEvent.ts │ │ │ │ ├── MessageEvent.ts │ │ │ │ ├── MouseEvent.ts │ │ │ │ ├── PointerEvent.ts │ │ │ │ ├── ProgressEvent.ts │ │ │ │ ├── StorageEvent.ts │ │ │ │ ├── SubmitEvent.ts │ │ │ │ ├── TouchEvent.ts │ │ │ │ └── WheelEvent.ts │ │ ├── exception │ │ │ ├── DOMException.ts │ │ │ └── DOMExceptionNameEnum.ts │ │ ├── fetch │ │ │ ├── AbortController.ts │ │ │ ├── AbortSignal.ts │ │ │ ├── Fetch.ts │ │ │ ├── Headers.ts │ │ │ ├── Request.ts │ │ │ ├── ResourceFetch.ts │ │ │ ├── Response.ts │ │ │ ├── SyncFetch.ts │ │ │ ├── cache │ │ │ │ ├── preflight │ │ │ │ │ ├── ICachablePreflightRequest.ts │ │ │ │ │ ├── ICachablePreflightResponse.ts │ │ │ │ │ ├── ICachedPreflightResponse.ts │ │ │ │ │ ├── IPreflightResponseCache.ts │ │ │ │ │ └── PreflightResponseCache.ts │ │ │ │ └── response │ │ │ │ │ ├── CachedResponseStateEnum.ts │ │ │ │ │ ├── ICachableRequest.ts │ │ │ │ │ ├── ICachableResponse.ts │ │ │ │ │ ├── ICachedResponse.ts │ │ │ │ │ ├── IResponseCache.ts │ │ │ │ │ └── ResponseCache.ts │ │ │ ├── certificate │ │ │ │ └── FetchHTTPSCertificate.ts │ │ │ ├── data-uri │ │ │ │ └── DataURIParser.ts │ │ │ ├── multipart │ │ │ │ ├── MultipartFormDataParser.ts │ │ │ │ └── MultipartReader.ts │ │ │ ├── preload │ │ │ │ ├── PreloadEntry.ts │ │ │ │ └── PreloadUtility.ts │ │ │ ├── types │ │ │ │ ├── IFetchInterceptor.ts │ │ │ │ ├── IHeadersInit.ts │ │ │ │ ├── IRequestBody.ts │ │ │ │ ├── IRequestCredentials.ts │ │ │ │ ├── IRequestInfo.ts │ │ │ │ ├── IRequestInit.ts │ │ │ │ ├── IRequestMode.ts │ │ │ │ ├── IRequestRedirect.ts │ │ │ │ ├── IRequestReferrerPolicy.ts │ │ │ │ ├── IResponseBody.ts │ │ │ │ ├── IResponseInit.ts │ │ │ │ ├── ISyncResponse.ts │ │ │ │ └── IVirtualServer.ts │ │ │ └── utilities │ │ │ │ ├── FetchBodyUtility.ts │ │ │ │ ├── FetchCORSUtility.ts │ │ │ │ ├── FetchRequestHeaderUtility.ts │ │ │ │ ├── FetchRequestReferrerUtility.ts │ │ │ │ ├── FetchRequestValidationUtility.ts │ │ │ │ ├── FetchResponseHeaderUtility.ts │ │ │ │ ├── FetchResponseRedirectUtility.ts │ │ │ │ ├── SyncFetchScriptBuilder.ts │ │ │ │ └── VirtualServerUtility.ts │ │ ├── file │ │ │ ├── Blob.ts │ │ │ ├── File.ts │ │ │ ├── FileReader.ts │ │ │ ├── FileReaderEventTypeEnum.ts │ │ │ ├── FileReaderFormatEnum.ts │ │ │ └── FileReaderReadyStateEnum.ts │ │ ├── form-data │ │ │ └── FormData.ts │ │ ├── history │ │ │ ├── History.ts │ │ │ ├── HistoryScrollRestorationEnum.ts │ │ │ └── IHistoryItem.ts │ │ ├── html-parser │ │ │ └── HTMLParser.ts │ │ ├── html-serializer │ │ │ └── HTMLSerializer.ts │ │ ├── index.ts │ │ ├── intersection-observer │ │ │ ├── IIntersectionObserverInit.ts │ │ │ ├── IntersectionObserver.ts │ │ │ └── IntersectionObserverEntry.ts │ │ ├── location │ │ │ └── Location.ts │ │ ├── match-media │ │ │ ├── IMediaQueryRange.ts │ │ │ ├── IMediaQueryRule.ts │ │ │ ├── MediaQueryItem.ts │ │ │ ├── MediaQueryList.ts │ │ │ ├── MediaQueryParser.ts │ │ │ └── MediaQueryTypeEnum.ts │ │ ├── module │ │ │ ├── CSSModule.ts │ │ │ ├── ECMAScriptModule.ts │ │ │ ├── ECMAScriptModuleCompiler.ts │ │ │ ├── IECMAScriptModuleCompiledResult.ts │ │ │ ├── IECMAScriptModuleImport.ts │ │ │ ├── IModule.ts │ │ │ ├── IModuleImportMap.ts │ │ │ ├── IModuleImportMapRule.ts │ │ │ ├── IModuleImportMapScope.ts │ │ │ ├── JSONModule.ts │ │ │ ├── ModuleFactory.ts │ │ │ ├── ModuleURLUtility.ts │ │ │ └── UnresolvedModule.ts │ │ ├── mutation-observer │ │ │ ├── IMutationListener.ts │ │ │ ├── IMutationObserverInit.ts │ │ │ ├── MutationObserver.ts │ │ │ ├── MutationObserverListener.ts │ │ │ ├── MutationRecord.ts │ │ │ └── MutationTypeEnum.ts │ │ ├── navigator │ │ │ ├── MimeType.ts │ │ │ ├── MimeTypeArray.ts │ │ │ ├── Navigator.ts │ │ │ ├── Plugin.ts │ │ │ └── PluginArray.ts │ │ ├── nodes │ │ │ ├── NodeFactory.ts │ │ │ ├── attr │ │ │ │ └── Attr.ts │ │ │ ├── character-data │ │ │ │ ├── CharacterData.ts │ │ │ │ └── CharacterDataUtility.ts │ │ │ ├── child-node │ │ │ │ ├── ChildNodeUtility.ts │ │ │ │ ├── IChildNode.ts │ │ │ │ ├── INonDocumentTypeChildNode.ts │ │ │ │ └── NonDocumentChildNodeUtility.ts │ │ │ ├── comment │ │ │ │ └── Comment.ts │ │ │ ├── document-fragment │ │ │ │ └── DocumentFragment.ts │ │ │ ├── document-type │ │ │ │ └── DocumentType.ts │ │ │ ├── document │ │ │ │ ├── Document.ts │ │ │ │ ├── DocumentReadyStateEnum.ts │ │ │ │ ├── DocumentReadyStateManager.ts │ │ │ │ └── VisibilityStateEnum.ts │ │ │ ├── element │ │ │ │ ├── Element.ts │ │ │ │ ├── ElementEventAttributeUtility.ts │ │ │ │ ├── HTMLCollection.ts │ │ │ │ ├── NamedNodeMap.ts │ │ │ │ ├── NamedNodeMapProxyFactory.ts │ │ │ │ ├── THTMLCollectionListener.ts │ │ │ │ └── TNamedNodeMapListener.ts │ │ │ ├── html-anchor-element │ │ │ │ └── HTMLAnchorElement.ts │ │ │ ├── html-area-element │ │ │ │ └── HTMLAreaElement.ts │ │ │ ├── html-audio-element │ │ │ │ ├── Audio.ts │ │ │ │ └── HTMLAudioElement.ts │ │ │ ├── html-base-element │ │ │ │ └── HTMLBaseElement.ts │ │ │ ├── html-body-element │ │ │ │ └── HTMLBodyElement.ts │ │ │ ├── html-br-element │ │ │ │ └── HTMLBRElement.ts │ │ │ ├── html-button-element │ │ │ │ └── HTMLButtonElement.ts │ │ │ ├── html-canvas-element │ │ │ │ ├── CanvasCaptureMediaStreamTrack.ts │ │ │ │ ├── HTMLCanvasElement.ts │ │ │ │ ├── ImageBitmap.ts │ │ │ │ └── OffscreenCanvas.ts │ │ │ ├── html-d-list-element │ │ │ │ └── HTMLDListElement.ts │ │ │ ├── html-data-element │ │ │ │ └── HTMLDataElement.ts │ │ │ ├── html-data-list-element │ │ │ │ └── HTMLDataListElement.ts │ │ │ ├── html-details-element │ │ │ │ └── HTMLDetailsElement.ts │ │ │ ├── html-dialog-element │ │ │ │ └── HTMLDialogElement.ts │ │ │ ├── html-div-element │ │ │ │ └── HTMLDivElement.ts │ │ │ ├── html-document │ │ │ │ └── HTMLDocument.ts │ │ │ ├── html-element │ │ │ │ ├── HTMLElement.ts │ │ │ │ └── HTMLElementUtility.ts │ │ │ ├── html-embed-element │ │ │ │ └── HTMLEmbedElement.ts │ │ │ ├── html-field-set-element │ │ │ │ └── HTMLFieldSetElement.ts │ │ │ ├── html-form-element │ │ │ │ ├── HTMLFormControlsCollection.ts │ │ │ │ ├── HTMLFormElement.ts │ │ │ │ ├── RadioNodeList.ts │ │ │ │ └── THTMLFormControlElement.ts │ │ │ ├── html-head-element │ │ │ │ └── HTMLHeadElement.ts │ │ │ ├── html-heading-element │ │ │ │ └── HTMLHeadingElement.ts │ │ │ ├── html-hr-element │ │ │ │ └── HTMLHRElement.ts │ │ │ ├── html-html-element │ │ │ │ └── HTMLHtmlElement.ts │ │ │ ├── html-hyperlink-element │ │ │ │ ├── HTMLHyperlinkElementUtility.ts │ │ │ │ └── IHTMLHyperlinkElement.ts │ │ │ ├── html-iframe-element │ │ │ │ └── HTMLIFrameElement.ts │ │ │ ├── html-image-element │ │ │ │ ├── HTMLImageElement.ts │ │ │ │ └── Image.ts │ │ │ ├── html-input-element │ │ │ │ ├── FileList.ts │ │ │ │ ├── HTMLInputElement.ts │ │ │ │ ├── HTMLInputElementDateUtility.ts │ │ │ │ ├── HTMLInputElementSelectionDirectionEnum.ts │ │ │ │ ├── HTMLInputElementSelectionModeEnum.ts │ │ │ │ ├── HTMLInputElementValueSanitizer.ts │ │ │ │ └── HTMLInputElementValueStepping.ts │ │ │ ├── html-label-element │ │ │ │ ├── HTMLLabelElement.ts │ │ │ │ └── HTMLLabelElementUtility.ts │ │ │ ├── html-legend-element │ │ │ │ └── HTMLLegendElement.ts │ │ │ ├── html-li-element │ │ │ │ └── HTMLLIElement.ts │ │ │ ├── html-link-element │ │ │ │ └── HTMLLinkElement.ts │ │ │ ├── html-map-element │ │ │ │ └── HTMLMapElement.ts │ │ │ ├── html-media-element │ │ │ │ ├── HTMLMediaElement.ts │ │ │ │ ├── IMediaTrackCapabilities.ts │ │ │ │ ├── IMediaTrackSettings.ts │ │ │ │ ├── MediaStream.ts │ │ │ │ ├── MediaStreamTrack.ts │ │ │ │ ├── RemotePlayback.ts │ │ │ │ ├── TextTrack.ts │ │ │ │ ├── TextTrackCue.ts │ │ │ │ ├── TextTrackCueList.ts │ │ │ │ ├── TextTrackKindEnum.ts │ │ │ │ ├── TextTrackList.ts │ │ │ │ ├── TimeRanges.ts │ │ │ │ ├── VTTCue.ts │ │ │ │ └── VTTRegion.ts │ │ │ ├── html-menu-element │ │ │ │ └── HTMLMenuElement.ts │ │ │ ├── html-meta-element │ │ │ │ └── HTMLMetaElement.ts │ │ │ ├── html-meter-element │ │ │ │ └── HTMLMeterElement.ts │ │ │ ├── html-mod-element │ │ │ │ └── HTMLModElement.ts │ │ │ ├── html-o-list-element │ │ │ │ └── HTMLOListElement.ts │ │ │ ├── html-object-element │ │ │ │ └── HTMLObjectElement.ts │ │ │ ├── html-opt-group-element │ │ │ │ └── HTMLOptGroupElement.ts │ │ │ ├── html-option-element │ │ │ │ └── HTMLOptionElement.ts │ │ │ ├── html-output-element │ │ │ │ └── HTMLOutputElement.ts │ │ │ ├── html-paragraph-element │ │ │ │ └── HTMLParagraphElement.ts │ │ │ ├── html-param-element │ │ │ │ └── HTMLParamElement.ts │ │ │ ├── html-picture-element │ │ │ │ └── HTMLPictureElement.ts │ │ │ ├── html-pre-element │ │ │ │ └── HTMLPreElement.ts │ │ │ ├── html-progress-element │ │ │ │ └── HTMLProgressElement.ts │ │ │ ├── html-quote-element │ │ │ │ └── HTMLQuoteElement.ts │ │ │ ├── html-script-element │ │ │ │ └── HTMLScriptElement.ts │ │ │ ├── html-select-element │ │ │ │ ├── HTMLOptionsCollection.ts │ │ │ │ └── HTMLSelectElement.ts │ │ │ ├── html-slot-element │ │ │ │ └── HTMLSlotElement.ts │ │ │ ├── html-source-element │ │ │ │ └── HTMLSourceElement.ts │ │ │ ├── html-span-element │ │ │ │ └── HTMLSpanElement.ts │ │ │ ├── html-style-element │ │ │ │ └── HTMLStyleElement.ts │ │ │ ├── html-table-caption-element │ │ │ │ └── HTMLTableCaptionElement.ts │ │ │ ├── html-table-cell-element │ │ │ │ └── HTMLTableCellElement.ts │ │ │ ├── html-table-col-element │ │ │ │ └── HTMLTableColElement.ts │ │ │ ├── html-table-element │ │ │ │ └── HTMLTableElement.ts │ │ │ ├── html-table-row-element │ │ │ │ └── HTMLTableRowElement.ts │ │ │ ├── html-table-section-element │ │ │ │ └── HTMLTableSectionElement.ts │ │ │ ├── html-template-element │ │ │ │ └── HTMLTemplateElement.ts │ │ │ ├── html-text-area-element │ │ │ │ └── HTMLTextAreaElement.ts │ │ │ ├── html-time-element │ │ │ │ └── HTMLTimeElement.ts │ │ │ ├── html-title-element │ │ │ │ └── HTMLTitleElement.ts │ │ │ ├── html-track-element │ │ │ │ └── HTMLTrackElement.ts │ │ │ ├── html-u-list-element │ │ │ │ └── HTMLUListElement.ts │ │ │ ├── html-unknown-element │ │ │ │ └── HTMLUnknownElement.ts │ │ │ ├── html-video-element │ │ │ │ └── HTMLVideoElement.ts │ │ │ ├── node │ │ │ │ ├── ICachedComputedStyleResult.ts │ │ │ │ ├── ICachedElementByIdResult.ts │ │ │ │ ├── ICachedElementByTagNameResult.ts │ │ │ │ ├── ICachedElementsByTagNameResult.ts │ │ │ │ ├── ICachedMatchesResult.ts │ │ │ │ ├── ICachedQuerySelectorAllResult.ts │ │ │ │ ├── ICachedQuerySelectorResult.ts │ │ │ │ ├── ICachedResult.ts │ │ │ │ ├── ICachedStyleResult.ts │ │ │ │ ├── Node.ts │ │ │ │ ├── NodeDocumentPositionEnum.ts │ │ │ │ ├── NodeList.ts │ │ │ │ ├── NodeTypeEnum.ts │ │ │ │ ├── NodeUtility.ts │ │ │ │ └── TNodeListListener.ts │ │ │ ├── parent-node │ │ │ │ ├── IParentNode.ts │ │ │ │ └── ParentNodeUtility.ts │ │ │ ├── processing-instruction │ │ │ │ └── ProcessingInstruction.ts │ │ │ ├── shadow-root │ │ │ │ └── ShadowRoot.ts │ │ │ ├── svg-animate-element │ │ │ │ └── SVGAnimateElement.ts │ │ │ ├── svg-animate-motion-element │ │ │ │ └── SVGAnimateMotionElement.ts │ │ │ ├── svg-animate-transform-element │ │ │ │ └── SVGAnimateTransformElement.ts │ │ │ ├── svg-animation-element │ │ │ │ └── SVGAnimationElement.ts │ │ │ ├── svg-circle-element │ │ │ │ └── SVGCircleElement.ts │ │ │ ├── svg-clip-path-element │ │ │ │ └── SVGClipPathElement.ts │ │ │ ├── svg-component-transfer-function-element │ │ │ │ └── SVGComponentTransferFunctionElement.ts │ │ │ ├── svg-defs-element │ │ │ │ └── SVGDefsElement.ts │ │ │ ├── svg-desc-element │ │ │ │ └── SVGDescElement.ts │ │ │ ├── svg-element │ │ │ │ └── SVGElement.ts │ │ │ ├── svg-ellipse-element │ │ │ │ └── SVGEllipseElement.ts │ │ │ ├── svg-fe-blend-element │ │ │ │ └── SVGFEBlendElement.ts │ │ │ ├── svg-fe-color-matrix-element │ │ │ │ └── SVGFEColorMatrixElement.ts │ │ │ ├── svg-fe-component-transfer-element │ │ │ │ └── SVGFEComponentTransferElement.ts │ │ │ ├── svg-fe-composite-element │ │ │ │ └── SVGFECompositeElement.ts │ │ │ ├── svg-fe-convolve-matrix-element │ │ │ │ └── SVGFEConvolveMatrixElement.ts │ │ │ ├── svg-fe-diffuse-lighting-element │ │ │ │ └── SVGFEDiffuseLightingElement.ts │ │ │ ├── svg-fe-displacement-map-element │ │ │ │ └── SVGFEDisplacementMapElement.ts │ │ │ ├── svg-fe-distant-light-element │ │ │ │ └── SVGFEDistantLightElement.ts │ │ │ ├── svg-fe-drop-shadow-element │ │ │ │ └── SVGFEDropShadowElement.ts │ │ │ ├── svg-fe-flood-element │ │ │ │ └── SVGFEFloodElement.ts │ │ │ ├── svg-fe-func-a-element │ │ │ │ └── SVGFEFuncAElement.ts │ │ │ ├── svg-fe-func-b-element │ │ │ │ └── SVGFEFuncBElement.ts │ │ │ ├── svg-fe-func-g-element │ │ │ │ └── SVGFEFuncGElement.ts │ │ │ ├── svg-fe-func-r-element │ │ │ │ └── SVGFEFuncRElement.ts │ │ │ ├── svg-fe-gaussian-blur-element │ │ │ │ └── SVGFEGaussianBlurElement.ts │ │ │ ├── svg-fe-image-element │ │ │ │ └── SVGFEImageElement.ts │ │ │ ├── svg-fe-merge-element │ │ │ │ └── SVGFEMergeElement.ts │ │ │ ├── svg-fe-merge-node-element │ │ │ │ └── SVGFEMergeNodeElement.ts │ │ │ ├── svg-fe-morphology-element │ │ │ │ └── SVGFEMorphologyElement.ts │ │ │ ├── svg-fe-offset-element │ │ │ │ └── SVGFEOffsetElement.ts │ │ │ ├── svg-fe-point-light-element │ │ │ │ └── SVGFEPointLightElement.ts │ │ │ ├── svg-fe-specular-lighting-element │ │ │ │ └── SVGFESpecularLightingElement.ts │ │ │ ├── svg-fe-spot-light-element │ │ │ │ └── SVGFESpotLightElement.ts │ │ │ ├── svg-fe-tile-element │ │ │ │ └── SVGFETileElement.ts │ │ │ ├── svg-fe-turbulence-element │ │ │ │ └── SVGFETurbulenceElement.ts │ │ │ ├── svg-filter-element │ │ │ │ └── SVGFilterElement.ts │ │ │ ├── svg-foreign-object-element │ │ │ │ └── SVGForeignObjectElement.ts │ │ │ ├── svg-g-element │ │ │ │ └── SVGGElement.ts │ │ │ ├── svg-geometry-element │ │ │ │ └── SVGGeometryElement.ts │ │ │ ├── svg-gradient-element │ │ │ │ └── SVGGradientElement.ts │ │ │ ├── svg-graphics-element │ │ │ │ └── SVGGraphicsElement.ts │ │ │ ├── svg-image-element │ │ │ │ └── SVGImageElement.ts │ │ │ ├── svg-line-element │ │ │ │ └── SVGLineElement.ts │ │ │ ├── svg-linear-gradient-element │ │ │ │ └── SVGLinearGradientElement.ts │ │ │ ├── svg-m-path-element │ │ │ │ └── SVGMPathElement.ts │ │ │ ├── svg-marker-element │ │ │ │ └── SVGMarkerElement.ts │ │ │ ├── svg-mask-element │ │ │ │ └── SVGMaskElement.ts │ │ │ ├── svg-metadata-element │ │ │ │ └── SVGMetadataElement.ts │ │ │ ├── svg-path-element │ │ │ │ └── SVGPathElement.ts │ │ │ ├── svg-pattern-element │ │ │ │ └── SVGPatternElement.ts │ │ │ ├── svg-polygon-element │ │ │ │ └── SVGPolygonElement.ts │ │ │ ├── svg-polyline-element │ │ │ │ └── SVGPolylineElement.ts │ │ │ ├── svg-radial-gradient-element │ │ │ │ └── SVGRadialGradientElement.ts │ │ │ ├── svg-rect-element │ │ │ │ └── SVGRectElement.ts │ │ │ ├── svg-script-element │ │ │ │ └── SVGScriptElement.ts │ │ │ ├── svg-set-element │ │ │ │ └── SVGSetElement.ts │ │ │ ├── svg-stop-element │ │ │ │ └── SVGStopElement.ts │ │ │ ├── svg-style-element │ │ │ │ └── SVGStyleElement.ts │ │ │ ├── svg-svg-element │ │ │ │ └── SVGSVGElement.ts │ │ │ ├── svg-switch-element │ │ │ │ └── SVGSwitchElement.ts │ │ │ ├── svg-symbol-element │ │ │ │ └── SVGSymbolElement.ts │ │ │ ├── svg-t-span-element │ │ │ │ └── SVGTSpanElement.ts │ │ │ ├── svg-text-content-element │ │ │ │ └── SVGTextContentElement.ts │ │ │ ├── svg-text-element │ │ │ │ └── SVGTextElement.ts │ │ │ ├── svg-text-path-element │ │ │ │ └── SVGTextPathElement.ts │ │ │ ├── svg-text-positioning-element │ │ │ │ └── SVGTextPositioningElement.ts │ │ │ ├── svg-title-element │ │ │ │ └── SVGTitleElement.ts │ │ │ ├── svg-use-element │ │ │ │ └── SVGUseElement.ts │ │ │ ├── svg-view-element │ │ │ │ └── SVGViewElement.ts │ │ │ ├── text │ │ │ │ └── Text.ts │ │ │ └── xml-document │ │ │ │ └── XMLDocument.ts │ │ ├── permissions │ │ │ ├── PermissionNameEnum.ts │ │ │ ├── PermissionStatus.ts │ │ │ └── Permissions.ts │ │ ├── query-selector │ │ │ ├── ISelectorAttribute.ts │ │ │ ├── ISelectorMatch.ts │ │ │ ├── ISelectorPseudo.ts │ │ │ ├── QuerySelector.ts │ │ │ ├── SelectorCombinatorEnum.ts │ │ │ ├── SelectorItem.ts │ │ │ └── SelectorParser.ts │ │ ├── range │ │ │ ├── IRangeBoundaryPoint.ts │ │ │ ├── Range.ts │ │ │ ├── RangeHowEnum.ts │ │ │ └── RangeUtility.ts │ │ ├── resize-observer │ │ │ └── ResizeObserver.ts │ │ ├── screen │ │ │ └── Screen.ts │ │ ├── selection │ │ │ ├── Selection.ts │ │ │ └── SelectionDirectionEnum.ts │ │ ├── storage │ │ │ └── Storage.ts │ │ ├── svg │ │ │ ├── SVGAngle.ts │ │ │ ├── SVGAngleTypeEnum.ts │ │ │ ├── SVGAnimatedAngle.ts │ │ │ ├── SVGAnimatedBoolean.ts │ │ │ ├── SVGAnimatedEnumeration.ts │ │ │ ├── SVGAnimatedInteger.ts │ │ │ ├── SVGAnimatedLength.ts │ │ │ ├── SVGAnimatedLengthList.ts │ │ │ ├── SVGAnimatedNumber.ts │ │ │ ├── SVGAnimatedNumberList.ts │ │ │ ├── SVGAnimatedPreserveAspectRatio.ts │ │ │ ├── SVGAnimatedRect.ts │ │ │ ├── SVGAnimatedString.ts │ │ │ ├── SVGAnimatedTransformList.ts │ │ │ ├── SVGLength.ts │ │ │ ├── SVGLengthList.ts │ │ │ ├── SVGLengthTypeEnum.ts │ │ │ ├── SVGMatrix.ts │ │ │ ├── SVGNumber.ts │ │ │ ├── SVGNumberList.ts │ │ │ ├── SVGPoint.ts │ │ │ ├── SVGPointList.ts │ │ │ ├── SVGPreserveAspectRatio.ts │ │ │ ├── SVGPreserveAspectRatioAlignEnum.ts │ │ │ ├── SVGPreserveAspectRatioMeetOrSliceEnum.ts │ │ │ ├── SVGRect.ts │ │ │ ├── SVGStringList.ts │ │ │ ├── SVGTransform.ts │ │ │ ├── SVGTransformList.ts │ │ │ ├── SVGTransformTypeEnum.ts │ │ │ └── SVGUnitTypes.ts │ │ ├── tree-walker │ │ │ ├── INodeFilter.ts │ │ │ ├── NodeFilter.ts │ │ │ ├── NodeFilterMask.ts │ │ │ ├── NodeIterator.ts │ │ │ └── TreeWalker.ts │ │ ├── url │ │ │ └── URL.ts │ │ ├── utilities │ │ │ ├── AttributeUtility.ts │ │ │ ├── ClassMethodBinder.ts │ │ │ ├── StringUtility.ts │ │ │ └── XMLEncodeUtility.ts │ │ ├── validity-state │ │ │ └── ValidityState.ts │ │ ├── version.ts │ │ ├── window │ │ │ ├── BrowserWindow.ts │ │ │ ├── CrossOriginBrowserWindow.ts │ │ │ ├── DetachedWindowAPI.ts │ │ │ ├── GlobalWindow.ts │ │ │ ├── INodeJSGlobal.ts │ │ │ ├── IScrollToOptions.ts │ │ │ ├── VMGlobalPropertyScript.ts │ │ │ ├── Window.ts │ │ │ ├── WindowBrowserContext.ts │ │ │ ├── WindowContextClassExtender.ts │ │ │ └── WindowPageOpenUtility.ts │ │ ├── xml-http-request │ │ │ ├── XMLHttpRequest.ts │ │ │ ├── XMLHttpRequestEventTarget.ts │ │ │ ├── XMLHttpRequestReadyStateEnum.ts │ │ │ ├── XMLHttpRequestResponseDataParser.ts │ │ │ ├── XMLHttpRequestUpload.ts │ │ │ └── XMLHttpResponseTypeEnum.ts │ │ ├── xml-parser │ │ │ └── XMLParser.ts │ │ └── xml-serializer │ │ │ └── XMLSerializer.ts │ ├── test │ │ ├── AdoptedStyleSheetCustomElement.ts │ │ ├── CustomElement.ts │ │ ├── browser │ │ │ ├── Browser.test.ts │ │ │ ├── BrowserContext.test.ts │ │ │ ├── BrowserFrame.test.ts │ │ │ ├── BrowserPage.test.ts │ │ │ └── detached-browser │ │ │ │ ├── DetachedBrowser.test.ts │ │ │ │ ├── DetachedBrowserContext.test.ts │ │ │ │ ├── DetachedBrowserFrame.test.ts │ │ │ │ └── DetachedBrowserPage.test.ts │ │ ├── clipboard │ │ │ └── Clipboard.test.ts │ │ ├── console │ │ │ ├── VirtualConsole.test.ts │ │ │ └── VirtualConsolePrinter.test.ts │ │ ├── cookie │ │ │ └── CookieContainer.test.ts │ │ ├── css │ │ │ ├── CSS.test.ts │ │ │ ├── CSSParser.test.ts │ │ │ ├── CSSStyleSheet.test.ts │ │ │ ├── CSSUnitValue.test.ts │ │ │ ├── data │ │ │ │ └── CSSParserInput.ts │ │ │ └── declaration │ │ │ │ ├── CSSStyleDeclaration.test.ts │ │ │ │ ├── CSSStyleDeclarationValueParser.test.ts │ │ │ │ └── computed-style │ │ │ │ └── CSSStyleDeclarationComputedStyle.test.ts │ │ ├── custom-element │ │ │ └── CustomElementRegistry.test.ts │ │ ├── dom-implementation │ │ │ └── DOMImplementation.test.ts │ │ ├── dom-parser │ │ │ ├── DOMParser.test.ts │ │ │ └── data │ │ │ │ ├── DOMParserHTML.ts │ │ │ │ └── DOMParserSVG.ts │ │ ├── dom │ │ │ ├── DOMPoint.test.ts │ │ │ ├── DOMPointReadOnly.test.ts │ │ │ ├── DOMRect.test.ts │ │ │ ├── DOMRectList.test.ts │ │ │ ├── DOMRectReadOnly.test.ts │ │ │ ├── DOMTokenList.test.ts │ │ │ └── dom-matrix │ │ │ │ ├── DOMMatrix.test.ts │ │ │ │ └── DOMMatrixReadOnly.test.ts │ │ ├── event │ │ │ ├── DataTransfer.test.ts │ │ │ ├── DataTransferItemList.test.ts │ │ │ ├── Event.test.ts │ │ │ ├── EventTarget.test.ts │ │ │ └── events │ │ │ │ ├── ClipboardEvent.test.ts │ │ │ │ ├── CustomEvent.test.ts │ │ │ │ ├── KeyboardEvent.test.ts │ │ │ │ ├── SubmitEvent.test.ts │ │ │ │ └── TouchEvent.test.ts │ │ ├── fetch │ │ │ ├── AbortController.test.ts │ │ │ ├── AbortSignal.test.ts │ │ │ ├── Fetch.test.ts │ │ │ ├── Headers.test.ts │ │ │ ├── Request.test.ts │ │ │ ├── ResourceFetch.test.ts │ │ │ ├── Response.test.ts │ │ │ ├── SyncFetch.test.ts │ │ │ ├── cache │ │ │ │ └── response │ │ │ │ │ └── ResponseCache.test.ts │ │ │ ├── data │ │ │ │ └── test-image.jpg │ │ │ └── virtual-server │ │ │ │ ├── css │ │ │ │ └── style.css │ │ │ │ ├── index.html │ │ │ │ └── js │ │ │ │ ├── async.js │ │ │ │ └── sync.js │ │ ├── file │ │ │ ├── Blob.test.ts │ │ │ ├── File.test.ts │ │ │ └── FileReader.test.ts │ │ ├── form-data │ │ │ └── FormData.test.ts │ │ ├── history │ │ │ └── History.test.ts │ │ ├── html-parser │ │ │ └── HTMLParser.test.ts │ │ ├── html-serializer │ │ │ └── HTMLSerializer.test.ts │ │ ├── index.test.ts │ │ ├── intersection-observer │ │ │ └── IntersectionObserver.test.ts │ │ ├── location │ │ │ └── Location.test.ts │ │ ├── match-media │ │ │ └── MediaQueryList.test.ts │ │ ├── module │ │ │ └── ECMAScriptModuleCompiler.test.ts │ │ ├── mutation-observer │ │ │ └── MutationObserver.test.ts │ │ ├── navigator │ │ │ └── Navigator.test.ts │ │ ├── nodes │ │ │ ├── attr │ │ │ │ └── Attr.test.ts │ │ │ ├── character-data │ │ │ │ ├── CharacterDataUtility.test.ts │ │ │ │ └── CharaterData.test.ts │ │ │ ├── child-node │ │ │ │ ├── ChildNodeUtility.test.ts │ │ │ │ └── NonDocumentChildNodeUtility.test.ts │ │ │ ├── comment │ │ │ │ └── Comment.test.ts │ │ │ ├── document-fragment │ │ │ │ └── DocumentFragment.test.ts │ │ │ ├── document │ │ │ │ └── Document.test.ts │ │ │ ├── element │ │ │ │ ├── Element.test.ts │ │ │ │ ├── HTMLCollection.test.ts │ │ │ │ └── NamedNodeMap.test.ts │ │ │ ├── html-anchor-element │ │ │ │ └── HTMLAnchorElement.test.ts │ │ │ ├── html-area-element │ │ │ │ └── HTMLAreaElement.test.ts │ │ │ ├── html-base-element │ │ │ │ └── HTMLBaseElement.test.ts │ │ │ ├── html-body-element │ │ │ │ └── HTMLBodyElement.test.ts │ │ │ ├── html-br-element │ │ │ │ └── HTMLBRElement.test.ts │ │ │ ├── html-button-element │ │ │ │ └── HTMLButtonElement.test.ts │ │ │ ├── html-canvas-element │ │ │ │ ├── CanvasCaptureMediaStreamTrack.test.ts │ │ │ │ ├── HTMLCanvasElement.test.ts │ │ │ │ ├── ImageBitmap.test.ts │ │ │ │ └── OffscreenCanvas.test.ts │ │ │ ├── html-d-list-element │ │ │ │ └── HTMLDListElement.test.ts │ │ │ ├── html-data-element │ │ │ │ └── HTMLDataElement.test.ts │ │ │ ├── html-data-list-element │ │ │ │ └── HTMLDataListElement.test.ts │ │ │ ├── html-details-element │ │ │ │ └── HTMLDetailsElement.test.ts │ │ │ ├── html-dialog-element │ │ │ │ └── HTMLDialogElement.test.ts │ │ │ ├── html-div-element │ │ │ │ └── HTMLDivElement.test.ts │ │ │ ├── html-element │ │ │ │ ├── HTMLElement.test.ts │ │ │ │ └── HTMLElementUtility.test.ts │ │ │ ├── html-embed-element │ │ │ │ └── HTMLEmbedElement.test.ts │ │ │ ├── html-field-set-element │ │ │ │ └── HTMLFieldSetElement.test.ts │ │ │ ├── html-form-element │ │ │ │ ├── HTMLFormElement.test.ts │ │ │ │ └── __snapshots__ │ │ │ │ │ └── HTMLFormElement.test.ts.snap │ │ │ ├── html-head-element │ │ │ │ └── HTMLHeadElement.test.ts │ │ │ ├── html-heading-element │ │ │ │ └── HTMLHeadingElement.test.ts │ │ │ ├── html-hr-element │ │ │ │ └── HTMLHRElement.test.ts │ │ │ ├── html-html-element │ │ │ │ └── HTMLHtmlElement.test.ts │ │ │ ├── html-iframe-element │ │ │ │ └── HTMLIFrameElement.test.ts │ │ │ ├── html-image-element │ │ │ │ ├── HTMLImageElement.test.ts │ │ │ │ └── Image.test.ts │ │ │ ├── html-input-element │ │ │ │ ├── FileList.test.ts │ │ │ │ ├── HTMLInputElement.test.ts │ │ │ │ ├── HTMLInputElementDateUtility.test.ts │ │ │ │ └── HTMLInputElementValueSanitizer.test.ts │ │ │ ├── html-label-element │ │ │ │ └── HTMLLabelElement.test.ts │ │ │ ├── html-legend-element │ │ │ │ └── HTMLLegendElement.test.ts │ │ │ ├── html-li-element │ │ │ │ └── HTMLLIElement.test.ts │ │ │ ├── html-link-element │ │ │ │ ├── HTMLLinkElement.test.ts │ │ │ │ └── preload-resources │ │ │ │ │ ├── data.json │ │ │ │ │ ├── main.js │ │ │ │ │ └── style.css │ │ │ ├── html-map-element │ │ │ │ └── HTMLMapElement.test.ts │ │ │ ├── html-media-element │ │ │ │ ├── HTMLMediaElement.test.ts │ │ │ │ ├── MediaStream.test.ts │ │ │ │ ├── MediaStreamTrack.test.ts │ │ │ │ ├── RemotePlayback.test.ts │ │ │ │ ├── TextTrack.test.ts │ │ │ │ ├── TextTrackCue.test.ts │ │ │ │ ├── TextTrackCueList.test.ts │ │ │ │ ├── TextTrackList.test.ts │ │ │ │ ├── TimeRanges.test.ts │ │ │ │ └── VTTCue.test.ts │ │ │ ├── html-menu-element │ │ │ │ └── HTMLMenuElement.test.ts │ │ │ ├── html-meta-element │ │ │ │ └── HTMLMetaElement.test.ts │ │ │ ├── html-meter-element │ │ │ │ └── HTMLMeterElement.test.ts │ │ │ ├── html-mod-element │ │ │ │ └── HTMLModElement.test.ts │ │ │ ├── html-o-list-element │ │ │ │ └── HTMLOListElement.test.ts │ │ │ ├── html-object-element │ │ │ │ └── HTMLObjectElement.test.ts │ │ │ ├── html-opt-group-element │ │ │ │ └── HTMLOptGroupElement.test.ts │ │ │ ├── html-option-element │ │ │ │ ├── HTMLOptionElement.test.ts │ │ │ │ └── HTMLOptionsCollection.test.ts │ │ │ ├── html-output-element │ │ │ │ └── HTMLOutputElement.test.ts │ │ │ ├── html-paragraph-element │ │ │ │ └── HTMLParagraphElement.test.ts │ │ │ ├── html-param-element │ │ │ │ └── HTMLParamElement.test.ts │ │ │ ├── html-picture-element │ │ │ │ └── HTMLPictureElement.test.ts │ │ │ ├── html-pre-element │ │ │ │ └── HTMLPreElement.test.ts │ │ │ ├── html-progress-element │ │ │ │ └── HTMLProgressElement.test.ts │ │ │ ├── html-quote-element │ │ │ │ └── HTMLQuoteElement.test.ts │ │ │ ├── html-script-element │ │ │ │ ├── HTMLScriptElement.test.ts │ │ │ │ ├── modules-with-compilation-error │ │ │ │ │ ├── TestModuleElement.js │ │ │ │ │ └── utilities │ │ │ │ │ │ └── stringUtility.js │ │ │ │ ├── modules-with-evaluation-error │ │ │ │ │ ├── TestModuleElement.js │ │ │ │ │ └── utilities │ │ │ │ │ │ └── stringUtility.js │ │ │ │ ├── modules-with-import-map │ │ │ │ │ ├── default │ │ │ │ │ │ ├── TestModuleElement.js │ │ │ │ │ │ └── utilities │ │ │ │ │ │ │ ├── StringUtilityClass.js │ │ │ │ │ │ │ └── lazyload.js │ │ │ │ │ ├── external-resources │ │ │ │ │ │ ├── css │ │ │ │ │ │ │ └── style.css │ │ │ │ │ │ └── json │ │ │ │ │ │ │ └── data.json │ │ │ │ │ └── external-scripts │ │ │ │ │ │ └── utilities │ │ │ │ │ │ ├── apostrophWrapper.js │ │ │ │ │ │ └── stringUtility.js │ │ │ │ ├── modules-with-not-found-error │ │ │ │ │ ├── TestModuleElement.js │ │ │ │ │ └── utilities │ │ │ │ │ │ └── stringUtility.js │ │ │ │ └── modules │ │ │ │ │ ├── TestModuleElement.js │ │ │ │ │ ├── css │ │ │ │ │ └── style.css │ │ │ │ │ ├── json │ │ │ │ │ └── data.json │ │ │ │ │ └── utilities │ │ │ │ │ ├── StringUtilityClass.js │ │ │ │ │ ├── apostrophWrapper.js │ │ │ │ │ ├── lazyload.js │ │ │ │ │ └── stringUtility.js │ │ │ ├── html-select-element │ │ │ │ ├── HTMLSelectElement.test.ts │ │ │ │ └── __snapshots__ │ │ │ │ │ └── HTMLSelectElement.test.ts.snap │ │ │ ├── html-slot-element │ │ │ │ ├── CustomElementWithNamedSlots.ts │ │ │ │ ├── CustomElementWithSlot.ts │ │ │ │ └── HTMLSlotElement.test.ts │ │ │ ├── html-source-element │ │ │ │ └── HTMLSourceElement.test.ts │ │ │ ├── html-span-element │ │ │ │ └── HTMLSpanElement.test.ts │ │ │ ├── html-style-element │ │ │ │ └── HTMLStyleElement.test.ts │ │ │ ├── html-table-caption-element │ │ │ │ └── HTMLTableCaptionElement.test.ts │ │ │ ├── html-table-cell-element │ │ │ │ └── HTMLTableCellElement.test.ts │ │ │ ├── html-table-col-element │ │ │ │ └── HTMLTableColElement.test.ts │ │ │ ├── html-table-element │ │ │ │ └── HTMLTableElement.test.ts │ │ │ ├── html-table-row-element │ │ │ │ └── HTMLTableRowElement.test.ts │ │ │ ├── html-table-section-element │ │ │ │ └── HTMLTableSectionElement.test.ts │ │ │ ├── html-template-element │ │ │ │ └── HTMLTemplateElement.test.ts │ │ │ ├── html-text-area-element │ │ │ │ └── HTMLTextAreaElement.test.ts │ │ │ ├── html-time-element │ │ │ │ └── HTMLTimeElement.test.ts │ │ │ ├── html-title-element │ │ │ │ └── HTMLTitleElement.test.ts │ │ │ ├── html-track-element │ │ │ │ └── HTMLTrackElement.test.ts │ │ │ ├── html-u-list-element │ │ │ │ └── HTMLUListElement.test.ts │ │ │ ├── node │ │ │ │ ├── Node.test.ts │ │ │ │ ├── NodeList.test.ts │ │ │ │ └── NodeUtility.test.ts │ │ │ ├── parent-node │ │ │ │ └── ParentNodeUtility.test.ts │ │ │ ├── shadow-root │ │ │ │ └── ShadowRoot.test.ts │ │ │ ├── svg-animate-element │ │ │ │ └── SVGAnimateElement.test.ts │ │ │ ├── svg-animate-motion-element │ │ │ │ └── SVGAnimateMotionElement.test.ts │ │ │ ├── svg-animate-transform-element │ │ │ │ └── SVGAnimateTransformElement.test.ts │ │ │ ├── svg-animation-element │ │ │ │ └── SVGAnimationElement.test.ts │ │ │ ├── svg-circle-element │ │ │ │ └── SVGCircleElement.test.ts │ │ │ ├── svg-clip-path-element │ │ │ │ └── SVGClipPathElement.test.ts │ │ │ ├── svg-component-transfer-function-element │ │ │ │ └── SVGComponentTransferFunctionElement.test.ts │ │ │ ├── svg-defs-element │ │ │ │ └── SVGDefsElement.test.ts │ │ │ ├── svg-desc-element │ │ │ │ └── SVGDescElement.test.ts │ │ │ ├── svg-element │ │ │ │ └── SVGElement.test.ts │ │ │ ├── svg-ellipse-element │ │ │ │ └── SVGEllipseElement.test.ts │ │ │ ├── svg-fe-blend-element │ │ │ │ └── SVGFEBlendElement.test.ts │ │ │ ├── svg-fe-color-matrix-element │ │ │ │ └── SVGFEColorMatrixElement.test.ts │ │ │ ├── svg-fe-component-transfer-element │ │ │ │ └── SVGFEComponentTransferElement.test.ts │ │ │ ├── svg-fe-composite-element │ │ │ │ └── SVGFECompositeElement.test.ts │ │ │ ├── svg-fe-convolve-matrix-element │ │ │ │ └── SVGFEConvolveMatrixElement.test.ts │ │ │ ├── svg-fe-diffuse-lighting-element │ │ │ │ └── SVGFEDiffuseLightingElement.test.ts │ │ │ ├── svg-fe-displacement-map-element │ │ │ │ └── SVGFEDisplacementMapElement.test.ts │ │ │ ├── svg-fe-distant-light-element │ │ │ │ └── SVGFEDistantLightElement.test.ts │ │ │ ├── svg-fe-drop-shadow-element │ │ │ │ └── SVGFEDropShadowElement.test.ts │ │ │ ├── svg-fe-flood-element │ │ │ │ └── SVGFEFloodElement.test.ts │ │ │ ├── svg-fe-func-a-element │ │ │ │ └── SVGFEFuncAElement.test.ts │ │ │ ├── svg-fe-func-b-element │ │ │ │ └── SVGFEFuncBElement.test.ts │ │ │ ├── svg-fe-func-g-element │ │ │ │ └── SVGFEFuncGElement.test.ts │ │ │ ├── svg-fe-func-r-element │ │ │ │ └── SVGFEFuncRElement.test.ts │ │ │ ├── svg-fe-gaussian-blur-element │ │ │ │ └── SVGFEGaussianBlurElement.test.ts │ │ │ ├── svg-fe-image-element │ │ │ │ └── SVGFEImageElement.test.ts │ │ │ ├── svg-fe-merge-element │ │ │ │ └── SVGFEMergeElement.test.ts │ │ │ ├── svg-fe-merge-node-element │ │ │ │ └── SVGFEMergeNodeElement.test.ts │ │ │ ├── svg-fe-morphology-element │ │ │ │ └── SVGFEMorphologyElement.test.ts │ │ │ ├── svg-fe-offset-element │ │ │ │ └── SVGFEOffsetElement.test.ts │ │ │ ├── svg-fe-point-light-element │ │ │ │ └── SVGFEPointLightElement.test.ts │ │ │ ├── svg-fe-specular-lighting-element │ │ │ │ └── SVGFESpecularLightingElement.test.ts │ │ │ ├── svg-fe-spot-light-element │ │ │ │ └── SVGFESpotLightElement.test.ts │ │ │ ├── svg-fe-tile-element │ │ │ │ └── SVGFETileElement.test.ts │ │ │ ├── svg-fe-turbulence-element │ │ │ │ └── SVGFETurbulenceElement.test.ts │ │ │ ├── svg-filter-element │ │ │ │ └── SVGFilterElement.test.ts │ │ │ ├── svg-foreign-object-element │ │ │ │ └── SVGForeignObjectElement.test.ts │ │ │ ├── svg-g-element │ │ │ │ └── SVGGElement.test.ts │ │ │ ├── svg-geometry-element │ │ │ │ └── SVGGeometryElement.test.ts │ │ │ ├── svg-gradient-element │ │ │ │ └── SVGGradientElement.test.ts │ │ │ ├── svg-graphics-element │ │ │ │ └── SVGGraphicsElement.test.ts │ │ │ ├── svg-image-element │ │ │ │ └── SVGImageElement.test.ts │ │ │ ├── svg-line-element │ │ │ │ └── SVGLineElement.test.ts │ │ │ ├── svg-linear-gradient-element │ │ │ │ └── SVGLinearGradientElement.test.ts │ │ │ ├── svg-m-path-element │ │ │ │ └── SVGMPathElement.test.ts │ │ │ ├── svg-marker-element │ │ │ │ └── SVGMarkerElement.test.ts │ │ │ ├── svg-mask-element │ │ │ │ └── SVGMaskElement.test.ts │ │ │ ├── svg-metadata-element │ │ │ │ └── SVGMetadataElement.test.ts │ │ │ ├── svg-path-element │ │ │ │ └── SVGPathElement.test.ts │ │ │ ├── svg-pattern-element │ │ │ │ └── SVGPatternElement.test.ts │ │ │ ├── svg-polygon-element │ │ │ │ └── SVGPolygonElement.test.ts │ │ │ ├── svg-polyline-element │ │ │ │ └── SVGPolylineElement.test.ts │ │ │ ├── svg-radial-gradient-element │ │ │ │ └── SVGRadialGradientElement.test.ts │ │ │ ├── svg-rect-element │ │ │ │ └── SVGRectElement.test.ts │ │ │ ├── svg-script-element │ │ │ │ └── SVGScriptElement.test.ts │ │ │ ├── svg-set-element │ │ │ │ └── SVGSetElement.test.ts │ │ │ ├── svg-stop-element │ │ │ │ └── SVGStopElement.test.ts │ │ │ ├── svg-style-element │ │ │ │ └── SVGStyleElement.test.ts │ │ │ ├── svg-svg-element │ │ │ │ └── SVGSVGElement.test.ts │ │ │ ├── svg-switch-element │ │ │ │ └── SVGSwitchElement.test.ts │ │ │ ├── svg-symbol-element │ │ │ │ └── SVGSymbolElement.test.ts │ │ │ ├── svg-t-span-element │ │ │ │ └── SVGTSpanElement.test.ts │ │ │ ├── svg-text-content-element │ │ │ │ └── SVGTextContentElement.test.ts │ │ │ ├── svg-text-element │ │ │ │ └── SVGTextElement.test.ts │ │ │ ├── svg-text-positioning-element │ │ │ │ └── SVGTextPositioningElement.test.ts │ │ │ ├── svg-title-element │ │ │ │ └── SVGTitleElement.test.ts │ │ │ ├── svg-use-element │ │ │ │ └── SVGUseElement.test.ts │ │ │ ├── svg-view-element │ │ │ │ └── SVGViewElement.test.ts │ │ │ └── text │ │ │ │ └── Text.test.ts │ │ ├── permissions │ │ │ └── Permissions.test.ts │ │ ├── query-selector │ │ │ ├── QuerySelector.test.ts │ │ │ └── data │ │ │ │ ├── QuerySelectorHTML.ts │ │ │ │ └── QuerySelectorNthChildHTML.ts │ │ ├── range │ │ │ └── Range.test.ts │ │ ├── selection │ │ │ └── Selection.test.ts │ │ ├── setup.ts │ │ ├── storage │ │ │ └── Storage.test.ts │ │ ├── svg │ │ │ ├── SVGAngle.test.ts │ │ │ ├── SVGAnimatedAngle.test.ts │ │ │ ├── SVGAnimatedBoolean.test.ts │ │ │ ├── SVGAnimatedEnumeration.test.ts │ │ │ ├── SVGAnimatedInteger.test.ts │ │ │ ├── SVGAnimatedLength.test.ts │ │ │ ├── SVGAnimatedLengthList.test.ts │ │ │ ├── SVGAnimatedNumber.test.ts │ │ │ ├── SVGAnimatedNumberList.test.ts │ │ │ ├── SVGAnimatedPreserveAspectRatio.test.ts │ │ │ ├── SVGAnimatedRect.test.ts │ │ │ ├── SVGAnimatedString.test.ts │ │ │ ├── SVGAnimatedTransformList.test.ts │ │ │ ├── SVGLength.test.ts │ │ │ ├── SVGLengthList.test.ts │ │ │ ├── SVGMatrix.test.ts │ │ │ ├── SVGNumber.test.ts │ │ │ ├── SVGNumberList.test.ts │ │ │ ├── SVGPoint.test.ts │ │ │ ├── SVGPointList.test.ts │ │ │ ├── SVGPreserveAspectRatio.test.ts │ │ │ ├── SVGRect.test.ts │ │ │ ├── SVGStringList.test.ts │ │ │ ├── SVGTransform.test.ts │ │ │ ├── SVGTransformList.test.ts │ │ │ └── SVGUnitTypes.test.ts │ │ ├── tree-walker │ │ │ ├── NodeIterator.test.ts │ │ │ ├── TreeWalker.test.ts │ │ │ └── data │ │ │ │ └── TreeWalkerHTML.ts │ │ ├── types.d.ts │ │ ├── url │ │ │ └── URL.test.ts │ │ ├── validity-state │ │ │ └── ValidityState.test.ts │ │ ├── window │ │ │ ├── BrowserWindow.test.ts │ │ │ ├── DetachedWindowAPI.test.ts │ │ │ ├── GlobalWindow.test.ts │ │ │ └── Window.test.ts │ │ ├── xml-http-request │ │ │ └── XMLHttpRequest.test.ts │ │ ├── xml-parser │ │ │ └── XMLParser.test.ts │ │ └── xml-serializer │ │ │ └── XMLSerializer.test.ts │ ├── tsconfig.json │ └── vitest.config.ts ├── integration-test │ ├── .editorconfig │ ├── .gitignore │ ├── .npmignore │ ├── .prettierrc.cjs │ ├── LICENSE │ ├── README.md │ ├── package.json │ └── test │ │ ├── index.js │ │ ├── tests │ │ ├── Browser.test.js │ │ ├── BrowserExceptionObserver.test.js │ │ ├── CommonJS.test.cjs │ │ ├── Fetch.test.js │ │ ├── WindowGlobals.test.js │ │ └── XMLHttpRequest.test.js │ │ └── utilities │ │ └── TestFunctions.js └── jest-environment │ ├── .editorconfig │ ├── .gitignore │ ├── .npmignore │ ├── .prettierrc.cjs │ ├── LICENSE │ ├── README.md │ ├── bin │ ├── build-lit-ts-config.cjs │ ├── copy-package-json-for-lit.cjs │ ├── copy-tsdef-for-lit.cjs │ └── transform-lit-require.cjs │ ├── package.json │ ├── src │ └── index.ts │ ├── test │ ├── angular │ │ ├── Angular.test.ts │ │ ├── AngularComponent.ts │ │ └── AngularModule.ts │ ├── javascript │ │ └── JavaScript.test.ts │ ├── jquery │ │ └── JQuery.test.ts │ ├── lit-element │ │ ├── LitElement.test.ts │ │ └── LitElementComponent.ts │ ├── react │ │ ├── React.test.tsx │ │ └── ReactComponents.tsx │ ├── testing-library │ │ └── TestingLibrary.test.tsx │ ├── tsconfig.json │ └── vue │ │ └── Vue.test.ts │ └── tsconfig.json ├── turbo.json └── vitest.workspace.ts /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: http://EditorConfig.org 2 | 3 | # top-most EditorConfig file 4 | root = true 5 | 6 | # Indentation override for all JS under lib directory 7 | [{**.js,**.json}] 8 | indent_style = tab 9 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | **/node_modules 2 | **/tmp 3 | **/lib 4 | **/cjs 5 | **/tmp 6 | **/test/**/modules-with-compilation-error -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # The star (*) means that it matches all files. 2 | * david@ortner.se 3 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: capricorn86 -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Device:** 27 | - OS: [e.g. iOS] 28 | - Browser [e.g. chrome, safari] 29 | - Version [e.g. 22] 30 | 31 | **Additional context** 32 | Add any other context about the problem here. 33 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/custom.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Custom issue template 3 | about: Describe this issue template's purpose here. 4 | title: '' 5 | labels: question 6 | assignees: '' 7 | 8 | --- 9 | 10 | 11 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: enhancement 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/workflows/auto-assign.yml: -------------------------------------------------------------------------------- 1 | name: Auto Assign 2 | on: 3 | pull_request: 4 | types: 5 | - opened 6 | jobs: 7 | auto-assign: 8 | runs-on: ubuntu-latest 9 | steps: 10 | - name: Set build URL to commit status 11 | run: | 12 | curl \ 13 | --request POST \ 14 | --url https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.number }} \ 15 | --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \ 16 | --header 'content-type: application/json' \ 17 | --data "{ 18 | \"assignees\": [\"${{ github.actor }}\"] 19 | }" 20 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | tmp 3 | lerna-debug.log 4 | .DS_Store 5 | .idea 6 | .turbo -------------------------------------------------------------------------------- /.husky/.gitignore: -------------------------------------------------------------------------------- 1 | _ 2 | -------------------------------------------------------------------------------- /.husky/commit-msg: -------------------------------------------------------------------------------- 1 | node ./node_modules/.bin/happy-validate-commit-message --commitFile=$1 2 | -------------------------------------------------------------------------------- /.husky/pre-commit: -------------------------------------------------------------------------------- 1 | node ./node_modules/.bin/happy-lint-changed -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | legacy-peer-deps=true -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | README.md -------------------------------------------------------------------------------- /.prettierrc.cjs: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | singleQuote: true, 3 | useTabs: true, 4 | printWidth: 100, 5 | trailingComma: 'none' 6 | }; 7 | -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": ["vitest.explorer"] 3 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 David Ortner (capricorn86) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Supported Versions 4 | 5 | | Version | Supported | 6 | | --------- | ------------------ | 7 | | > 15.10.0 | :white_check_mark: | 8 | | < 15.10.0 | :x: | 9 | 10 | ## Reporting a Vulnerability 11 | 12 | Use the [Github Vulnaribilty Reporter](https://github.com/capricorn86/happy-dom/security) tool to report your findings. 13 | -------------------------------------------------------------------------------- /cspell.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2", 3 | "ignorePaths": [], 4 | "dictionaryDefinitions": [], 5 | "dictionaries": [], 6 | "words": [ 7 | "altgraph", 8 | "clonable", 9 | "Contoso", 10 | "ISVG", 11 | "oncompositionend", 12 | "oncompositionstart", 13 | "oncompositionupdate", 14 | "oncontentvisibilityautostatechange", 15 | "onpointerrawupdate", 16 | "onscrollsnapchange", 17 | "onscrollsnapchanging", 18 | "onsearch", 19 | "unnestable", 20 | "xlink" 21 | ], 22 | "ignoreWords": [], 23 | "import": [] 24 | } 25 | -------------------------------------------------------------------------------- /docs/happy-dom-logo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/capricorn86/happy-dom/24912049d7ec70748dc987da1dfbde9fbd5bd848/docs/happy-dom-logo.jpg -------------------------------------------------------------------------------- /docs/happy-dom-logo.jpg~: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/capricorn86/happy-dom/24912049d7ec70748dc987da1dfbde9fbd5bd848/docs/happy-dom-logo.jpg~ -------------------------------------------------------------------------------- /packages/global-registrator/.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: http://EditorConfig.org 2 | 3 | # top-most EditorConfig file 4 | root = true 5 | 6 | # Indentation override for all JS under lib directory 7 | [{**.js,**.ts,**.json}] 8 | indent_style = tab -------------------------------------------------------------------------------- /packages/global-registrator/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | tmp 3 | lib 4 | cjs -------------------------------------------------------------------------------- /packages/global-registrator/.npmignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | tmp 3 | test 4 | .turbo 5 | npm-shrinkwrap.json -------------------------------------------------------------------------------- /packages/global-registrator/.prettierrc.cjs: -------------------------------------------------------------------------------- 1 | module.exports = require('../happy-dom/.prettierrc.cjs'); 2 | -------------------------------------------------------------------------------- /packages/global-registrator/src/index.ts: -------------------------------------------------------------------------------- 1 | import GlobalRegistrator from './GlobalRegistrator.js'; 2 | 3 | export { GlobalRegistrator }; 4 | -------------------------------------------------------------------------------- /packages/global-registrator/test/react/ReactComponent.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | /** 4 | * 5 | */ 6 | export default class ReactComponent extends React.Component<{}, {}> { 7 | public $props = {}; 8 | 9 | /** 10 | * @override 11 | */ 12 | public render(): React.ReactElement { 13 | return
Test
; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /packages/global-registrator/test/react/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../../tmp", 5 | "rootDir": "../../test", 6 | "jsx": "react", 7 | "module": "CommonJS", 8 | "moduleResolution": "Node", 9 | "lib": [ 10 | "es2015", 11 | "es2016", 12 | "es2017", 13 | "dom" 14 | ] 15 | }, 16 | "include": [ 17 | "@types/node", 18 | ".", 19 | "../../lib" 20 | ] 21 | } -------------------------------------------------------------------------------- /packages/global-registrator/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "outDir": "lib", 4 | "rootDir": "src", 5 | "target": "ES2022", 6 | "declaration": true, 7 | "declarationMap": true, 8 | "module": "Node16", 9 | "moduleResolution": "Node16", 10 | "esModuleInterop": true, 11 | "experimentalDecorators": true, 12 | "allowSyntheticDefaultImports": true, 13 | "resolveJsonModule": true, 14 | "noUnusedLocals": true, 15 | "noUnusedParameters": true, 16 | "removeComments": false, 17 | "preserveConstEnums": true, 18 | "sourceMap": true, 19 | "skipLibCheck": true, 20 | "baseUrl": ".", 21 | "composite": false, 22 | "incremental": false, 23 | "jsx": "react", 24 | "types": [ 25 | "node" 26 | ], 27 | "lib": [ 28 | "es2015", 29 | "es2016", 30 | "es2017" 31 | ] 32 | }, 33 | "include": [ 34 | "@types/node", 35 | "src", 36 | "src/**/*.json" 37 | ] 38 | } -------------------------------------------------------------------------------- /packages/happy-dom/.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: http://EditorConfig.org 2 | 3 | # top-most EditorConfig file 4 | root = true 5 | 6 | # Indentation override for all JS under lib directory 7 | [{**.js,**.ts,**.json}] 8 | indent_style = tab -------------------------------------------------------------------------------- /packages/happy-dom/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | tmp 3 | lib 4 | cjs 5 | .DS_Store -------------------------------------------------------------------------------- /packages/happy-dom/.npmignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | tmp 3 | test 4 | bin 5 | .turbo 6 | npm-shrinkwrap.json -------------------------------------------------------------------------------- /packages/happy-dom/.prettierrc.cjs: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | singleQuote: true, 3 | useTabs: true, 4 | printWidth: 100, 5 | trailingComma: 'none' 6 | }; -------------------------------------------------------------------------------- /packages/happy-dom/bin/build-version-file.cjs: -------------------------------------------------------------------------------- 1 | /* eslint-disable no-console*/ 2 | 3 | const Path = require('path'); 4 | const FS = require('fs'); 5 | const packageJson = require('../package.json'); 6 | 7 | async function main() { 8 | await Promise.all([ 9 | FS.promises.writeFile( 10 | Path.resolve(Path.join('.', 'lib', 'version.js')), 11 | `export default { version: '${packageJson.version}' };` 12 | ), 13 | FS.promises.writeFile( 14 | Path.resolve(Path.join('.', 'cjs', 'version.cjs')), 15 | `module.exports = { default: { version: '${packageJson.version}' } };` 16 | ) 17 | ]); 18 | } 19 | 20 | main(); 21 | -------------------------------------------------------------------------------- /packages/happy-dom/src/browser/DefaultBrowserPageViewport.ts: -------------------------------------------------------------------------------- 1 | import IBrowserPageViewport from './types/IBrowserPageViewport.js'; 2 | 3 | export default { 4 | width: 1024, 5 | height: 768, 6 | devicePixelRatio: 1 7 | }; 8 | -------------------------------------------------------------------------------- /packages/happy-dom/src/browser/enums/BrowserErrorCaptureEnum.ts: -------------------------------------------------------------------------------- 1 | enum BrowserErrorCaptureEnum { 2 | /** Happy DOM use try and catch when evaluating code, but will not be able to catch all errors and Promise rejections. This will decrease performance as using try and catch makes the execution significally slower. This is the default setting. */ 3 | tryAndCatch = 'tryAndCatch', 4 | /** Happy DOM will add an event listener to the Node.js process to catch all errors and Promise rejections. This will not work in Jest and Vitest as it conflicts with their error listeners. */ 5 | processLevel = 'processLevel', 6 | /** Error capturing is disabled. Errors and Promise rejections will be thrown. */ 7 | disabled = 'disabled' 8 | } 9 | 10 | export default BrowserErrorCaptureEnum; 11 | -------------------------------------------------------------------------------- /packages/happy-dom/src/browser/enums/BrowserNavigationCrossOriginPolicyEnum.ts: -------------------------------------------------------------------------------- 1 | enum BrowserNavigationCrossOriginPolicyEnum { 2 | /** The browser can navigate to any origin. */ 3 | anyOrigin = 'anyOrigin', 4 | /** The browser can only navigate to the same origin as the current page or its parent. */ 5 | sameOrigin = 'sameOrigin', 6 | /** The browser can never navigate from a secure protocol (https) to an unsecure protocol (http), but it can always navigate to a secure (https). */ 7 | strictOrigin = 'strictOrigin' 8 | } 9 | 10 | export default BrowserNavigationCrossOriginPolicyEnum; 11 | -------------------------------------------------------------------------------- /packages/happy-dom/src/browser/types/IBrowserPageViewport.ts: -------------------------------------------------------------------------------- 1 | export default interface IBrowserPageViewport { 2 | width: number; 3 | height: number; 4 | devicePixelRatio: number; 5 | } 6 | -------------------------------------------------------------------------------- /packages/happy-dom/src/browser/types/IGoToOptions.ts: -------------------------------------------------------------------------------- 1 | import IRequestReferrerPolicy from '../../fetch/types/IRequestReferrerPolicy.js'; 2 | import IReloadOptions from './IReloadOptions.js'; 3 | 4 | /** 5 | * Go to options. 6 | */ 7 | export default interface IGoToOptions extends IReloadOptions { 8 | /** 9 | * Referrer. 10 | */ 11 | referrer?: string; 12 | 13 | /** 14 | * Referrer policy. 15 | */ 16 | referrerPolicy?: IRequestReferrerPolicy; 17 | } 18 | -------------------------------------------------------------------------------- /packages/happy-dom/src/browser/types/IOptionalBrowserPageViewport.ts: -------------------------------------------------------------------------------- 1 | export default interface IOptionalBrowserPageViewport { 2 | width?: number; 3 | height?: number; 4 | devicePixelRatio?: number; 5 | } 6 | -------------------------------------------------------------------------------- /packages/happy-dom/src/browser/types/IReloadOptions.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Reload options. 3 | */ 4 | export default interface IReloadOptions { 5 | /** 6 | * Set to true to bypass the cache. 7 | */ 8 | hard?: boolean; 9 | 10 | /** 11 | * Timeout in ms. Default is 30000ms. 12 | */ 13 | timeout?: number; 14 | } 15 | -------------------------------------------------------------------------------- /packages/happy-dom/src/browser/utilities/BrowserFrameScriptEvaluator.ts: -------------------------------------------------------------------------------- 1 | import IBrowserFrame from '../types/IBrowserFrame.js'; 2 | import { Script } from 'vm'; 3 | 4 | /** 5 | * Browser frame script evaluator. 6 | */ 7 | export default class BrowserFrameScriptEvaluator { 8 | /** 9 | * Evaluates code or a VM Script in the frame's context. 10 | * 11 | * @param frame Frame. 12 | * @param script Script. 13 | * @returns Result. 14 | */ 15 | public static evaluate(frame: IBrowserFrame, script: string | Script): any { 16 | if (!frame.window) { 17 | throw new Error('The frame has been destroyed, the "window" property is not set.'); 18 | } 19 | script = typeof script === 'string' ? new Script(script) : script; 20 | return script.runInContext(frame.window); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /packages/happy-dom/src/browser/utilities/BrowserFrameURL.ts: -------------------------------------------------------------------------------- 1 | import IBrowserFrame from '../types/IBrowserFrame.js'; 2 | import { URL } from 'url'; 3 | 4 | /** 5 | * Browser frame URL utility. 6 | */ 7 | export default class BrowserFrameURL { 8 | /** 9 | * Returns relative URL. 10 | * 11 | * @param frame Frame. 12 | * @param url URL. 13 | * @returns Relative URL. 14 | */ 15 | public static getRelativeURL(frame: IBrowserFrame, url: string | URL): URL { 16 | url = url ? String(url) : 'about:blank'; 17 | 18 | if (url.startsWith('about:') || url.startsWith('javascript:')) { 19 | return new URL(url); 20 | } 21 | 22 | try { 23 | return new URL(url, frame.window.location.href); 24 | } catch (e) { 25 | return new URL('about:blank'); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /packages/happy-dom/src/config/HTMLElementConfigContentModelEnum.ts: -------------------------------------------------------------------------------- 1 | enum HTMLElementConfigContentModelEnum { 2 | rawText = 'rawText', 3 | noSelfDescendants = 'noSelfDescendants', 4 | noFirstLevelSelfDescendants = 'noFirstLevelSelfDescendants', 5 | noForbiddenFirstLevelDescendants = 'noForbiddenFirstLevelDescendants', 6 | noDescendants = 'noDescendants', 7 | permittedDescendants = 'permittedDescendants', 8 | textOrComments = 'textOrComments', 9 | anyDescendants = 'anyDescendants' 10 | } 11 | 12 | export default HTMLElementConfigContentModelEnum; 13 | -------------------------------------------------------------------------------- /packages/happy-dom/src/config/NamespaceURI.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | html: 'http://www.w3.org/1999/xhtml', 3 | svg: 'http://www.w3.org/2000/svg', 4 | mathML: 'http://www.w3.org/1998/Math/MathML', 5 | xml: 'http://www.w3.org/XML/1998/namespace', 6 | xlink: 'http://www.w3.org/1999/xlink', 7 | xmlns: 'http://www.w3.org/2000/xmlns/' 8 | }; 9 | -------------------------------------------------------------------------------- /packages/happy-dom/src/console/IVirtualConsoleLogEntry.ts: -------------------------------------------------------------------------------- 1 | import IVirtualConsoleLogGroup from './IVirtualConsoleLogGroup.js'; 2 | import VirtualConsoleLogLevelEnum from './enums/VirtualConsoleLogLevelEnum.js'; 3 | import VirtualConsoleLogTypeEnum from './enums/VirtualConsoleLogTypeEnum.js'; 4 | 5 | export default interface IVirtualConsoleLogEntry { 6 | type: VirtualConsoleLogTypeEnum; 7 | level: VirtualConsoleLogLevelEnum; 8 | message: Array; 9 | group: IVirtualConsoleLogGroup | null; 10 | } 11 | -------------------------------------------------------------------------------- /packages/happy-dom/src/console/IVirtualConsoleLogGroup.ts: -------------------------------------------------------------------------------- 1 | export default interface IVirtualConsoleLogGroup { 2 | id: number; 3 | label: string; 4 | collapsed: boolean; 5 | parent: IVirtualConsoleLogGroup; 6 | } 7 | -------------------------------------------------------------------------------- /packages/happy-dom/src/console/enums/VirtualConsoleLogLevelEnum.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Virtual console log level. 3 | * 4 | * @see https://console.spec.whatwg.org/#loglevel-severity 5 | */ 6 | enum VirtualConsoleLogLevelEnum { 7 | log = 0, 8 | info = 1, 9 | warn = 2, 10 | error = 3 11 | } 12 | export default VirtualConsoleLogLevelEnum; 13 | -------------------------------------------------------------------------------- /packages/happy-dom/src/console/enums/VirtualConsoleLogTypeEnum.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Virtual console log type. 3 | */ 4 | enum VirtualConsoleLogTypeEnum { 5 | // Log 6 | log = 'log', 7 | table = 'table', 8 | trace = 'trace', 9 | dir = 'dir', 10 | dirxml = 'dirxml', 11 | group = 'group', 12 | groupCollapsed = 'groupCollapsed', 13 | debug = 'debug', 14 | timeLog = 'timeLog', 15 | 16 | // Info 17 | info = 'info', 18 | count = 'count', 19 | timeEnd = 'timeEnd', 20 | 21 | // Warning 22 | warn = 'warn', 23 | countReset = 'countReset', 24 | 25 | // Error 26 | error = 'error', 27 | assert = 'assert' 28 | } 29 | export default VirtualConsoleLogTypeEnum; 30 | -------------------------------------------------------------------------------- /packages/happy-dom/src/cookie/DefaultCookie.ts: -------------------------------------------------------------------------------- 1 | import CookieSameSiteEnum from './enums/CookieSameSiteEnum.js'; 2 | import ICookie from './ICookie.js'; 3 | 4 | export default { 5 | // Required 6 | key: null, 7 | originURL: null, 8 | 9 | // Optional 10 | value: null, 11 | domain: '', 12 | path: '', 13 | expires: null, 14 | httpOnly: false, 15 | secure: false, 16 | sameSite: CookieSameSiteEnum.lax 17 | }; 18 | -------------------------------------------------------------------------------- /packages/happy-dom/src/cookie/ICookie.ts: -------------------------------------------------------------------------------- 1 | import CookieSameSiteEnum from './enums/CookieSameSiteEnum.js'; 2 | 3 | export default interface ICookie { 4 | // Required 5 | key: string; 6 | originURL: URL; 7 | value: string | null; 8 | domain: string; 9 | path: string; 10 | expires: Date | null; 11 | httpOnly: boolean; 12 | secure: boolean; 13 | sameSite: CookieSameSiteEnum; 14 | } 15 | -------------------------------------------------------------------------------- /packages/happy-dom/src/cookie/ICookieContainer.ts: -------------------------------------------------------------------------------- 1 | import URL from '../url/URL.js'; 2 | import ICookie from './ICookie.js'; 3 | import IOptionalCookie from './IOptionalCookie.js'; 4 | 5 | /** 6 | * Cookie Container. 7 | * 8 | * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cookie. 9 | * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie. 10 | */ 11 | export default interface ICookieContainer { 12 | /** 13 | * Adds cookies. 14 | * 15 | * @param cookies Cookies. 16 | */ 17 | addCookies(cookies: IOptionalCookie[]): void; 18 | 19 | /** 20 | * Returns cookies. 21 | * 22 | * @param [url] URL. 23 | * @param [httpOnly] "true" if only http cookies should be returned. 24 | * @returns Cookies. 25 | */ 26 | getCookies(url: URL | null, httpOnly?: boolean): ICookie[]; 27 | } 28 | -------------------------------------------------------------------------------- /packages/happy-dom/src/cookie/IOptionalCookie.ts: -------------------------------------------------------------------------------- 1 | import CookieSameSiteEnum from './enums/CookieSameSiteEnum.js'; 2 | 3 | export default interface IOptionalCookie { 4 | // Required 5 | key: string; 6 | originURL: URL; 7 | 8 | // Optional 9 | value?: string | null; 10 | domain?: string; 11 | path?: string; 12 | expires?: Date | null; 13 | httpOnly?: boolean; 14 | secure?: boolean; 15 | sameSite?: CookieSameSiteEnum; 16 | } 17 | -------------------------------------------------------------------------------- /packages/happy-dom/src/cookie/enums/CookieSameSiteEnum.ts: -------------------------------------------------------------------------------- 1 | enum CookieSameSiteEnum { 2 | strict = 'Strict', 3 | lax = 'Lax', 4 | none = 'None' 5 | } 6 | export default CookieSameSiteEnum; 7 | -------------------------------------------------------------------------------- /packages/happy-dom/src/cookie/urilities/CookieExpireUtility.ts: -------------------------------------------------------------------------------- 1 | import ICookie from '../ICookie.js'; 2 | 3 | /** 4 | * Cookie expire utility. 5 | */ 6 | export default class CookieExpireUtility { 7 | /** 8 | * Returns "true" if cookie has expired. 9 | * 10 | * @param cookie Cookie. 11 | * @returns "true" if cookie has expired. 12 | */ 13 | public static hasExpired(cookie: ICookie): boolean | null { 14 | return cookie.expires && cookie.expires.getTime() < Date.now(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /packages/happy-dom/src/cookie/urilities/CookieURLUtility.ts: -------------------------------------------------------------------------------- 1 | import CookieSameSiteEnum from '../enums/CookieSameSiteEnum.js'; 2 | import URL from '../../url/URL.js'; 3 | import ICookie from '../ICookie.js'; 4 | 5 | /** 6 | * Cookie string. 7 | */ 8 | export default class CookieURLUtility { 9 | /** 10 | * Returns "true" if cookie matches URL. 11 | * 12 | * @param cookie Cookie. 13 | * @param url URL. 14 | * @returns "true" if cookie matches URL. 15 | */ 16 | public static cookieMatchesURL(cookie: ICookie, url: URL): boolean { 17 | const isLocalhost = url.hostname === 'localhost' || url.hostname.endsWith('.localhost'); 18 | return ( 19 | (!cookie.secure || url.protocol === 'https:' || isLocalhost) && 20 | (!cookie.domain || url.hostname.endsWith(cookie.domain)) && 21 | (!cookie.path || url.pathname.startsWith(cookie.path)) && 22 | // @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#samesitesamesite-value 23 | ((cookie.sameSite === CookieSameSiteEnum.none && cookie.secure) || 24 | cookie.originURL.hostname === url.hostname) 25 | ); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /packages/happy-dom/src/css/CSSRuleTypeEnum.ts: -------------------------------------------------------------------------------- 1 | enum CSSRuleTypeEnum { 2 | containerRule = 0, 3 | styleRule = 1, 4 | importRule = 3, 5 | mediaRule = 4, 6 | fontFaceRule = 5, 7 | pageRule = 6, 8 | keyframesRule = 7, 9 | keyframeRule = 8, 10 | namespaceRule = 10, 11 | counterStyleRule = 11, 12 | supportsRule = 12, 13 | documentRule = 13, 14 | fontFeatureValuesRule = 14, 15 | regionStyleRule = 16 16 | } 17 | 18 | export default CSSRuleTypeEnum; 19 | -------------------------------------------------------------------------------- /packages/happy-dom/src/css/CSSUnitValue.ts: -------------------------------------------------------------------------------- 1 | import CSSUnits from './CSSUnits.js'; 2 | 3 | /** 4 | * CSS unit value. 5 | */ 6 | export default class CSSUnitValue { 7 | public unit: string = null; 8 | public value: number = null; 9 | 10 | /** 11 | * Constructor. 12 | * 13 | * @param value Value. 14 | * @param unit Unit. 15 | */ 16 | constructor(value: number, unit: string) { 17 | if (typeof value !== 'number') { 18 | throw new TypeError('The provided double value is non-finite'); 19 | } 20 | if (!CSSUnits.includes(unit)) { 21 | throw new TypeError('Invalid unit: ' + unit); 22 | } 23 | this.value = value; 24 | this.unit = unit; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /packages/happy-dom/src/css/CSSUnits.ts: -------------------------------------------------------------------------------- 1 | export default [ 2 | 'Hz', 3 | 'Q', 4 | 'ch', 5 | 'cm', 6 | 'deg', 7 | 'dpcm', 8 | 'dpi', 9 | 'dppx', 10 | 'em', 11 | 'ex', 12 | 'fr', 13 | 'grad', 14 | 'in', 15 | 'kHz', 16 | 'mm', 17 | 'ms', 18 | 'number', 19 | 'pc', 20 | 'percent', 21 | 'pt', 22 | 'px', 23 | 'rad', 24 | 'rem', 25 | 's', 26 | 'turn', 27 | 'vh', 28 | 'vmax', 29 | 'vmin', 30 | 'vw' 31 | ]; 32 | -------------------------------------------------------------------------------- /packages/happy-dom/src/css/declaration/computed-style/config/CSSStyleDeclarationElementInheritedProperties.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | 'border-collapse': true, 3 | 'border-spacing': true, 4 | 'caption-side': true, 5 | color: true, 6 | cursor: true, 7 | direction: true, 8 | 'empty-cells': true, 9 | 'font-family': true, 10 | 'font-size': true, 11 | 'font-style': true, 12 | 'font-variant': true, 13 | 'font-weight': true, 14 | 'font-size-adjust': true, 15 | 'font-stretch': true, 16 | font: true, 17 | 'letter-spacing': true, 18 | 'line-height': true, 19 | 'list-style-image': true, 20 | 'list-style-position': true, 21 | 'list-style-type': true, 22 | 'list-style': true, 23 | orphans: true, 24 | quotes: true, 25 | 'tab-size': true, 26 | 'text-align': true, 27 | 'text-align-last': true, 28 | 'text-decoration-color': true, 29 | 'text-indent': true, 30 | 'text-justify': true, 31 | 'text-shadow': true, 32 | 'text-transform': true, 33 | visibility: true, 34 | 'white-space': true, 35 | widows: true, 36 | 'word-break': true, 37 | 'word-spacing': true, 38 | 'word-wrap': true 39 | }; 40 | -------------------------------------------------------------------------------- /packages/happy-dom/src/css/declaration/computed-style/config/CSSStyleDeclarationElementMeasurementProperties.ts: -------------------------------------------------------------------------------- 1 | export default [ 2 | 'background-position-x', 3 | 'background-position-y', 4 | 'background-size', 5 | 'border-image-outset', 6 | 'border-top-width', 7 | 'border-right-width', 8 | 'border-bottom-width', 9 | 'border-left-width', 10 | 'border-top-left-radius', 11 | 'border-top-right-radius', 12 | 'border-bottom-right-radius', 13 | 'border-bottom-left-radius', 14 | 'border-image-width', 15 | 'clip', 16 | 'font-size', 17 | 'padding-top', 18 | 'padding-right', 19 | 'padding-bottom', 20 | 'padding-left', 21 | 'margin-top', 22 | 'margin-right', 23 | 'margin-bottom', 24 | 'margin-left', 25 | 'width', 26 | 'height', 27 | 'min-width', 28 | 'min-height', 29 | 'max-width', 30 | 'max-height', 31 | 'top', 32 | 'right', 33 | 'bottom', 34 | 'left', 35 | 'outline-width', 36 | 'outline-offset', 37 | 'letter-spacing', 38 | 'word-spacing', 39 | 'text-indent', 40 | 'line-height' 41 | ]; 42 | -------------------------------------------------------------------------------- /packages/happy-dom/src/css/declaration/property-manager/ICSSStyleDeclarationPropertyValue.ts: -------------------------------------------------------------------------------- 1 | export default interface ICSSStyleDeclarationPropertyValue { 2 | value: string; 3 | important: boolean; 4 | } 5 | -------------------------------------------------------------------------------- /packages/happy-dom/src/css/rules/CSSContainerRule.ts: -------------------------------------------------------------------------------- 1 | import CSSRule from '../CSSRule.js'; 2 | import CSSRuleTypeEnum from '../CSSRuleTypeEnum.js'; 3 | 4 | /** 5 | * CSSRule interface. 6 | */ 7 | export default class CSSContainerRule extends CSSRule { 8 | public readonly type = CSSRuleTypeEnum.containerRule; 9 | public readonly cssRules: CSSRule[] = []; 10 | public readonly conditionText = ''; 11 | 12 | /** 13 | * Returns css text. 14 | * 15 | * @returns CSS text. 16 | */ 17 | public get cssText(): string { 18 | let cssText = ''; 19 | for (const cssRule of this.cssRules) { 20 | cssText += cssRule.cssText; 21 | } 22 | return `@container ${this.conditionText} { ${cssText} }`; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /packages/happy-dom/src/css/rules/CSSMediaRule.ts: -------------------------------------------------------------------------------- 1 | import CSSRule from '../CSSRule.js'; 2 | import CSSRuleTypeEnum from '../CSSRuleTypeEnum.js'; 3 | import MediaList from '../MediaList.js'; 4 | 5 | /** 6 | * CSSRule interface. 7 | */ 8 | export default class CSSMediaRule extends CSSRule { 9 | public readonly type = CSSRuleTypeEnum.mediaRule; 10 | public readonly cssRules: CSSRule[] = []; 11 | public readonly media = new MediaList(); 12 | 13 | /** 14 | * Returns css text. 15 | * 16 | * @returns CSS text. 17 | */ 18 | public get cssText(): string { 19 | let cssText = ''; 20 | for (const cssRule of this.cssRules) { 21 | cssText += cssRule.cssText; 22 | } 23 | return `@media ${this.conditionText} { ${cssText} }`; 24 | } 25 | 26 | /** 27 | * Returns conditional text. 28 | * 29 | * @returns Conditional text. 30 | */ 31 | public get conditionText(): string { 32 | return this.media.mediaText; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /packages/happy-dom/src/css/rules/CSSSupportsRule.ts: -------------------------------------------------------------------------------- 1 | import CSSRule from '../CSSRule.js'; 2 | import CSSRuleTypeEnum from '../CSSRuleTypeEnum.js'; 3 | 4 | /** 5 | * CSSRule interface. 6 | */ 7 | export default class CSSSupportsRule extends CSSRule { 8 | public readonly type = CSSRuleTypeEnum.supportsRule; 9 | public readonly cssRules: CSSRule[] = []; 10 | public readonly conditionText = ''; 11 | 12 | /** 13 | * Returns css text. 14 | * 15 | * @returns CSS text. 16 | */ 17 | public get cssText(): string { 18 | let cssText = ''; 19 | for (const cssRule of this.cssRules) { 20 | cssText += cssRule.cssText; 21 | } 22 | return `@supports ${this.conditionText} { ${cssText} }`; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /packages/happy-dom/src/custom-element/ICustomElementDefinition.ts: -------------------------------------------------------------------------------- 1 | import HTMLElement from '../nodes/html-element/HTMLElement.js'; 2 | 3 | export default interface ICustomElementDefinition { 4 | elementClass: typeof HTMLElement; 5 | extends: string; 6 | observedAttributes: Set; 7 | livecycleCallbacks: { 8 | connectedCallback: () => void; 9 | disconnectedCallback: () => void; 10 | attributeChangedCallback: ( 11 | name: string, 12 | oldValue: string | null, 13 | newValue: string | null 14 | ) => void; 15 | }; 16 | } 17 | -------------------------------------------------------------------------------- /packages/happy-dom/src/dom/DOMRectList.ts: -------------------------------------------------------------------------------- 1 | import DOMRect from './DOMRect.js'; 2 | import * as PropertySymbol from '../PropertySymbol.js'; 3 | 4 | /** 5 | * DOM Rect List. 6 | * 7 | * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMRectList 8 | */ 9 | export default class DOMRectList extends Array { 10 | /** 11 | * Constructor. 12 | * 13 | * @param illegalConstructorSymbol Illegal constructor symbol. 14 | */ 15 | constructor(illegalConstructorSymbol: symbol) { 16 | super(); 17 | // "illegalConstructorSymbol" can be "1" when calling the "splice()" method 18 | if ( 19 | (illegalConstructorSymbol) !== 1 && 20 | illegalConstructorSymbol !== PropertySymbol.illegalConstructor 21 | ) { 22 | throw new TypeError('Illegal constructor'); 23 | } 24 | } 25 | 26 | /** 27 | * Returns item by index. 28 | * 29 | * @param index Index. 30 | */ 31 | public item(index: number): DOMRect { 32 | return this[index] ?? null; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /packages/happy-dom/src/dom/DOMStringMapUtility.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * DOMStringMap utility. 3 | * 4 | * Reference: 5 | * https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/dataset 6 | */ 7 | export default class DOMStringMapUtility { 8 | /** 9 | * Transforms a kebab cased string to camel case. 10 | * 11 | * @param text Text string. 12 | * @returns Camel cased string. 13 | */ 14 | public static kebabToCamelCase(text: string): string { 15 | const parts = text.split('-'); 16 | for (let i = 0, max = parts.length; i < max; i++) { 17 | parts[i] = i > 0 ? parts[i].charAt(0).toUpperCase() + parts[i].slice(1) : parts[i]; 18 | } 19 | return parts.join(''); 20 | } 21 | 22 | /** 23 | * Transforms a camel cased string to kebab case. 24 | * 25 | * @param text Text string. 26 | * @returns Kebab cased string. 27 | */ 28 | public static camelCaseToKebab(text: string): string { 29 | return text 30 | .toString() 31 | .replace(/[A-Z]+(?![a-z])|[A-Z]/g, ($, ofs) => (ofs ? '-' : '') + $.toLowerCase()); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /packages/happy-dom/src/dom/IDOMPointInit.ts: -------------------------------------------------------------------------------- 1 | export default interface IDOMPointInit { 2 | readonly x?: number; 3 | readonly y?: number; 4 | readonly z?: number; 5 | readonly w?: number; 6 | } 7 | -------------------------------------------------------------------------------- /packages/happy-dom/src/dom/IDOMRectInit.ts: -------------------------------------------------------------------------------- 1 | export default interface IDOMRectInit { 2 | readonly x: number; 3 | readonly y: number; 4 | readonly width: number; 5 | readonly height: number; 6 | } 7 | -------------------------------------------------------------------------------- /packages/happy-dom/src/dom/dom-matrix/IDOMMatrixCompatibleObject.ts: -------------------------------------------------------------------------------- 1 | export default interface IDOMMatrixCompatibleObject { 2 | a?: number; 3 | b?: number; 4 | c?: number; 5 | d?: number; 6 | e?: number; 7 | f?: number; 8 | m11?: number; 9 | m12?: number; 10 | m13?: number; 11 | m14?: number; 12 | m21?: number; 13 | m22?: number; 14 | m23?: number; 15 | m24?: number; 16 | m31?: number; 17 | m32?: number; 18 | m33?: number; 19 | m34?: number; 20 | m41?: number; 21 | m42?: number; 22 | m43?: number; 23 | m44?: number; 24 | } 25 | -------------------------------------------------------------------------------- /packages/happy-dom/src/dom/dom-matrix/IDOMMatrixJSON.ts: -------------------------------------------------------------------------------- 1 | export default interface IDOMMatrixJSON { 2 | a: number; 3 | b: number; 4 | c: number; 5 | d: number; 6 | e: number; 7 | f: number; 8 | m11: number; 9 | m12: number; 10 | m13: number; 11 | m14: number; 12 | m21: number; 13 | m22: number; 14 | m23: number; 15 | m24: number; 16 | m31: number; 17 | m32: number; 18 | m33: number; 19 | m34: number; 20 | m41: number; 21 | m42: number; 22 | m43: number; 23 | m44: number; 24 | is2D: boolean; 25 | isIdentity: boolean; 26 | } 27 | -------------------------------------------------------------------------------- /packages/happy-dom/src/dom/dom-matrix/TDOMMatrix2DArray.ts: -------------------------------------------------------------------------------- 1 | /** An array of 6 numbers representing a 2D matrix. */ 2 | type TDOMMatrix2DArray = [number, number, number, number, number, number]; 3 | export default TDOMMatrix2DArray; 4 | -------------------------------------------------------------------------------- /packages/happy-dom/src/dom/dom-matrix/TDOMMatrix3DArray.ts: -------------------------------------------------------------------------------- 1 | /** An array of 16 numbers representing a 3D matrix. */ 2 | type TDOMMatrix3DArray = [ 3 | number, 4 | number, 5 | number, 6 | number, 7 | number, 8 | number, 9 | number, 10 | number, 11 | number, 12 | number, 13 | number, 14 | number, 15 | number, 16 | number, 17 | number, 18 | number 19 | ]; 20 | export default TDOMMatrix3DArray; 21 | -------------------------------------------------------------------------------- /packages/happy-dom/src/dom/dom-matrix/TDOMMatrixInit.ts: -------------------------------------------------------------------------------- 1 | import IDOMMatrixCompatibleObject from './IDOMMatrixCompatibleObject.js'; 2 | 3 | type TDOMMatrixInit = string | any[] | IDOMMatrixCompatibleObject | Float32Array | Float64Array; 4 | export default TDOMMatrixInit; 5 | -------------------------------------------------------------------------------- /packages/happy-dom/src/event/DataTransferItemList.ts: -------------------------------------------------------------------------------- 1 | import File from '../file/File.js'; 2 | import DataTransferItem from './DataTransferItem.js'; 3 | 4 | /** 5 | * 6 | */ 7 | export default class DataTransferItemList extends Array { 8 | /** 9 | * Adds an item. 10 | * 11 | * @param item Item. 12 | * @param type Type. 13 | */ 14 | public add(item: File | string, type?: string): void { 15 | if (item instanceof File) { 16 | this.push(new DataTransferItem(item)); 17 | return; 18 | } 19 | if (!type) { 20 | throw new TypeError( 21 | `Failed to execute 'add' on 'DataTransferItemList': parameter 1 is not of type 'File'.` 22 | ); 23 | } 24 | this.push(new DataTransferItem(item, type)); 25 | } 26 | 27 | /** 28 | * Removes an item. 29 | * 30 | * @param index Index. 31 | */ 32 | public remove(index: number): void { 33 | this.splice(index, 1); 34 | } 35 | 36 | /** 37 | * Clears list. 38 | */ 39 | public clear(): void { 40 | while (this.length) { 41 | this.pop(); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /packages/happy-dom/src/event/EventPhaseEnum.ts: -------------------------------------------------------------------------------- 1 | enum EventPhaseEnum { 2 | none = 0, 3 | capturing = 1, 4 | atTarget = 2, 5 | bubbling = 3 6 | } 7 | export default EventPhaseEnum; 8 | -------------------------------------------------------------------------------- /packages/happy-dom/src/event/IEventInit.ts: -------------------------------------------------------------------------------- 1 | export default interface IEventInit { 2 | bubbles?: boolean; 3 | cancelable?: boolean; 4 | composed?: boolean; 5 | } 6 | -------------------------------------------------------------------------------- /packages/happy-dom/src/event/IEventListenerOptions.ts: -------------------------------------------------------------------------------- 1 | import AbortSignal from 'src/fetch/AbortSignal.js'; 2 | 3 | export default interface IEventListenerOptions { 4 | once?: boolean; 5 | 6 | // TODO: Not implemented yet. 7 | capture?: boolean; 8 | passive?: boolean; 9 | signal?: AbortSignal; 10 | } 11 | -------------------------------------------------------------------------------- /packages/happy-dom/src/event/ITouchInit.ts: -------------------------------------------------------------------------------- 1 | import EventTarget from './EventTarget.js'; 2 | 3 | export default interface ITouchInit { 4 | identifier: number; 5 | target: EventTarget; 6 | clientX?: number; 7 | clientY?: number; 8 | screenX?: number; 9 | screenY?: number; 10 | pageX?: number; 11 | pageY?: number; 12 | radiusX?: number; 13 | radiusY?: number; 14 | rotationAngle?: number; 15 | force?: number; 16 | } 17 | -------------------------------------------------------------------------------- /packages/happy-dom/src/event/IUIEventInit.ts: -------------------------------------------------------------------------------- 1 | import BrowserWindow from '../window/BrowserWindow.js'; 2 | import IEventInit from './IEventInit.js'; 3 | 4 | export default interface IUIEventInit extends IEventInit { 5 | detail?: number; 6 | view?: BrowserWindow; 7 | } 8 | -------------------------------------------------------------------------------- /packages/happy-dom/src/event/MessagePort.ts: -------------------------------------------------------------------------------- 1 | import EventTarget from './EventTarget.js'; 2 | 3 | /** 4 | * Message port. 5 | * 6 | * @see https://developer.mozilla.org/en-US/docs/Web/API/MessagePort 7 | */ 8 | export default abstract class MessagePort extends EventTarget { 9 | /** 10 | * Sends a message from the port, and optionally, transfers ownership of objects to other browsing contexts. 11 | * 12 | * @param _message Message. 13 | * @param _transerList Transfer list. 14 | */ 15 | public postMessage(_message: unknown, _transerList: unknown[]): void { 16 | // TODO: Implement 17 | } 18 | 19 | /** 20 | * Starts the sending of messages queued on the port. 21 | */ 22 | public start(): void { 23 | // TODO: Implement 24 | } 25 | 26 | /** 27 | * Disconnects the port, so it is no longer active. This stops the flow of messages to that port. 28 | */ 29 | public close(): void { 30 | // TODO: Implement 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /packages/happy-dom/src/event/TEventListener.ts: -------------------------------------------------------------------------------- 1 | import TEventListenerFunction from './TEventListenerFunction.js'; 2 | import TEventListenerObject from './TEventListenerObject.js'; 3 | 4 | type TEventListener = TEventListenerFunction | TEventListenerObject; 5 | 6 | export default TEventListener; 7 | -------------------------------------------------------------------------------- /packages/happy-dom/src/event/TEventListenerFunction.ts: -------------------------------------------------------------------------------- 1 | import Event from './Event.js'; 2 | 3 | type TEventListenerFunction = (event: Event) => void; 4 | 5 | export default TEventListenerFunction; 6 | -------------------------------------------------------------------------------- /packages/happy-dom/src/event/TEventListenerObject.ts: -------------------------------------------------------------------------------- 1 | import Event from './Event.js'; 2 | 3 | type TEventListenerObject = { 4 | handleEvent(event: Event): void; 5 | }; 6 | 7 | export default TEventListenerObject; 8 | -------------------------------------------------------------------------------- /packages/happy-dom/src/event/UIEvent.ts: -------------------------------------------------------------------------------- 1 | import BrowserWindow from '../window/BrowserWindow.js'; 2 | import Event from './Event.js'; 3 | import IUIEventInit from './IUIEventInit.js'; 4 | 5 | /** 6 | * 7 | */ 8 | export default class UIEvent extends Event { 9 | public static NONE = 0; 10 | public static CAPTURING_PHASE = 1; 11 | public static AT_TARGET = 2; 12 | public static BUBBLING_PHASE = 3; 13 | public readonly detail: number; 14 | public readonly layerX: number = 0; 15 | public readonly layerY: number = 0; 16 | public readonly pageX: number = 0; 17 | public readonly pageY: number = 0; 18 | public readonly view: BrowserWindow | null; 19 | 20 | /** 21 | * Constructor. 22 | * 23 | * @param type Event type. 24 | * @param [eventInit] Event init. 25 | */ 26 | constructor(type: string, eventInit: IUIEventInit | null = null) { 27 | super(type, eventInit); 28 | 29 | this.detail = eventInit?.detail ?? 0; 30 | this.view = eventInit?.view ?? null; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /packages/happy-dom/src/event/events/AnimationEvent.ts: -------------------------------------------------------------------------------- 1 | import Event from '../Event.js'; 2 | import IAnimationEventInit from './IAnimationEventInit.js'; 3 | 4 | /** 5 | * 6 | */ 7 | export default class AnimationEvent extends Event { 8 | public readonly animationName: string; 9 | public readonly elapsedTime: number; 10 | public readonly pseudoElement: string; 11 | 12 | /** 13 | * Constructor. 14 | * 15 | * @param type Event type. 16 | * @param [eventInit] Event init. 17 | */ 18 | constructor(type: string, eventInit: IAnimationEventInit | null = null) { 19 | super(type, eventInit); 20 | 21 | this.animationName = eventInit?.animationName ?? ''; 22 | this.elapsedTime = eventInit?.elapsedTime ?? 0; 23 | this.pseudoElement = eventInit?.pseudoElement ?? ''; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /packages/happy-dom/src/event/events/ClipboardEvent.ts: -------------------------------------------------------------------------------- 1 | import DataTransfer from '../DataTransfer.js'; 2 | import Event from '../Event.js'; 3 | import IClipboardEventInit from './IClipboardEventInit.js'; 4 | 5 | /** 6 | * 7 | */ 8 | export default class ClipboardEvent extends Event { 9 | public clipboardData: DataTransfer | null; 10 | 11 | /** 12 | * Constructor. 13 | * 14 | * @param type Event type. 15 | * @param [eventInit] Event init. 16 | */ 17 | constructor(type: string, eventInit: IClipboardEventInit | null = null) { 18 | super(type, eventInit); 19 | 20 | this.clipboardData = eventInit?.clipboardData ?? null; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /packages/happy-dom/src/event/events/ErrorEvent.ts: -------------------------------------------------------------------------------- 1 | import UIEvent from '../UIEvent.js'; 2 | import IErrorEventInit from './IErrorEventInit.js'; 3 | 4 | /** 5 | * 6 | */ 7 | export default class ErrorEvent extends UIEvent { 8 | public readonly message: string; 9 | public readonly filename: string; 10 | public readonly lineno: number; 11 | public readonly colno: number; 12 | public readonly error: Error | null; 13 | 14 | /** 15 | * Constructor. 16 | * 17 | * @param type Event type. 18 | * @param [eventInit] Event init. 19 | */ 20 | constructor(type: string, eventInit: IErrorEventInit | null = null) { 21 | super(type, eventInit); 22 | 23 | this.message = eventInit?.message ?? ''; 24 | this.filename = eventInit?.filename ?? ''; 25 | this.lineno = eventInit?.lineno ?? 0; 26 | this.colno = eventInit?.colno ?? 0; 27 | this.error = eventInit?.error ?? null; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /packages/happy-dom/src/event/events/FocusEvent.ts: -------------------------------------------------------------------------------- 1 | import UIEvent from '../UIEvent.js'; 2 | import EventTarget from '../EventTarget.js'; 3 | import IFocusEventInit from './IFocusEventInit.js'; 4 | 5 | /** 6 | * 7 | */ 8 | export default class FocusEvent extends UIEvent { 9 | public readonly relatedTarget: EventTarget | null; 10 | 11 | /** 12 | * Constructor. 13 | * 14 | * @param type Event type. 15 | * @param [eventInit] Event init. 16 | */ 17 | constructor(type: string, eventInit: IFocusEventInit | null = null) { 18 | super(type, eventInit); 19 | 20 | this.relatedTarget = eventInit?.relatedTarget ?? null; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /packages/happy-dom/src/event/events/HashChangeEvent.ts: -------------------------------------------------------------------------------- 1 | import Event from '../Event.js'; 2 | import IHashChangeEventInit from './IHashChangeEventInit.js'; 3 | 4 | /** 5 | * Hash change event. 6 | * 7 | * @see https://developer.mozilla.org/en-US/docs/Web/API/HashChangeEvent 8 | */ 9 | export default class HashChangeEvent extends Event { 10 | public readonly newURL: string; 11 | public readonly oldURL: string; 12 | 13 | /** 14 | * Constructor. 15 | * 16 | * @param type Event type. 17 | * @param [eventInit] Event init. 18 | */ 19 | constructor(type: string, eventInit: IHashChangeEventInit | null = null) { 20 | super(type, eventInit); 21 | 22 | this.newURL = eventInit?.newURL ?? ''; 23 | this.oldURL = eventInit?.oldURL ?? ''; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /packages/happy-dom/src/event/events/IAnimationEventInit.ts: -------------------------------------------------------------------------------- 1 | import IEventInit from '../IEventInit.js'; 2 | 3 | export default interface IAnimationEventInit extends IEventInit { 4 | animationName?: string; 5 | elapsedTime?: number; 6 | pseudoElement?: string; 7 | } 8 | -------------------------------------------------------------------------------- /packages/happy-dom/src/event/events/IClipboardEventInit.ts: -------------------------------------------------------------------------------- 1 | import DataTransfer from '../DataTransfer.js'; 2 | import IEventInit from '../IEventInit.js'; 3 | 4 | export default interface IClipboardEventInit extends IEventInit { 5 | clipboardData?: DataTransfer | null; 6 | } 7 | -------------------------------------------------------------------------------- /packages/happy-dom/src/event/events/ICustomEventInit.ts: -------------------------------------------------------------------------------- 1 | import IEventInit from '../IEventInit.js'; 2 | 3 | export default interface ICustomEventInit extends IEventInit { 4 | detail?: object | null; 5 | } 6 | -------------------------------------------------------------------------------- /packages/happy-dom/src/event/events/IErrorEventInit.ts: -------------------------------------------------------------------------------- 1 | import IEventInit from '../IEventInit.js'; 2 | export default interface IErrorEventInit extends IEventInit { 3 | message?: string; 4 | filename?: string; 5 | lineno?: number; 6 | colno?: number; 7 | error?: Error; 8 | } 9 | -------------------------------------------------------------------------------- /packages/happy-dom/src/event/events/IFocusEventInit.ts: -------------------------------------------------------------------------------- 1 | import EventTarget from '../EventTarget.js'; 2 | import IUIEventInit from '../IUIEventInit.js'; 3 | 4 | export default interface IFocusEventInit extends IUIEventInit { 5 | relatedTarget?: EventTarget; 6 | } 7 | -------------------------------------------------------------------------------- /packages/happy-dom/src/event/events/IHashChangeEventInit.ts: -------------------------------------------------------------------------------- 1 | import IEventInit from '../IEventInit.js'; 2 | 3 | export default interface IHashChangeEventInit extends IEventInit { 4 | newURL?: string; 5 | oldURL?: string; 6 | } 7 | -------------------------------------------------------------------------------- /packages/happy-dom/src/event/events/IInputEventInit.ts: -------------------------------------------------------------------------------- 1 | import DataTransfer from '../DataTransfer.js'; 2 | import IUIEventInit from '../IUIEventInit.js'; 3 | 4 | export default interface IInputEventInit extends IUIEventInit { 5 | inputType?: string; 6 | data?: string; 7 | dataTransfer?: DataTransfer; 8 | isComposing?: boolean; 9 | } 10 | -------------------------------------------------------------------------------- /packages/happy-dom/src/event/events/IKeyboardEventInit.ts: -------------------------------------------------------------------------------- 1 | import IUIEventInit from '../IUIEventInit.js'; 2 | 3 | export default interface IKeyboardEventInit extends IUIEventInit { 4 | key?: string; 5 | code?: string; 6 | location?: number; 7 | ctrlKey?: boolean; 8 | shiftKey?: boolean; 9 | altKey?: boolean; 10 | metaKey?: boolean; 11 | repeat?: boolean; 12 | isComposing?: boolean; 13 | 14 | /** 15 | * @deprecated 16 | */ 17 | keyCode?: number; 18 | } 19 | -------------------------------------------------------------------------------- /packages/happy-dom/src/event/events/IMediaQueryListEventInit.ts: -------------------------------------------------------------------------------- 1 | import MediaStreamTrack from '../../nodes/html-media-element/MediaStreamTrack.js'; 2 | import IEventInit from '../IEventInit.js'; 3 | 4 | export default interface IMediaQueryListEventInit extends IEventInit { 5 | track?: MediaStreamTrack; 6 | } 7 | -------------------------------------------------------------------------------- /packages/happy-dom/src/event/events/IMediaQueryListInit.ts: -------------------------------------------------------------------------------- 1 | import IEventInit from '../IEventInit.js'; 2 | 3 | export default interface IMediaQueryListInit extends IEventInit { 4 | matches?: boolean; 5 | media?: string; 6 | } 7 | -------------------------------------------------------------------------------- /packages/happy-dom/src/event/events/IMessageEventInit.ts: -------------------------------------------------------------------------------- 1 | import IEventInit from '../IEventInit.js'; 2 | import BrowserWindow from '../../window/BrowserWindow.js'; 3 | import MessagePort from '../MessagePort.js'; 4 | 5 | export default interface IMessageEventInit extends IEventInit { 6 | data?: unknown | null; 7 | origin?: string; 8 | lastEventId?: string; 9 | source?: BrowserWindow | null; 10 | ports?: MessagePort[]; 11 | } 12 | -------------------------------------------------------------------------------- /packages/happy-dom/src/event/events/IMouseEventInit.ts: -------------------------------------------------------------------------------- 1 | import EventTarget from '../EventTarget.js'; 2 | import IUIEventInit from '../IUIEventInit.js'; 3 | 4 | export default interface IMouseEventInit extends IUIEventInit { 5 | screenX?: number; 6 | screenY?: number; 7 | clientX?: number; 8 | clientY?: number; 9 | ctrlKey?: boolean; 10 | shiftKey?: boolean; 11 | altKey?: boolean; 12 | metaKey?: boolean; 13 | movementX?: number; 14 | movementY?: number; 15 | button?: number; 16 | buttons?: number; 17 | relatedTarget?: EventTarget; 18 | region?: string; 19 | } 20 | -------------------------------------------------------------------------------- /packages/happy-dom/src/event/events/IPointerEventInit.ts: -------------------------------------------------------------------------------- 1 | import IMouseEventInit from './IMouseEventInit.js'; 2 | import PointerEvent from './PointerEvent.js'; 3 | 4 | export default interface IPointerEventInit extends IMouseEventInit { 5 | pointerId?: number; 6 | width?: number; 7 | height?: number; 8 | pressure?: number; 9 | tangentialPressure?: number; 10 | tiltX?: number; 11 | tiltY?: number; 12 | twist?: number; 13 | altitudeAngle?: number; 14 | azimuthAngle?: number; 15 | pointerType?: string; 16 | isPrimary?: boolean; 17 | coalescedEvents?: PointerEvent[]; 18 | predictedEvents?: PointerEvent[]; 19 | } 20 | -------------------------------------------------------------------------------- /packages/happy-dom/src/event/events/IProgressEventInit.ts: -------------------------------------------------------------------------------- 1 | import IEventInit from '../IEventInit.js'; 2 | 3 | export default interface IProgressEventInit extends IEventInit { 4 | lengthComputable?: boolean; 5 | loaded?: number; 6 | total?: number; 7 | } 8 | -------------------------------------------------------------------------------- /packages/happy-dom/src/event/events/IStorageEventInit.ts: -------------------------------------------------------------------------------- 1 | import IEventInit from '../IEventInit.js'; 2 | import Storage from '../../storage/Storage.js'; 3 | 4 | export default interface IStorageEventInit extends IEventInit { 5 | key?: string; 6 | oldValue?: string; 7 | newValue?: string; 8 | url?: string; 9 | storageArea?: Storage; 10 | } 11 | -------------------------------------------------------------------------------- /packages/happy-dom/src/event/events/ISubmitEventInit.ts: -------------------------------------------------------------------------------- 1 | import HTMLElement from '../../nodes/html-element/HTMLElement.js'; 2 | import IEventInit from '../IEventInit.js'; 3 | 4 | export default interface ISubmitEventInit extends IEventInit { 5 | submitter?: HTMLElement; 6 | } 7 | -------------------------------------------------------------------------------- /packages/happy-dom/src/event/events/ITouchEventInit.ts: -------------------------------------------------------------------------------- 1 | import IUIEventInit from '../IUIEventInit.js'; 2 | import Touch from '../Touch.js'; 3 | 4 | export default interface ITouchEventInit extends IUIEventInit { 5 | touches?: Touch[] | null; 6 | targetTouches?: Touch[] | null; 7 | changedTouches?: Touch[] | null; 8 | ctrlKey?: boolean | null; 9 | shiftKey?: boolean | null; 10 | altKey?: boolean | null; 11 | metaKey?: boolean | null; 12 | } 13 | -------------------------------------------------------------------------------- /packages/happy-dom/src/event/events/IWheelEventInit.ts: -------------------------------------------------------------------------------- 1 | import IUIEventInit from '../IUIEventInit.js'; 2 | 3 | export default interface IWheelEventInit extends IUIEventInit { 4 | deltaX?: number; 5 | deltaY?: number; 6 | deltaZ?: number; 7 | deltaMode?: number; 8 | } 9 | -------------------------------------------------------------------------------- /packages/happy-dom/src/event/events/InputEvent.ts: -------------------------------------------------------------------------------- 1 | import DataTransfer from '../DataTransfer.js'; 2 | import UIEvent from '../UIEvent.js'; 3 | import IInputEventInit from './IInputEventInit.js'; 4 | 5 | /** 6 | * 7 | */ 8 | export default class InputEvent extends UIEvent { 9 | public readonly data: string; 10 | public readonly dataTransfer: DataTransfer; 11 | public readonly inputType: string; 12 | public readonly isComposing: boolean; 13 | 14 | /** 15 | * Constructor. 16 | * 17 | * @param type Event type. 18 | * @param [eventInit] Event init. 19 | */ 20 | constructor(type: string, eventInit: IInputEventInit | null = null) { 21 | super(type, eventInit); 22 | 23 | this.data = eventInit?.data ?? ''; 24 | this.dataTransfer = eventInit?.dataTransfer ?? null; 25 | this.inputType = eventInit?.inputType ?? ''; 26 | this.isComposing = eventInit?.isComposing ?? false; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /packages/happy-dom/src/event/events/MediaQueryListEvent.ts: -------------------------------------------------------------------------------- 1 | import Event from '../Event.js'; 2 | import IMediaQueryListInit from './IMediaQueryListInit.js'; 3 | 4 | /** 5 | * 6 | */ 7 | export default class MediaQueryListEvent extends Event { 8 | public readonly matches: boolean; 9 | public readonly media: string; 10 | 11 | /** 12 | * Constructor. 13 | * 14 | * @param type Event type. 15 | * @param [eventInit] Event init. 16 | */ 17 | constructor(type: string, eventInit: IMediaQueryListInit | null = null) { 18 | super(type, eventInit); 19 | 20 | this.matches = eventInit?.matches ?? false; 21 | this.media = eventInit?.media ?? ''; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /packages/happy-dom/src/event/events/MediaStreamTrackEvent.ts: -------------------------------------------------------------------------------- 1 | import MediaStreamTrack from '../../nodes/html-media-element/MediaStreamTrack.js'; 2 | import Event from '../Event.js'; 3 | import IMediaQueryListEventInit from './IMediaQueryListEventInit.js'; 4 | 5 | /** 6 | * Media Stream Track Event. 7 | */ 8 | export default class MediaStreamTrackEvent extends Event { 9 | public readonly track: MediaStreamTrack | null; 10 | 11 | /** 12 | * Constructor. 13 | * 14 | * @param type Event type. 15 | * @param [eventInit] Event init. 16 | */ 17 | constructor(type: string, eventInit: IMediaQueryListEventInit | null = null) { 18 | super(type, eventInit); 19 | 20 | this.track = eventInit?.track ?? null; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /packages/happy-dom/src/event/events/MessageEvent.ts: -------------------------------------------------------------------------------- 1 | import BrowserWindow from '../../window/BrowserWindow.js'; 2 | import Event from '../Event.js'; 3 | import MessagePort from '../MessagePort.js'; 4 | import IMessageEventInit from './IMessageEventInit.js'; 5 | 6 | /** 7 | * Message event. 8 | * 9 | * @see https://developer.mozilla.org/en-US/docs/Web/API/MessageEvent 10 | */ 11 | export default class MessageEvent extends Event { 12 | public readonly data: unknown | null; 13 | public readonly origin: string; 14 | public readonly lastEventId: string; 15 | public readonly source: BrowserWindow | null; 16 | public readonly ports: MessagePort[]; 17 | 18 | /** 19 | * Constructor. 20 | * 21 | * @param type Event type. 22 | * @param [eventInit] Event init. 23 | */ 24 | constructor(type: string, eventInit: IMessageEventInit | null = null) { 25 | super(type, eventInit); 26 | 27 | this.data = eventInit?.data ?? null; 28 | this.origin = eventInit?.origin ?? ''; 29 | this.lastEventId = eventInit?.lastEventId ?? ''; 30 | this.source = eventInit?.source ?? null; 31 | this.ports = eventInit?.ports ?? []; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /packages/happy-dom/src/event/events/ProgressEvent.ts: -------------------------------------------------------------------------------- 1 | import Event from '../Event.js'; 2 | import IProgressEventInit from './IProgressEventInit.js'; 3 | 4 | /** 5 | * 6 | */ 7 | export default class ProgressEvent extends Event { 8 | public readonly lengthComputable: boolean; 9 | public readonly loaded: number; 10 | public readonly total: number; 11 | 12 | /** 13 | * Constructor. 14 | * 15 | * @param type Event type. 16 | * @param [eventInit] Event init. 17 | */ 18 | constructor(type: string, eventInit: IProgressEventInit | null = null) { 19 | super(type); 20 | 21 | this.lengthComputable = eventInit?.lengthComputable ?? false; 22 | this.loaded = eventInit?.loaded ?? 0; 23 | this.total = eventInit?.total ?? 0; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /packages/happy-dom/src/event/events/StorageEvent.ts: -------------------------------------------------------------------------------- 1 | import Event from '../Event.js'; 2 | import IStorageEventInit from './IStorageEventInit.js'; 3 | import Storage from '../../storage/Storage.js'; 4 | 5 | /** 6 | * 7 | */ 8 | export default class StorageEvent extends Event { 9 | public readonly key: string | null; 10 | public readonly oldValue: string | null; 11 | public readonly newValue: string | null; 12 | public readonly url: string; 13 | public readonly storageArea: Storage | null; 14 | 15 | /** 16 | * Constructor. 17 | * 18 | * @param type Event type. 19 | * @param [eventInit] Event init. 20 | */ 21 | constructor(type: string, eventInit: IStorageEventInit | null = null) { 22 | super(type); 23 | 24 | this.key = eventInit?.key ?? null; 25 | this.oldValue = eventInit?.oldValue ?? null; 26 | this.newValue = eventInit?.newValue ?? null; 27 | this.url = eventInit?.url ?? ''; 28 | this.storageArea = eventInit?.storageArea ?? null; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /packages/happy-dom/src/event/events/SubmitEvent.ts: -------------------------------------------------------------------------------- 1 | import Event from '../Event.js'; 2 | import ISubmitEventInit from './ISubmitEventInit.js'; 3 | import HTMLElement from '../../nodes/html-element/HTMLElement.js'; 4 | 5 | /** 6 | * An event triggered by form submit buttons. 7 | */ 8 | export default class SubmitEvent extends Event { 9 | public readonly submitter: HTMLElement | null; 10 | 11 | /** 12 | * Constructor. 13 | * 14 | * @param type Event type. 15 | * @param [eventInit] Event init. 16 | */ 17 | constructor(type: string, eventInit: ISubmitEventInit | null = null) { 18 | super(type, eventInit); 19 | 20 | this.submitter = eventInit?.submitter ?? null; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /packages/happy-dom/src/event/events/TouchEvent.ts: -------------------------------------------------------------------------------- 1 | import ITouchEventInit from './ITouchEventInit.js'; 2 | import UIEvent from '../UIEvent.js'; 3 | import Touch from '../Touch.js'; 4 | 5 | /** 6 | * 7 | */ 8 | export default class TouchEvent extends UIEvent { 9 | public readonly altKey: boolean; 10 | public readonly changedTouches: Touch[]; 11 | public readonly ctrlKey: boolean; 12 | public readonly metaKey: boolean; 13 | public readonly shiftKey: boolean; 14 | public readonly targetTouches: Touch[]; 15 | public readonly touches: Touch[]; 16 | 17 | /** 18 | * Constructor. 19 | * 20 | * @param type Event type. 21 | * @param [eventInit] Event init. 22 | */ 23 | constructor(type: string, eventInit: ITouchEventInit | null = null) { 24 | super(type, eventInit); 25 | 26 | this.altKey = eventInit?.altKey ?? false; 27 | this.changedTouches = eventInit?.changedTouches ?? []; 28 | this.ctrlKey = eventInit?.ctrlKey ?? false; 29 | this.metaKey = eventInit?.metaKey ?? false; 30 | this.shiftKey = eventInit?.shiftKey ?? false; 31 | this.targetTouches = eventInit?.targetTouches ?? []; 32 | this.touches = eventInit?.touches ?? []; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /packages/happy-dom/src/event/events/WheelEvent.ts: -------------------------------------------------------------------------------- 1 | import UIEvent from '../UIEvent.js'; 2 | import IWheelEventInit from './IWheelEventInit.js'; 3 | 4 | /** 5 | * 6 | */ 7 | export default class WheelEvent extends UIEvent { 8 | public static DOM_DELTA_PIXEL = 0; 9 | public static DOM_DELTA_LINE = 1; 10 | public static DOM_DELTA_PAGE = 2; 11 | public readonly deltaX: number; 12 | public readonly deltaY: number; 13 | public readonly deltaZ: number; 14 | public readonly deltaMode: number; 15 | 16 | /** 17 | * Constructor. 18 | * 19 | * @param type Event type. 20 | * @param [eventInit] Event init. 21 | */ 22 | constructor(type: string, eventInit: IWheelEventInit | null = null) { 23 | super(type, eventInit); 24 | 25 | this.deltaX = eventInit?.deltaX ?? 0; 26 | this.deltaY = eventInit?.deltaY ?? 0; 27 | this.deltaZ = eventInit?.deltaZ ?? 0; 28 | this.deltaMode = eventInit?.deltaMode ?? 0; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /packages/happy-dom/src/exception/DOMException.ts: -------------------------------------------------------------------------------- 1 | import DOMExceptionNameEnum from './DOMExceptionNameEnum.js'; 2 | 3 | /** 4 | * DOM Exception. 5 | * 6 | * Reference: 7 | * https://developer.mozilla.org/en-US/docs/Web/API/DOMException/DOMException. 8 | */ 9 | export default class DOMException extends Error { 10 | /** 11 | * Constructor. 12 | * 13 | * @param message Message. 14 | * @param name Name. 15 | */ 16 | constructor(message: string, name: string = null) { 17 | super(message); 18 | 19 | this.name = name || DOMExceptionNameEnum.domException; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /packages/happy-dom/src/exception/DOMExceptionNameEnum.ts: -------------------------------------------------------------------------------- 1 | enum DOMExceptionNameEnum { 2 | invalidStateError = 'InvalidStateError', 3 | indexSizeError = 'IndexSizeError', 4 | syntaxError = 'SyntaxError', 5 | hierarchyRequestError = 'HierarchyRequestError', 6 | notSupportedError = 'NotSupportedError', 7 | wrongDocumentError = 'WrongDocumentError', 8 | invalidNodeTypeError = 'InvalidNodeTypeError', 9 | invalidCharacterError = 'InvalidCharacterError', 10 | notFoundError = 'NotFoundError', 11 | securityError = 'SecurityError', 12 | networkError = 'NetworkError', 13 | domException = 'DOMException', 14 | invalidAccessError = 'InvalidAccessError', 15 | unknownError = 'UnknownError', 16 | abortError = 'AbortError', 17 | timeoutError = 'TimeoutError', 18 | encodingError = 'EncodingError', 19 | uriMismatchError = 'URIMismatchError', 20 | inUseAttributeError = 'InUseAttributeError', 21 | namespaceError = 'NamespaceError' 22 | } 23 | export default DOMExceptionNameEnum; 24 | -------------------------------------------------------------------------------- /packages/happy-dom/src/fetch/AbortController.ts: -------------------------------------------------------------------------------- 1 | import AbortSignal from './AbortSignal.js'; 2 | import * as PropertySymbol from '../PropertySymbol.js'; 3 | import BrowserWindow from '../window/BrowserWindow.js'; 4 | 5 | /** 6 | * AbortController. 7 | * 8 | * @see https://developer.mozilla.org/en-US/docs/Web/API/AbortController 9 | */ 10 | export default class AbortController { 11 | // Injected by WindowContextClassExtender 12 | protected declare [PropertySymbol.window]: BrowserWindow; 13 | 14 | // Public properties 15 | public readonly signal: AbortSignal = new this[PropertySymbol.window].AbortSignal(); 16 | 17 | /** 18 | * Aborts the signal. 19 | * 20 | * @param [reason] Reason. 21 | */ 22 | public abort(reason?: any): void { 23 | this.signal[PropertySymbol.abort](reason); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /packages/happy-dom/src/fetch/cache/preflight/ICachablePreflightRequest.ts: -------------------------------------------------------------------------------- 1 | import Headers from '../../Headers.js'; 2 | 3 | export default interface ICachablePreflightRequest { 4 | url: string; 5 | method: string; 6 | headers: Headers; 7 | } 8 | -------------------------------------------------------------------------------- /packages/happy-dom/src/fetch/cache/preflight/ICachablePreflightResponse.ts: -------------------------------------------------------------------------------- 1 | import Headers from '../../Headers.js'; 2 | 3 | export default interface ICachablePreflightResponse { 4 | status: number; 5 | url: string; 6 | headers: Headers; 7 | } 8 | -------------------------------------------------------------------------------- /packages/happy-dom/src/fetch/cache/preflight/ICachedPreflightResponse.ts: -------------------------------------------------------------------------------- 1 | export default interface ICachedPreflightResponse { 2 | allowOrigin: string; 3 | allowMethods: string[]; 4 | expires: number; 5 | } 6 | -------------------------------------------------------------------------------- /packages/happy-dom/src/fetch/cache/preflight/IPreflightResponseCache.ts: -------------------------------------------------------------------------------- 1 | import ICachedPreflightResponse from './ICachedPreflightResponse.js'; 2 | import ICachablePreflightRequest from './ICachablePreflightRequest.js'; 3 | import ICachablePreflightResponse from './ICachablePreflightResponse.js'; 4 | 5 | /** 6 | * Fetch response cache. 7 | */ 8 | export default interface IPreflightResponseCache { 9 | /** 10 | * Returns cached response. 11 | * 12 | * @param request Request. 13 | * @returns Cached response. 14 | */ 15 | get(request: ICachablePreflightRequest): ICachedPreflightResponse | null; 16 | 17 | /** 18 | * Adds a cached response. 19 | * 20 | * @param request Request. 21 | * @param response Response. 22 | * @returns Cached response. 23 | */ 24 | add( 25 | request: ICachablePreflightRequest, 26 | response: ICachablePreflightResponse 27 | ): ICachedPreflightResponse | null; 28 | 29 | /** 30 | * Clears the cache. 31 | */ 32 | clear(): void; 33 | } 34 | -------------------------------------------------------------------------------- /packages/happy-dom/src/fetch/cache/response/CachedResponseStateEnum.ts: -------------------------------------------------------------------------------- 1 | enum CachedResponseStateEnum { 2 | fresh = 'fresh', 3 | stale = 'stale' 4 | } 5 | export default CachedResponseStateEnum; 6 | -------------------------------------------------------------------------------- /packages/happy-dom/src/fetch/cache/response/ICachableRequest.ts: -------------------------------------------------------------------------------- 1 | import Headers from '../../Headers.js'; 2 | 3 | export default interface ICachableRequest { 4 | url: string; 5 | method: string; 6 | headers: Headers; 7 | } 8 | -------------------------------------------------------------------------------- /packages/happy-dom/src/fetch/cache/response/ICachableResponse.ts: -------------------------------------------------------------------------------- 1 | import Headers from '../../Headers.js'; 2 | 3 | export default interface ICachableResponse { 4 | status: number; 5 | statusText: string; 6 | url: string; 7 | headers: Headers; 8 | body: Buffer | null; 9 | waitingForBody: boolean; 10 | } 11 | -------------------------------------------------------------------------------- /packages/happy-dom/src/fetch/cache/response/IResponseCache.ts: -------------------------------------------------------------------------------- 1 | import ICachedResponse from './ICachedResponse.js'; 2 | import ICachableRequest from './ICachableRequest.js'; 3 | import ICachableResponse from './ICachableResponse.js'; 4 | 5 | /** 6 | * Fetch response cache. 7 | */ 8 | export default interface IResponseCache { 9 | /** 10 | * Returns cached response. 11 | * 12 | * @param request Request. 13 | * @returns Cached response. 14 | */ 15 | get(request: ICachableRequest): ICachedResponse | null; 16 | 17 | /** 18 | * Adds a cached response. 19 | * 20 | * @param request Request. 21 | * @param response Response. 22 | * @returns Cached response. 23 | */ 24 | add(request: ICachableRequest, response: ICachableResponse): ICachedResponse | null; 25 | 26 | /** 27 | * Clears the cache. 28 | * 29 | * @param [options] Options. 30 | * @param [options.url] URL. 31 | * @param [options.toTime] Time in MS. 32 | */ 33 | clear(options?: { url?: string; toTime?: number }): void; 34 | } 35 | -------------------------------------------------------------------------------- /packages/happy-dom/src/fetch/preload/PreloadUtility.ts: -------------------------------------------------------------------------------- 1 | import IRequestCredentials from '../types/IRequestCredentials.js'; 2 | import IRequestMode from '../types/IRequestMode.js'; 3 | 4 | /** 5 | * Utility for preloading resources. 6 | * 7 | * @see https://html.spec.whatwg.org/multipage/links.html#link-type-preload 8 | */ 9 | export default class PreloadUtility { 10 | /** 11 | * Returns a key for a preload entry. 12 | * 13 | * @param options Options. 14 | * @param options.url URL. 15 | * @param options.destination Destination. 16 | * @param options.mode Mode. 17 | * @param options.credentialsMode Credentials mode. 18 | * @returns Key. 19 | */ 20 | public static getKey(options: { 21 | url: string; 22 | destination: string; 23 | mode: IRequestMode; 24 | credentialsMode: IRequestCredentials; 25 | }): string { 26 | return JSON.stringify({ 27 | url: options.url, 28 | destination: options.destination, 29 | mode: options.mode, 30 | credentialsMode: options.credentialsMode 31 | }); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /packages/happy-dom/src/fetch/types/IHeadersInit.ts: -------------------------------------------------------------------------------- 1 | import Headers from '../Headers.js'; 2 | 3 | type IHeadersInit = string[][] | { [key: string]: string } | Headers; 4 | 5 | export default IHeadersInit; 6 | -------------------------------------------------------------------------------- /packages/happy-dom/src/fetch/types/IRequestBody.ts: -------------------------------------------------------------------------------- 1 | import { URLSearchParams } from 'url'; 2 | import FormData from '../../form-data/FormData.js'; 3 | import Blob from '../../file/Blob.js'; 4 | import { ReadableStream } from 'stream/web'; 5 | 6 | type IRequestBody = 7 | | ArrayBuffer 8 | | ArrayBufferView 9 | | ReadableStream 10 | | string 11 | | URLSearchParams 12 | | Blob 13 | | FormData 14 | | null; 15 | 16 | export default IRequestBody; 17 | -------------------------------------------------------------------------------- /packages/happy-dom/src/fetch/types/IRequestCredentials.ts: -------------------------------------------------------------------------------- 1 | type IRequestCredentials = 'omit' | 'same-origin' | 'include'; 2 | export default IRequestCredentials; 3 | -------------------------------------------------------------------------------- /packages/happy-dom/src/fetch/types/IRequestInfo.ts: -------------------------------------------------------------------------------- 1 | import URL from '../../url/URL.js'; 2 | import Request from '../Request.js'; 3 | 4 | type IRequestInfo = Request | string | URL; 5 | 6 | export default IRequestInfo; 7 | -------------------------------------------------------------------------------- /packages/happy-dom/src/fetch/types/IRequestInit.ts: -------------------------------------------------------------------------------- 1 | import IHeadersInit from './IHeadersInit.js'; 2 | import AbortSignal from '../AbortSignal.js'; 3 | import URL from '../../url/URL.js'; 4 | import IRequestReferrerPolicy from './IRequestReferrerPolicy.js'; 5 | import IRequestRedirect from './IRequestRedirect.js'; 6 | import IRequestBody from './IRequestBody.js'; 7 | import IRequestCredentials from './IRequestCredentials.js'; 8 | import IRequestMode from './IRequestMode.js'; 9 | 10 | /** 11 | * Fetch request init. 12 | */ 13 | export default interface IRequestInit { 14 | body?: IRequestBody; 15 | headers?: IHeadersInit; 16 | method?: string; 17 | mode?: IRequestMode; 18 | redirect?: IRequestRedirect; 19 | signal?: AbortSignal | null; 20 | referrer?: '' | 'no-referrer' | 'client' | string | URL; 21 | credentials?: IRequestCredentials; 22 | referrerPolicy?: IRequestReferrerPolicy; 23 | } 24 | -------------------------------------------------------------------------------- /packages/happy-dom/src/fetch/types/IRequestMode.ts: -------------------------------------------------------------------------------- 1 | type IRequestMode = 'same-origin' | 'cors' | 'no-cors' | 'navigate' | 'websocket'; 2 | export default IRequestMode; 3 | -------------------------------------------------------------------------------- /packages/happy-dom/src/fetch/types/IRequestRedirect.ts: -------------------------------------------------------------------------------- 1 | type IRequestRedirect = 'follow' | 'error' | 'manual'; 2 | 3 | export default IRequestRedirect; 4 | -------------------------------------------------------------------------------- /packages/happy-dom/src/fetch/types/IRequestReferrerPolicy.ts: -------------------------------------------------------------------------------- 1 | type IRequestReferrerPolicy = 2 | | '' 3 | | 'no-referrer' 4 | | 'no-referrer-when-downgrade' 5 | | 'same-origin' 6 | | 'origin' 7 | | 'strict-origin' 8 | | 'origin-when-cross-origin' 9 | | 'strict-origin-when-cross-origin' 10 | | 'unsafe-url'; 11 | export default IRequestReferrerPolicy; 12 | -------------------------------------------------------------------------------- /packages/happy-dom/src/fetch/types/IResponseBody.ts: -------------------------------------------------------------------------------- 1 | import { ReadableStream } from 'stream/web'; 2 | import { URLSearchParams } from 'url'; 3 | import FormData from '../../form-data/FormData.js'; 4 | import Blob from '../../file/Blob.js'; 5 | 6 | type IResponseBody = 7 | | ArrayBuffer 8 | | ArrayBufferView 9 | | ReadableStream 10 | | string 11 | | URLSearchParams 12 | | Blob 13 | | FormData 14 | | null; 15 | 16 | export default IResponseBody; 17 | -------------------------------------------------------------------------------- /packages/happy-dom/src/fetch/types/IResponseInit.ts: -------------------------------------------------------------------------------- 1 | import IHeadersInit from './IHeadersInit.js'; 2 | 3 | /** 4 | * Response init. 5 | */ 6 | export default interface IResponseInit { 7 | headers?: IHeadersInit | undefined; 8 | status?: number | undefined; 9 | statusText?: string | undefined; 10 | } 11 | -------------------------------------------------------------------------------- /packages/happy-dom/src/fetch/types/ISyncResponse.ts: -------------------------------------------------------------------------------- 1 | import Headers from '../Headers.js'; 2 | 3 | /** 4 | * Fetch response. 5 | * 6 | * @see https://developer.mozilla.org/en-US/docs/Web/API/Response/Response 7 | */ 8 | export default interface ISyncResponse { 9 | status: number; 10 | statusText: string; 11 | ok: boolean; 12 | url: string; 13 | redirected: boolean; 14 | headers: Headers; 15 | body: Buffer; 16 | } 17 | -------------------------------------------------------------------------------- /packages/happy-dom/src/fetch/types/IVirtualServer.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Virtual server used for simulating a server that reads from the file system. 3 | */ 4 | export default interface IVirtualServer { 5 | url: string | RegExp; 6 | directory: string; 7 | } 8 | -------------------------------------------------------------------------------- /packages/happy-dom/src/fetch/utilities/FetchCORSUtility.ts: -------------------------------------------------------------------------------- 1 | import { URL } from 'url'; 2 | 3 | /** 4 | * Fetch CORS utility. 5 | */ 6 | export default class FetchCORSUtility { 7 | /** 8 | * Validates request headers. 9 | * 10 | * @param originURL Origin URL. 11 | * @param targetURL Target URL. 12 | */ 13 | public static isCORS(originURL: URL | string, targetURL: URL | string): boolean { 14 | originURL = typeof originURL === 'string' ? new URL(originURL) : originURL; 15 | targetURL = typeof targetURL === 'string' ? new URL(targetURL) : targetURL; 16 | 17 | if (targetURL.protocol === 'about:' || targetURL.protocol === 'javascript:') { 18 | return false; 19 | } 20 | 21 | return ( 22 | (originURL.hostname !== targetURL.hostname && 23 | !originURL.hostname.endsWith(targetURL.hostname)) || 24 | originURL.protocol !== targetURL.protocol 25 | ); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /packages/happy-dom/src/fetch/utilities/FetchResponseRedirectUtility.ts: -------------------------------------------------------------------------------- 1 | const REDIRECT_STATUS_CODES = [301, 302, 303, 307, 308]; 2 | const MAX_REDIRECT_COUNT = 20; 3 | 4 | /** 5 | * Fetch request validation utility. 6 | */ 7 | export default class FetchResponseRedirectUtility { 8 | /** 9 | * Returns "true" if redirect. 10 | * 11 | * @param statusCode Status code. 12 | * @returns "true" if redirect. 13 | */ 14 | public static isRedirect(statusCode: number): boolean { 15 | return REDIRECT_STATUS_CODES.includes(statusCode); 16 | } 17 | 18 | /** 19 | * Returns "true" if max redirects is reached. 20 | * 21 | * @param redirectCount Redirect count. 22 | * @returns "true" if max redirects is reached. 23 | */ 24 | public static isMaxRedirectsReached(redirectCount: number): boolean { 25 | return redirectCount >= MAX_REDIRECT_COUNT; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /packages/happy-dom/src/file/FileReaderEventTypeEnum.ts: -------------------------------------------------------------------------------- 1 | enum FileReaderEventTypeEnum { 2 | abort = 'abort', 3 | error = 'error', 4 | load = 'load', 5 | loadstart = 'loadstart', 6 | loadend = 'loadend', 7 | progress = 'progress' 8 | } 9 | export default FileReaderEventTypeEnum; 10 | -------------------------------------------------------------------------------- /packages/happy-dom/src/file/FileReaderFormatEnum.ts: -------------------------------------------------------------------------------- 1 | enum FileReaderFormatEnum { 2 | buffer = 'buffer', 3 | binaryString = 'binaryString', 4 | dataURL = 'dataURL', 5 | text = 'text' 6 | } 7 | export default FileReaderFormatEnum; 8 | -------------------------------------------------------------------------------- /packages/happy-dom/src/file/FileReaderReadyStateEnum.ts: -------------------------------------------------------------------------------- 1 | enum FileReaderReadyStateEnum { 2 | empty = 0, 3 | loading = 1, 4 | done = 2 5 | } 6 | export default FileReaderReadyStateEnum; 7 | -------------------------------------------------------------------------------- /packages/happy-dom/src/history/HistoryScrollRestorationEnum.ts: -------------------------------------------------------------------------------- 1 | enum HistoryScrollRestorationEnum { 2 | auto = 'auto', 3 | manual = 'manual' 4 | } 5 | export default HistoryScrollRestorationEnum; 6 | -------------------------------------------------------------------------------- /packages/happy-dom/src/history/IHistoryItem.ts: -------------------------------------------------------------------------------- 1 | import FormData from '../form-data/FormData.js'; 2 | import HistoryScrollRestorationEnum from './HistoryScrollRestorationEnum.js'; 3 | 4 | export default interface IHistoryItem { 5 | title: string | null; 6 | href: string; 7 | state: any | null; 8 | scrollRestoration: HistoryScrollRestorationEnum; 9 | method: string; 10 | formData: FormData | null; 11 | isCurrent: boolean; 12 | } 13 | -------------------------------------------------------------------------------- /packages/happy-dom/src/intersection-observer/IIntersectionObserverInit.ts: -------------------------------------------------------------------------------- 1 | import Element from '../nodes/element/Element.js'; 2 | 3 | export default interface IIntersectionObserverInit { 4 | /** 5 | * A specific ancestor of the target element against which the intersection is to be calculated. 6 | */ 7 | root?: Element; 8 | /** 9 | * A string which specifies a specific property to observe on the intersection target. 10 | */ 11 | rootMargin?: string; 12 | /** 13 | * A list of thresholds, sorted in increasing numeric order, where each threshold is a ratio of intersection area to bounding box area of the target. 14 | */ 15 | threshold?: number | number[]; 16 | } 17 | -------------------------------------------------------------------------------- /packages/happy-dom/src/intersection-observer/IntersectionObserverEntry.ts: -------------------------------------------------------------------------------- 1 | import DOMRect from '../dom/DOMRect.js'; 2 | import Node from '../nodes/node/Node.js'; 3 | 4 | /** 5 | * The IntersectionObserverEntry interface of the Intersection Observer API describes the intersection between the target element and its root container at a specific moment of transition. 6 | * 7 | * @see https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserverEntry 8 | */ 9 | export default class IntersectionObserverEntry { 10 | public readonly boundingClientRect: DOMRect | null = null; 11 | public readonly intersectionRatio: number = 0; 12 | public readonly intersectionRect: DOMRect | null = null; 13 | public readonly isIntersecting: boolean = false; 14 | public readonly rootBounds: DOMRect | null = null; 15 | public readonly target: Node | null = null; 16 | public readonly time: number = 0; 17 | 18 | /** 19 | * Constructor. 20 | * 21 | * @param init Options to initialize the intersection observer entry. 22 | */ 23 | constructor(init?: Partial) { 24 | Object.assign(this, init); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /packages/happy-dom/src/match-media/IMediaQueryRange.ts: -------------------------------------------------------------------------------- 1 | export default interface IMediaQueryRange { 2 | before: { value: string; operator: string }; 3 | type: string; 4 | after: { value: string; operator: string }; 5 | } 6 | -------------------------------------------------------------------------------- /packages/happy-dom/src/match-media/IMediaQueryRule.ts: -------------------------------------------------------------------------------- 1 | export default interface IMediaQueryRule { 2 | name: string; 3 | value: string | null; 4 | } 5 | -------------------------------------------------------------------------------- /packages/happy-dom/src/match-media/MediaQueryTypeEnum.ts: -------------------------------------------------------------------------------- 1 | enum MediaQueryTypeEnum { 2 | all = 'all', 3 | print = 'print', 4 | screen = 'screen' 5 | } 6 | 7 | export default MediaQueryTypeEnum; 8 | -------------------------------------------------------------------------------- /packages/happy-dom/src/module/IECMAScriptModuleCompiledResult.ts: -------------------------------------------------------------------------------- 1 | import IECMAScriptModuleImport from './IECMAScriptModuleImport.js'; 2 | 3 | export default interface IECMAScriptModuleCompiledResult { 4 | imports: IECMAScriptModuleImport[]; 5 | execute: (options: { 6 | dispatchError: (error: Error) => void; 7 | dynamicImport: ( 8 | url: string, 9 | options?: { with?: { type?: string } } 10 | ) => Promise<{ [key: string]: any }>; 11 | imports: Map; 12 | exports: { [key: string]: any }; 13 | }) => void; 14 | } 15 | -------------------------------------------------------------------------------- /packages/happy-dom/src/module/IECMAScriptModuleImport.ts: -------------------------------------------------------------------------------- 1 | export default interface IECMAScriptModuleImport { 2 | url: string; 3 | type: string; 4 | } 5 | -------------------------------------------------------------------------------- /packages/happy-dom/src/module/IModule.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Module interface. 3 | */ 4 | export default interface IModule { 5 | url: URL; 6 | 7 | /** 8 | * Compiles and evaluates the module. 9 | * 10 | * @returns Module exports. 11 | */ 12 | evaluate(): Promise<{ [key: string]: any }>; 13 | 14 | /** 15 | * Compiles and preloads the module and its imports. 16 | * 17 | * @returns Promise. 18 | */ 19 | preload(): Promise; 20 | } 21 | -------------------------------------------------------------------------------- /packages/happy-dom/src/module/IModuleImportMap.ts: -------------------------------------------------------------------------------- 1 | import IModuleImportMapRule from './IModuleImportMapRule.js'; 2 | import IModuleImportMapScope from './IModuleImportMapScope.js'; 3 | 4 | /** 5 | * @see https://html.spec.whatwg.org/multipage/webappapis.html#import-map 6 | */ 7 | export default interface IModuleImportMap { 8 | imports: IModuleImportMapRule[]; 9 | scopes: IModuleImportMapScope[]; 10 | } 11 | -------------------------------------------------------------------------------- /packages/happy-dom/src/module/IModuleImportMapRule.ts: -------------------------------------------------------------------------------- 1 | export default interface IModuleImportMapRule { 2 | from: string; 3 | to: string; 4 | } 5 | -------------------------------------------------------------------------------- /packages/happy-dom/src/module/IModuleImportMapScope.ts: -------------------------------------------------------------------------------- 1 | import IModuleImportMapRule from './IModuleImportMapRule.js'; 2 | 3 | export default interface IModuleImportMapScope { 4 | scope: string; 5 | rules: IModuleImportMapRule[]; 6 | } 7 | -------------------------------------------------------------------------------- /packages/happy-dom/src/mutation-observer/IMutationListener.ts: -------------------------------------------------------------------------------- 1 | import IMutationObserverInit from './IMutationObserverInit.js'; 2 | import MutationRecord from './MutationRecord.js'; 3 | 4 | export default interface IMutationListener { 5 | options: IMutationObserverInit; 6 | callback: WeakRef<(record: MutationRecord) => void>; 7 | } 8 | -------------------------------------------------------------------------------- /packages/happy-dom/src/mutation-observer/IMutationObserverInit.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Mutation observer init configurations. 3 | * 4 | * @see https://developer.mozilla.org/en-US/docs/Web/API/MutationObserverInit 5 | */ 6 | export default interface IMutationObserverInit { 7 | attributeFilter?: string[]; 8 | attributeOldValue?: boolean; 9 | attributes?: boolean; 10 | characterData?: boolean; 11 | characterDataOldValue?: boolean; 12 | childList?: boolean; 13 | subtree?: boolean; 14 | } 15 | -------------------------------------------------------------------------------- /packages/happy-dom/src/mutation-observer/MutationRecord.ts: -------------------------------------------------------------------------------- 1 | import Node from '../nodes/node/Node.js'; 2 | 3 | /** 4 | * MutationRecord is a model for a mutation. 5 | * 6 | * @see https://developer.mozilla.org/en-US/docs/Web/API/MutationRecord 7 | */ 8 | export default class MutationRecord { 9 | public type: string = null; 10 | public target: Node = null; 11 | public addedNodes: Node[] = []; 12 | public removedNodes: Node[] = []; 13 | public previousSibling: Node = null; 14 | public nextSibling: Node = null; 15 | public attributeName: string = null; 16 | public attributeNamespace: string = null; 17 | public oldValue: string = null; 18 | 19 | /** 20 | * Constructor. 21 | * 22 | * @param init Options to initialize the mutation record. 23 | */ 24 | constructor(init?: Partial) { 25 | Object.assign(this, init); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /packages/happy-dom/src/mutation-observer/MutationTypeEnum.ts: -------------------------------------------------------------------------------- 1 | enum MutationTypeEnum { 2 | attributes = 'attributes', 3 | characterData = 'characterData', 4 | childList = 'childList' 5 | } 6 | 7 | export default MutationTypeEnum; 8 | -------------------------------------------------------------------------------- /packages/happy-dom/src/navigator/MimeType.ts: -------------------------------------------------------------------------------- 1 | import Plugin from './Plugin.js'; 2 | 3 | /** 4 | * MimeType. 5 | */ 6 | export default class MimeType { 7 | public readonly description: string; 8 | public readonly enabledPlugin: Plugin; 9 | public readonly suffixes: string; 10 | public readonly type: string; 11 | 12 | /** 13 | * Constructor. 14 | * 15 | * @param description 16 | * @param enabledPlugin 17 | * @param suffixes 18 | * @param type 19 | */ 20 | constructor(description: string, enabledPlugin: Plugin, suffixes: string, type: string) { 21 | this.description = description; 22 | this.enabledPlugin = enabledPlugin; 23 | this.suffixes = suffixes; 24 | this.type = type; 25 | } 26 | 27 | /** 28 | * Returns the object as a string. 29 | * 30 | * @returns String. 31 | */ 32 | public toString(): string { 33 | return '[object MimeType]'; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /packages/happy-dom/src/navigator/MimeTypeArray.ts: -------------------------------------------------------------------------------- 1 | import MimeType from './MimeType.js'; 2 | 3 | /** 4 | * MimeTypeArray. 5 | * 6 | * Reference: 7 | * https://developer.mozilla.org/en-US/docs/Web/API/MimeTypeArray. 8 | */ 9 | export default class MimeTypeArray { 10 | [n: number]: MimeType; 11 | public readonly length: number; 12 | 13 | /** 14 | * Constructor. 15 | * 16 | * @param mimeTypes 17 | */ 18 | constructor(mimeTypes: MimeType[]) { 19 | for (let i = 0, max = mimeTypes.length; i < max; i++) { 20 | this[i] = mimeTypes[i]; 21 | this[mimeTypes[i].type] = mimeTypes[i]; 22 | } 23 | this.length = mimeTypes.length; 24 | } 25 | 26 | /** 27 | * @param index 28 | */ 29 | public item(index: number): MimeType { 30 | return this[index] || null; 31 | } 32 | 33 | /** 34 | * @param name 35 | */ 36 | public namedItem(name: string): MimeType { 37 | return this[name] || null; 38 | } 39 | 40 | /** 41 | * Returns the object as a string. 42 | * 43 | * @returns String. 44 | */ 45 | public toString(): string { 46 | return '[object MimeTypeArray]'; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/NodeFactory.ts: -------------------------------------------------------------------------------- 1 | import Document from '../nodes/document/Document.js'; 2 | import Node from './node/Node.js'; 3 | import * as PropertySymbol from '../PropertySymbol.js'; 4 | 5 | /** 6 | * Node factory used for setting the owner document to nodes. 7 | */ 8 | export default class NodeFactory { 9 | public static ownerDocuments: Document[] = []; 10 | 11 | /** 12 | * Creates a node instance with the given owner document. 13 | * 14 | * @param ownerDocument Owner document. 15 | * @param nodeClass Node class. 16 | * @param [args] Node arguments. 17 | * @returns Node instance. 18 | */ 19 | public static createNode( 20 | ownerDocument: Document, 21 | nodeClass: new (...args) => T, 22 | ...args: any[] 23 | ): T { 24 | if (!nodeClass.prototype[PropertySymbol.window]) { 25 | this.ownerDocuments.push(ownerDocument); 26 | } 27 | return new nodeClass(...args); 28 | } 29 | 30 | /** 31 | * Pulls an owner document from the queue. 32 | * 33 | * @returns Document. 34 | */ 35 | public static pullOwnerDocument(): Document { 36 | return this.ownerDocuments.pop(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/child-node/IChildNode.ts: -------------------------------------------------------------------------------- 1 | import Node from '../node/Node.js'; 2 | 3 | export default interface IChildNode extends Node { 4 | /** 5 | * Removes the node from its parent. 6 | */ 7 | remove(): void; 8 | 9 | /** 10 | * Inserts a set of Node or DOMString objects in the children list of this ChildNode's parent, just before this ChildNode. DOMString objects are inserted as equivalent Text nodes. 11 | * 12 | * @param nodes List of Node or DOMString. 13 | */ 14 | before(...nodes: (Node | string)[]): void; 15 | 16 | /** 17 | * Inserts a set of Node or DOMString objects in the children list of this ChildNode's parent, just after this ChildNode. DOMString objects are inserted as equivalent Text nodes. 18 | * 19 | * @param nodes List of Node or DOMString. 20 | */ 21 | after(...nodes: (Node | string)[]): void; 22 | 23 | /** 24 | * The Node.replaceWith() method replaces this Node in the children list of its parent with a set of Node or DOMString objects. 25 | * 26 | * @param nodes List of Node or DOMString. 27 | */ 28 | replaceWith(...nodes: (Node | string)[]): void; 29 | } 30 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/child-node/INonDocumentTypeChildNode.ts: -------------------------------------------------------------------------------- 1 | import Element from '../element/Element.js'; 2 | import Node from '../node/Node.js'; 3 | 4 | export default interface INonDocumentTypeChildNode extends Node { 5 | readonly previousElementSibling: Element; 6 | readonly nextElementSibling: Element; 7 | } 8 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/comment/Comment.ts: -------------------------------------------------------------------------------- 1 | import CharacterData from '../character-data/CharacterData.js'; 2 | import * as PropertySymbol from '../../PropertySymbol.js'; 3 | import NodeTypeEnum from '../node/NodeTypeEnum.js'; 4 | 5 | /** 6 | * Comment node. 7 | */ 8 | export default class Comment extends CharacterData { 9 | public [PropertySymbol.nodeType] = NodeTypeEnum.commentNode; 10 | public declare cloneNode: (deep?: boolean) => Comment; 11 | 12 | /** 13 | * Node name. 14 | * 15 | * @returns Node name. 16 | */ 17 | public get nodeName(): string { 18 | return '#comment'; 19 | } 20 | 21 | /** 22 | * Converts to string. 23 | * 24 | * @returns String. 25 | */ 26 | public toString(): string { 27 | return '[object Comment]'; 28 | } 29 | 30 | /** 31 | * @override 32 | */ 33 | public override [PropertySymbol.cloneNode](deep = false): Comment { 34 | return super[PropertySymbol.cloneNode](deep); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/document/DocumentReadyStateEnum.ts: -------------------------------------------------------------------------------- 1 | enum DocumentReadyStateEnum { 2 | loading = 'loading', 3 | interactive = 'interactive', 4 | complete = 'complete' 5 | } 6 | export default DocumentReadyStateEnum; 7 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/document/VisibilityStateEnum.ts: -------------------------------------------------------------------------------- 1 | enum VisibilityStateEnum { 2 | hidden = 'hidden', 3 | visible = 'visible', 4 | prerender = 'prerender' 5 | } 6 | export default VisibilityStateEnum; 7 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/element/THTMLCollectionListener.ts: -------------------------------------------------------------------------------- 1 | type THTMLCollectionListener = (details: { 2 | index?: number; 3 | item?: T; 4 | propertyName?: string; 5 | propertyValue?: any; 6 | }) => void; 7 | export default THTMLCollectionListener; 8 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/element/TNamedNodeMapListener.ts: -------------------------------------------------------------------------------- 1 | import Attr from '../attr/Attr.js'; 2 | 3 | type TNamedNodeMapListener = (attribute: Attr, replacedAttribute?: Attr | null) => void; 4 | export default TNamedNodeMapListener; 5 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/html-audio-element/Audio.ts: -------------------------------------------------------------------------------- 1 | import NamespaceURI from '../../config/NamespaceURI.js'; 2 | import HTMLAudioElement from './HTMLAudioElement.js'; 3 | import * as PropertySymbol from '../../PropertySymbol.js'; 4 | 5 | /** 6 | * Image as constructor. 7 | * 8 | * Reference: 9 | * https://developer.mozilla.org/en-US/docs/Web/API/HTMLAudioElement/Audio. 10 | */ 11 | export default class Audio extends HTMLAudioElement { 12 | public [PropertySymbol.tagName] = 'AUDIO'; 13 | public [PropertySymbol.localName] = 'audio'; 14 | public [PropertySymbol.namespaceURI] = NamespaceURI.html; 15 | 16 | /** 17 | * Constructor. 18 | * 19 | * @param [url] source URL. 20 | */ 21 | constructor(url: string = null) { 22 | super(); 23 | 24 | if (url !== null) { 25 | this.src = url; 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/html-audio-element/HTMLAudioElement.ts: -------------------------------------------------------------------------------- 1 | import HTMLMediaElement from '../html-media-element/HTMLMediaElement.js'; 2 | 3 | /** 4 | * HTML Audio Element. 5 | * 6 | * Reference: 7 | * https://developer.mozilla.org/en-US/docs/Web/API/HTMLAudioElement. 8 | * 9 | */ 10 | export default class HTMLAudioElement extends HTMLMediaElement {} 11 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/html-br-element/HTMLBRElement.ts: -------------------------------------------------------------------------------- 1 | import HTMLElement from '../html-element/HTMLElement.js'; 2 | /** 3 | * HTMLBRElement 4 | * 5 | * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLBRElement 6 | */ 7 | export default class HTMLBRElement extends HTMLElement {} 8 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/html-canvas-element/ImageBitmap.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Image Bitmap. 3 | * 4 | * @see https://developer.mozilla.org/en-US/docs/Web/API/ImageBitmap 5 | */ 6 | export default class ImageBitmap { 7 | public height: number; 8 | public width: number; 9 | 10 | /** 11 | * Constructor. 12 | * 13 | * @param width Width. 14 | * @param height Height. 15 | */ 16 | constructor(width: number, height: number) { 17 | this.width = width; 18 | this.height = height; 19 | } 20 | 21 | /** 22 | * Disposes of all graphical resources associated with an ImageBitmap. 23 | */ 24 | public close(): void { 25 | // TODO: Not implemented. 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/html-d-list-element/HTMLDListElement.ts: -------------------------------------------------------------------------------- 1 | import HTMLElement from '../html-element/HTMLElement.js'; 2 | /** 3 | * HTMLDListElement 4 | * 5 | * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLDListElement 6 | */ 7 | export default class HTMLDListElement extends HTMLElement {} 8 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/html-data-element/HTMLDataElement.ts: -------------------------------------------------------------------------------- 1 | import HTMLElement from '../html-element/HTMLElement.js'; 2 | /** 3 | * HTMLDataElement 4 | * 5 | * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLDataElement 6 | */ 7 | export default class HTMLDataElement extends HTMLElement { 8 | /** 9 | * Returns value. 10 | * 11 | * @returns Value. 12 | */ 13 | public get value(): string { 14 | return this.getAttribute('value') || ''; 15 | } 16 | 17 | /** 18 | * Sets value. 19 | * 20 | * @param value Value. 21 | */ 22 | public set value(value: string) { 23 | this.setAttribute('value', value); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/html-data-list-element/HTMLDataListElement.ts: -------------------------------------------------------------------------------- 1 | import HTMLElement from '../html-element/HTMLElement.js'; 2 | import * as PropertySymbol from '../../PropertySymbol.js'; 3 | import HTMLCollection from '../element/HTMLCollection.js'; 4 | import HTMLOptionElement from '../html-option-element/HTMLOptionElement.js'; 5 | import ParentNodeUtility from '../parent-node/ParentNodeUtility.js'; 6 | 7 | /** 8 | * HTMLDataListElement 9 | * 10 | * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLDataListElement 11 | */ 12 | export default class HTMLDataListElement extends HTMLElement { 13 | public [PropertySymbol.options]: HTMLCollection | null = null; 14 | 15 | /** 16 | * Returns options. 17 | * 18 | * @returns Options. 19 | */ 20 | public get options(): HTMLCollection { 21 | if (!this[PropertySymbol.options]) { 22 | this[PropertySymbol.options] = >( 23 | ParentNodeUtility.getElementsByTagName(this, 'OPTION') 24 | ); 25 | } 26 | return this[PropertySymbol.options]; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/html-div-element/HTMLDivElement.ts: -------------------------------------------------------------------------------- 1 | import HTMLElement from '../html-element/HTMLElement.js'; 2 | /** 3 | * HTMLDivElement 4 | * 5 | * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLDivElement 6 | */ 7 | export default class HTMLDivElement extends HTMLElement {} 8 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/html-form-element/RadioNodeList.ts: -------------------------------------------------------------------------------- 1 | import HTMLInputElement from '../html-input-element/HTMLInputElement.js'; 2 | import NodeList from '../node/NodeList.js'; 3 | import THTMLFormControlElement from './THTMLFormControlElement.js'; 4 | import * as PropertySymbol from '../../PropertySymbol.js'; 5 | 6 | /** 7 | * RadioNodeList 8 | * 9 | * @see https://developer.mozilla.org/en-US/docs/Web/API/RadioNodeList 10 | */ 11 | export default class RadioNodeList extends NodeList { 12 | /** 13 | * Returns value. 14 | * 15 | * @returns Value. 16 | */ 17 | public get value(): string { 18 | for (const node of this[PropertySymbol.items]) { 19 | if ((node).checked) { 20 | return (node).value; 21 | } 22 | } 23 | return null; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/html-form-element/THTMLFormControlElement.ts: -------------------------------------------------------------------------------- 1 | import HTMLButtonElement from '../html-button-element/HTMLButtonElement.js'; 2 | import HTMLFieldSetElement from '../html-field-set-element/HTMLFieldSetElement.js'; 3 | import HTMLInputElement from '../html-input-element/HTMLInputElement.js'; 4 | import HTMLObjectElement from '../html-object-element/HTMLObjectElement.js'; 5 | import HTMLOutputElement from '../html-output-element/HTMLOutputElement.js'; 6 | import HTMLSelectElement from '../html-select-element/HTMLSelectElement.js'; 7 | import HTMLTextAreaElement from '../html-text-area-element/HTMLTextAreaElement.js'; 8 | 9 | type THTMLFormControlElement = 10 | | HTMLInputElement 11 | | HTMLSelectElement 12 | | HTMLTextAreaElement 13 | | HTMLButtonElement 14 | | HTMLFieldSetElement 15 | | HTMLObjectElement 16 | | HTMLOutputElement; 17 | 18 | export default THTMLFormControlElement; 19 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/html-head-element/HTMLHeadElement.ts: -------------------------------------------------------------------------------- 1 | import HTMLElement from '../html-element/HTMLElement.js'; 2 | /** 3 | * HTMLHeadElement 4 | * 5 | * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLHeadElement 6 | */ 7 | export default class HTMLHeadElement extends HTMLElement {} 8 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/html-heading-element/HTMLHeadingElement.ts: -------------------------------------------------------------------------------- 1 | import HTMLElement from '../html-element/HTMLElement.js'; 2 | /** 3 | * HTMLHeadingElement 4 | * 5 | * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLHeadingElement 6 | */ 7 | export default class HTMLHeadingElement extends HTMLElement {} 8 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/html-hr-element/HTMLHRElement.ts: -------------------------------------------------------------------------------- 1 | import HTMLElement from '../html-element/HTMLElement.js'; 2 | /** 3 | * HTMLHRElement 4 | * 5 | * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLHRElement 6 | */ 7 | export default class HTMLHRElement extends HTMLElement {} 8 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/html-html-element/HTMLHtmlElement.ts: -------------------------------------------------------------------------------- 1 | import HTMLElement from '../html-element/HTMLElement.js'; 2 | /** 3 | * HTMLHtmlElement 4 | * 5 | * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLHtmlElement 6 | */ 7 | export default class HTMLHtmlElement extends HTMLElement {} 8 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/html-hyperlink-element/IHTMLHyperlinkElement.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * HTMLHyperlinkElementUtils. 3 | * 4 | * Reference: 5 | * https://html.spec.whatwg.org/multipage/links.html#htmlhyperlinkelementutils. 6 | */ 7 | export default interface IHTMLHyperlinkElement { 8 | readonly origin: string; 9 | href: string; 10 | protocol: string; 11 | username: string; 12 | password: string; 13 | host: string; 14 | hostname: string; 15 | port: string; 16 | pathname: string; 17 | search: string; 18 | hash: string; 19 | } 20 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/html-image-element/Image.ts: -------------------------------------------------------------------------------- 1 | import HTMLImageElement from './HTMLImageElement.js'; 2 | import * as PropertySymbol from '../../PropertySymbol.js'; 3 | import NamespaceURI from '../../config/NamespaceURI.js'; 4 | 5 | /** 6 | * Image as constructor. 7 | * 8 | * Reference: 9 | * https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/Image. 10 | */ 11 | export default class Image extends HTMLImageElement { 12 | public [PropertySymbol.tagName] = 'IMG'; 13 | public [PropertySymbol.localName] = 'img'; 14 | public [PropertySymbol.namespaceURI] = NamespaceURI.html; 15 | 16 | /** 17 | * Constructor. 18 | * 19 | * @param [width] Width. 20 | * @param [height] Height. 21 | */ 22 | constructor(width: number = null, height: number = null) { 23 | super(); 24 | 25 | if (width !== null) { 26 | this.width = width; 27 | } 28 | 29 | if (height !== null) { 30 | this.height = height; 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/html-input-element/FileList.ts: -------------------------------------------------------------------------------- 1 | import File from '../../file/File.js'; 2 | 3 | /** 4 | * FileList. 5 | * 6 | * @see https://developer.mozilla.org/en-US/docs/Web/API/FileList 7 | */ 8 | export default class FileList extends Array { 9 | /** 10 | * Constructor. 11 | */ 12 | constructor() { 13 | super(0); 14 | } 15 | 16 | /** 17 | * Returns `Symbol.toStringTag`. 18 | * 19 | * @returns `Symbol.toStringTag`. 20 | */ 21 | public get [Symbol.toStringTag](): string { 22 | return this.constructor.name; 23 | } 24 | 25 | /** 26 | * Returns item by index. 27 | * 28 | * @param index Index. 29 | * @returns Item. 30 | */ 31 | public item(index: number): File | null { 32 | return this[index] || null; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/html-input-element/HTMLInputElementSelectionDirectionEnum.ts: -------------------------------------------------------------------------------- 1 | enum HTMLInputElementSelectionDirectionEnum { 2 | none = 'none', 3 | forward = 'forward', 4 | backward = 'backward' 5 | } 6 | export default HTMLInputElementSelectionDirectionEnum; 7 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/html-input-element/HTMLInputElementSelectionModeEnum.ts: -------------------------------------------------------------------------------- 1 | enum HTMLInputElementSelectionModeEnum { 2 | preserve = 'preserve', 3 | select = 'select', 4 | start = 'start', 5 | end = 'end' 6 | } 7 | export default HTMLInputElementSelectionModeEnum; 8 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/html-input-element/HTMLInputElementValueStepping.ts: -------------------------------------------------------------------------------- 1 | import DOMException from '../../exception/DOMException.js'; 2 | 3 | /** 4 | * HTML input element value stepping. 5 | */ 6 | export default class HTMLInputElementValueStepping { 7 | /** 8 | * Steps up or down. 9 | * 10 | * @param type Type. 11 | * @param value Value. 12 | * @param direction Direction. 13 | * @param [increment] Increment. 14 | * @returns New value. 15 | */ 16 | public static step(type: string, value: string, direction: -1 | 1, increment?: number): string { 17 | switch (type) { 18 | case 'number': 19 | return String( 20 | Number(value) + (increment !== undefined ? increment * direction : direction) 21 | ); 22 | case 'date': 23 | case 'month': 24 | case 'week': 25 | case 'time': 26 | case 'datetime-local': 27 | case 'range': 28 | // TODO: Implement support for additional types 29 | return null; 30 | default: 31 | throw new DOMException('This form element is not steppable.'); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/html-legend-element/HTMLLegendElement.ts: -------------------------------------------------------------------------------- 1 | import HTMLElement from '../html-element/HTMLElement.js'; 2 | import HTMLFormElement from '../html-form-element/HTMLFormElement.js'; 3 | import HTMLFieldSetElement from '../html-field-set-element/HTMLFieldSetElement.js'; 4 | import Node from '../node/Node.js'; 5 | 6 | /** 7 | * HTMLLegendElement 8 | * 9 | * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLLegendElement 10 | */ 11 | export default class HTMLLegendElement extends HTMLElement { 12 | /** 13 | * Returns the parent form element. 14 | * 15 | * @returns Form. 16 | */ 17 | public get form(): HTMLFormElement { 18 | let parent: Node | null = this; 19 | while (parent) { 20 | if (parent instanceof HTMLFieldSetElement) { 21 | return parent.form; 22 | } 23 | parent = parent.parentNode; 24 | } 25 | return null; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/html-li-element/HTMLLIElement.ts: -------------------------------------------------------------------------------- 1 | import HTMLElement from '../html-element/HTMLElement.js'; 2 | /** 3 | * HTMLLIElement 4 | * 5 | * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLLIElement 6 | */ 7 | export default class HTMLLIElement extends HTMLElement { 8 | /** 9 | * Returns value. 10 | * 11 | * @returns Value. 12 | */ 13 | public get value(): number { 14 | if (!this.hasAttribute('value')) { 15 | return 0; 16 | } 17 | 18 | const parsedValue = Number(this.getAttribute('value')); 19 | return isNaN(parsedValue) ? 0 : parsedValue; 20 | } 21 | 22 | /** 23 | * Sets value. 24 | * 25 | * @param value Value. 26 | */ 27 | public set value(value: number) { 28 | const parsedValue = Number(value); 29 | this.setAttribute('value', isNaN(parsedValue) ? '0' : String(parsedValue)); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/html-media-element/IMediaTrackCapabilities.ts: -------------------------------------------------------------------------------- 1 | export default interface IMediaTrackCapabilities { 2 | aspectRatio: { 3 | max: number; 4 | min: number; 5 | }; 6 | deviceId: string; 7 | facingMode: []; 8 | frameRate: { 9 | max: number; 10 | min: number; 11 | }; 12 | height: { 13 | max: number; 14 | min: number; 15 | }; 16 | resizeMode: string[]; 17 | width: { 18 | max: number; 19 | min: number; 20 | }; 21 | } 22 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/html-media-element/IMediaTrackSettings.ts: -------------------------------------------------------------------------------- 1 | export default interface IMediaTrackSettings { 2 | deviceId: string; 3 | frameRate: number; 4 | resizeMode: string; 5 | } 6 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/html-media-element/TextTrackCueList.ts: -------------------------------------------------------------------------------- 1 | import TextTrackCue from './TextTrackCue.js'; 2 | import * as PropertySymbol from '../../PropertySymbol.js'; 3 | 4 | /** 5 | * 6 | */ 7 | export default class TextTrackCueList extends Array { 8 | /** 9 | * Constructor. 10 | * 11 | * @param [illegalConstructorSymbol] Illegal constructor symbol. 12 | */ 13 | constructor(illegalConstructorSymbol?: symbol) { 14 | super(); 15 | // "illegalConstructorSymbol" can be "1" when calling the "splice()" method 16 | if ( 17 | (illegalConstructorSymbol) !== 1 && 18 | illegalConstructorSymbol !== PropertySymbol.illegalConstructor 19 | ) { 20 | throw new TypeError('Illegal constructor'); 21 | } 22 | } 23 | 24 | /** 25 | * Returns the first TextTrackCue object with the identifier passed to it. 26 | * 27 | * @param id Text track cue identifier. 28 | */ 29 | public getCueById(id: string): TextTrackCue | null { 30 | for (const cue of this) { 31 | if (cue.id === id) { 32 | return cue; 33 | } 34 | } 35 | return null; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/html-media-element/TextTrackKindEnum.ts: -------------------------------------------------------------------------------- 1 | enum TextTrackKindEnum { 2 | subtitles = 'subtitles', 3 | captions = 'captions', 4 | descriptions = 'descriptions', 5 | chapters = 'chapters', 6 | metadata = 'metadata' 7 | } 8 | 9 | export default TextTrackKindEnum; 10 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/html-media-element/VTTRegion.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * VTTRegion. 3 | * 4 | * @see https://developer.mozilla.org/en-US/docs/Web/API/VTTRegion 5 | */ 6 | export default class VTTRegion { 7 | public id: string = ''; 8 | public width: number = 100; 9 | public lines: number = 3; 10 | public regionAnchorX: number = 0; 11 | public regionAnchorY: number = 100; 12 | public viewportAnchorX: number = 0; 13 | public viewportAnchorY: number = 100; 14 | public scroll: string = 'none'; 15 | } 16 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/html-menu-element/HTMLMenuElement.ts: -------------------------------------------------------------------------------- 1 | import HTMLElement from '../html-element/HTMLElement.js'; 2 | /** 3 | * HTMLMenuElement 4 | * 5 | * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLMenuElement 6 | */ 7 | export default class HTMLMenuElement extends HTMLElement {} 8 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/html-paragraph-element/HTMLParagraphElement.ts: -------------------------------------------------------------------------------- 1 | import HTMLElement from '../html-element/HTMLElement.js'; 2 | /** 3 | * HTMLParagraphElement 4 | * 5 | * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLParagraphElement 6 | */ 7 | export default class HTMLParagraphElement extends HTMLElement {} 8 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/html-param-element/HTMLParamElement.ts: -------------------------------------------------------------------------------- 1 | import HTMLElement from '../html-element/HTMLElement.js'; 2 | /** 3 | * HTMLParamElement 4 | * 5 | * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLParamElement 6 | */ 7 | export default class HTMLParamElement extends HTMLElement {} 8 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/html-picture-element/HTMLPictureElement.ts: -------------------------------------------------------------------------------- 1 | import HTMLElement from '../html-element/HTMLElement.js'; 2 | /** 3 | * HTMLPictureElement 4 | * 5 | * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLPictureElement 6 | */ 7 | export default class HTMLPictureElement extends HTMLElement {} 8 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/html-pre-element/HTMLPreElement.ts: -------------------------------------------------------------------------------- 1 | import HTMLElement from '../html-element/HTMLElement.js'; 2 | /** 3 | * HTMLPreElement 4 | * 5 | * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLPreElement 6 | */ 7 | export default class HTMLPreElement extends HTMLElement {} 8 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/html-quote-element/HTMLQuoteElement.ts: -------------------------------------------------------------------------------- 1 | import HTMLElement from '../html-element/HTMLElement.js'; 2 | import * as PropertySymbol from '../../PropertySymbol.js'; 3 | 4 | /** 5 | * HTMLQuoteElement 6 | * 7 | * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLQuoteElement 8 | */ 9 | export default class HTMLQuoteElement extends HTMLElement { 10 | /** 11 | * Returns source. 12 | * 13 | * @returns Source. 14 | */ 15 | public get cite(): string { 16 | if (!this.hasAttribute('cite')) { 17 | return ''; 18 | } 19 | 20 | try { 21 | return new URL(this.getAttribute('cite'), this[PropertySymbol.ownerDocument].location.href) 22 | .href; 23 | } catch (e) { 24 | return this.getAttribute('cite'); 25 | } 26 | } 27 | 28 | /** 29 | * Sets source. 30 | * 31 | * @param cite Source. 32 | */ 33 | public set cite(cite: string) { 34 | this.setAttribute('cite', cite); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/html-span-element/HTMLSpanElement.ts: -------------------------------------------------------------------------------- 1 | import HTMLElement from '../html-element/HTMLElement.js'; 2 | /** 3 | * HTMLSpanElement 4 | * 5 | * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLSpanElement 6 | */ 7 | export default class HTMLSpanElement extends HTMLElement {} 8 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/html-table-caption-element/HTMLTableCaptionElement.ts: -------------------------------------------------------------------------------- 1 | import HTMLElement from '../html-element/HTMLElement.js'; 2 | /** 3 | * HTMLTableCaptionElement 4 | * 5 | * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableCaptionElement 6 | */ 7 | export default class HTMLTableCaptionElement extends HTMLElement {} 8 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/html-table-col-element/HTMLTableColElement.ts: -------------------------------------------------------------------------------- 1 | import HTMLElement from '../html-element/HTMLElement.js'; 2 | /** 3 | * HTMLTableColElement 4 | * 5 | * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableColElement 6 | */ 7 | export default class HTMLTableColElement extends HTMLElement {} 8 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/html-time-element/HTMLTimeElement.ts: -------------------------------------------------------------------------------- 1 | import HTMLElement from '../html-element/HTMLElement.js'; 2 | 3 | /** 4 | * HTMLTimeElement. 5 | * 6 | * Reference: 7 | * https://developer.mozilla.org/en-US/docs/Web/API/HTMLTimeElement 8 | */ 9 | export default class HTMLTimeElement extends HTMLElement { 10 | /** 11 | * Returns dateTime. 12 | * 13 | * @returns dateTime. 14 | */ 15 | public get dateTime(): string { 16 | return this.getAttribute('dateTime') || ''; 17 | } 18 | 19 | /** 20 | * Sets dateTime. 21 | * 22 | * @param dateTime dateTime. 23 | */ 24 | public set dateTime(dateTime: string) { 25 | this.setAttribute('dateTime', dateTime); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/html-u-list-element/HTMLUListElement.ts: -------------------------------------------------------------------------------- 1 | import HTMLElement from '../html-element/HTMLElement.js'; 2 | /** 3 | * HTMLUListElement 4 | * 5 | * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLUListElement 6 | */ 7 | export default class HTMLUListElement extends HTMLElement {} 8 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/html-unknown-element/HTMLUnknownElement.ts: -------------------------------------------------------------------------------- 1 | import HTMLElement from '../html-element/HTMLElement.js'; 2 | 3 | /** 4 | * HTML Unknown Element. 5 | * 6 | * Reference: 7 | * https://developer.mozilla.org/en-US/docs/Web/API/HTMLUnknownElement. 8 | */ 9 | export default class HTMLUnknownElement extends HTMLElement {} 10 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/html-video-element/HTMLVideoElement.ts: -------------------------------------------------------------------------------- 1 | import HTMLMediaElement from '../html-media-element/HTMLMediaElement.js'; 2 | 3 | /** 4 | * HTML Video Element. 5 | * 6 | * Reference: 7 | * https://developer.mozilla.org/en-US/docs/Web/API/HTMLVideoElement. 8 | * 9 | */ 10 | export default class HTMLVideoElement extends HTMLMediaElement {} 11 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/node/ICachedComputedStyleResult.ts: -------------------------------------------------------------------------------- 1 | import CSSStyleDeclarationPropertyManager from '../../css/declaration/property-manager/CSSStyleDeclarationPropertyManager.js'; 2 | import ICachedResult from './ICachedResult.js'; 3 | 4 | export default interface ICachedComputedStyleResult extends ICachedResult { 5 | result: WeakRef | null; 6 | } 7 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/node/ICachedElementByIdResult.ts: -------------------------------------------------------------------------------- 1 | import Element from '../element/Element.js'; 2 | import ICachedResult from './ICachedResult.js'; 3 | 4 | export default interface ICachedElementByIdResult extends ICachedResult { 5 | result: WeakRef | null; 6 | } 7 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/node/ICachedElementByTagNameResult.ts: -------------------------------------------------------------------------------- 1 | import Element from '../element/Element.js'; 2 | import ICachedResult from './ICachedResult.js'; 3 | 4 | export default interface ICachedElementByTagNameResult extends ICachedResult { 5 | result: WeakRef | null; 6 | } 7 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/node/ICachedElementsByTagNameResult.ts: -------------------------------------------------------------------------------- 1 | import Element from '../element/Element.js'; 2 | import ICachedResult from './ICachedResult.js'; 3 | 4 | export default interface ICachedElementsByTagNameResult extends ICachedResult { 5 | result: WeakRef | null; 6 | } 7 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/node/ICachedMatchesResult.ts: -------------------------------------------------------------------------------- 1 | import ISelectorMatch from '../../query-selector/ISelectorMatch.js'; 2 | import ICachedResult from './ICachedResult.js'; 3 | 4 | export default interface ICachedMatchesResult extends ICachedResult { 5 | result: { match: ISelectorMatch | null } | null; 6 | } 7 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/node/ICachedQuerySelectorAllResult.ts: -------------------------------------------------------------------------------- 1 | import Element from '../element/Element.js'; 2 | import ICachedResult from './ICachedResult.js'; 3 | import NodeList from './NodeList.js'; 4 | 5 | export default interface ICachedQuerySelectorAllResult extends ICachedResult { 6 | result: WeakRef> | null; 7 | } 8 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/node/ICachedQuerySelectorResult.ts: -------------------------------------------------------------------------------- 1 | import Element from '../element/Element.js'; 2 | import ICachedResult from './ICachedResult.js'; 3 | 4 | export default interface ICachedQuerySelectorResult extends ICachedResult { 5 | result: WeakRef | null; 6 | } 7 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/node/ICachedResult.ts: -------------------------------------------------------------------------------- 1 | export default interface ICachedResult { 2 | result: any | null; 3 | } 4 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/node/ICachedStyleResult.ts: -------------------------------------------------------------------------------- 1 | import CSSStyleDeclarationPropertyManager from '../../css/declaration/property-manager/CSSStyleDeclarationPropertyManager.js'; 2 | import ICachedResult from './ICachedResult.js'; 3 | 4 | export default interface ICachedStyleResult extends ICachedResult { 5 | result: WeakRef | null; 6 | } 7 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/node/NodeDocumentPositionEnum.ts: -------------------------------------------------------------------------------- 1 | enum NodeDocumentPositionEnum { 2 | disconnect = 0x01, 3 | preceding = 0x02, 4 | following = 0x04, 5 | contains = 0x08, 6 | containedBy = 0x10, 7 | implementationSpecific = 0x20 8 | } 9 | 10 | export default NodeDocumentPositionEnum; 11 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/node/NodeTypeEnum.ts: -------------------------------------------------------------------------------- 1 | enum NodeTypeEnum { 2 | elementNode = 1, 3 | attributeNode = 2, 4 | textNode = 3, 5 | cdataSectionNode = 4, 6 | commentNode = 8, 7 | documentNode = 9, 8 | documentTypeNode = 10, 9 | documentFragmentNode = 11, 10 | processingInstructionNode = 7 11 | } 12 | 13 | export default NodeTypeEnum; 14 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/node/TNodeListListener.ts: -------------------------------------------------------------------------------- 1 | type TNodeListListener = (item: T, referenceItem?: T | null) => void; 2 | export default TNodeListListener; 3 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/processing-instruction/ProcessingInstruction.ts: -------------------------------------------------------------------------------- 1 | import CharacterData from '../character-data/CharacterData.js'; 2 | import NodeTypeEnum from '../node/NodeTypeEnum.js'; 3 | import * as PropertySymbol from '../../PropertySymbol.js'; 4 | 5 | /** 6 | * Processing instruction node interface. 7 | * 8 | * Reference: https://developer.mozilla.org/en-US/docs/Web/API/ProcessingInstruction. 9 | */ 10 | export default class ProcessingInstruction extends CharacterData { 11 | public [PropertySymbol.nodeType] = NodeTypeEnum.processingInstructionNode; 12 | public [PropertySymbol.target]: string; 13 | 14 | /** 15 | * Returns target. 16 | * 17 | * @returns Target. 18 | */ 19 | public get target(): string { 20 | return this[PropertySymbol.target]; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/svg-animate-element/SVGAnimateElement.ts: -------------------------------------------------------------------------------- 1 | import SVGAnimationElement from '../svg-animation-element/SVGAnimationElement.js'; 2 | 3 | /** 4 | * SVG Animate Element. 5 | * 6 | * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGAnimateElement 7 | */ 8 | export default class SVGAnimateElement extends SVGAnimationElement {} 9 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/svg-animate-motion-element/SVGAnimateMotionElement.ts: -------------------------------------------------------------------------------- 1 | import SVGAnimationElement from '../svg-animation-element/SVGAnimationElement.js'; 2 | 3 | /** 4 | * SVG Animate Element Motion. 5 | * 6 | * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGAnimateMotionElement 7 | */ 8 | export default class SVGAnimateMotionElement extends SVGAnimationElement {} 9 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/svg-animate-transform-element/SVGAnimateTransformElement.ts: -------------------------------------------------------------------------------- 1 | import SVGAnimationElement from '../svg-animation-element/SVGAnimationElement.js'; 2 | 3 | /** 4 | * SVG Animate Element Transform. 5 | * 6 | * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGAnimateTransformElement 7 | */ 8 | export default class SVGAnimateTransformElement extends SVGAnimationElement {} 9 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/svg-defs-element/SVGDefsElement.ts: -------------------------------------------------------------------------------- 1 | import SVGGraphicsElement from '../svg-graphics-element/SVGGraphicsElement.js'; 2 | 3 | /** 4 | * SVG Defs Element. 5 | * 6 | * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGDefsElement 7 | */ 8 | export default class SVGDefsElement extends SVGGraphicsElement {} 9 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/svg-desc-element/SVGDescElement.ts: -------------------------------------------------------------------------------- 1 | import SVGElement from '../svg-element/SVGElement.js'; 2 | 3 | /** 4 | * SVG Desc Element. 5 | * 6 | * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGDescElement 7 | */ 8 | export default class SVGDescElement extends SVGElement {} 9 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/svg-fe-func-a-element/SVGFEFuncAElement.ts: -------------------------------------------------------------------------------- 1 | import SVGComponentTransferFunctionElement from '../svg-component-transfer-function-element/SVGComponentTransferFunctionElement.js'; 2 | 3 | /** 4 | * SVGFEFuncAElement. 5 | * 6 | * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGFEFuncAElement 7 | */ 8 | export default class SVGFEFuncAElement extends SVGComponentTransferFunctionElement {} 9 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/svg-fe-func-b-element/SVGFEFuncBElement.ts: -------------------------------------------------------------------------------- 1 | import SVGComponentTransferFunctionElement from '../svg-component-transfer-function-element/SVGComponentTransferFunctionElement.js'; 2 | 3 | /** 4 | * SVGFEFuncBElement. 5 | * 6 | * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGFEFuncBElement 7 | */ 8 | export default class SVGFEFuncBElement extends SVGComponentTransferFunctionElement {} 9 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/svg-fe-func-g-element/SVGFEFuncGElement.ts: -------------------------------------------------------------------------------- 1 | import SVGComponentTransferFunctionElement from '../svg-component-transfer-function-element/SVGComponentTransferFunctionElement.js'; 2 | 3 | /** 4 | * SVGFEFuncGElement. 5 | * 6 | * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGFEFuncGElement 7 | */ 8 | export default class SVGFEFuncGElement extends SVGComponentTransferFunctionElement {} 9 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/svg-fe-func-r-element/SVGFEFuncRElement.ts: -------------------------------------------------------------------------------- 1 | import SVGComponentTransferFunctionElement from '../svg-component-transfer-function-element/SVGComponentTransferFunctionElement.js'; 2 | 3 | /** 4 | * SVGFEFuncRElement. 5 | * 6 | * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGFEFuncRElement 7 | */ 8 | export default class SVGFEFuncRElement extends SVGComponentTransferFunctionElement {} 9 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/svg-fe-merge-node-element/SVGFEMergeNodeElement.ts: -------------------------------------------------------------------------------- 1 | import SVGElement from '../svg-element/SVGElement.js'; 2 | import * as PropertySymbol from '../../PropertySymbol.js'; 3 | import SVGAnimatedString from '../../svg/SVGAnimatedString.js'; 4 | 5 | /** 6 | * SVGFEMergeNodeElement. 7 | * 8 | * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGFEMergeNodeElement 9 | */ 10 | export default class SVGFEMergeNodeElement extends SVGElement { 11 | // Internal properties 12 | public [PropertySymbol.in1]: SVGAnimatedString | null = null; 13 | 14 | /** 15 | * Returns in1. 16 | * 17 | * @returns In1. 18 | */ 19 | public get in1(): SVGAnimatedString { 20 | if (!this[PropertySymbol.in1]) { 21 | this[PropertySymbol.in1] = new SVGAnimatedString( 22 | PropertySymbol.illegalConstructor, 23 | this[PropertySymbol.window], 24 | { 25 | getAttribute: () => this.getAttribute('in'), 26 | setAttribute: (value) => this.setAttribute('in', value) 27 | } 28 | ); 29 | } 30 | return this[PropertySymbol.in1]; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/svg-g-element/SVGGElement.ts: -------------------------------------------------------------------------------- 1 | import SVGGraphicsElement from '../svg-graphics-element/SVGGraphicsElement.js'; 2 | 3 | /** 4 | * SVG G Element. 5 | * 6 | * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGGElement 7 | */ 8 | export default class SVGGElement extends SVGGraphicsElement {} 9 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/svg-m-path-element/SVGMPathElement.ts: -------------------------------------------------------------------------------- 1 | import SVGAnimatedString from '../../svg/SVGAnimatedString.js'; 2 | import SVGElement from '../svg-element/SVGElement.js'; 3 | import * as PropertySymbol from '../../PropertySymbol.js'; 4 | 5 | /** 6 | * SVG MPath Element. 7 | * 8 | * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGMPathElement 9 | */ 10 | export default class SVGMPathElement extends SVGElement { 11 | // Internal properties 12 | public [PropertySymbol.href]: SVGAnimatedString | null = null; 13 | 14 | /** 15 | * Returns href. 16 | * 17 | * @returns Href. 18 | */ 19 | public get href(): SVGAnimatedString { 20 | if (!this[PropertySymbol.href]) { 21 | this[PropertySymbol.href] = new SVGAnimatedString( 22 | PropertySymbol.illegalConstructor, 23 | this[PropertySymbol.window], 24 | { 25 | getAttribute: () => this.getAttribute('href'), 26 | setAttribute: (value) => this.setAttribute('href', value) 27 | } 28 | ); 29 | } 30 | return this[PropertySymbol.href]; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/svg-metadata-element/SVGMetadataElement.ts: -------------------------------------------------------------------------------- 1 | import SVGElement from '../svg-element/SVGElement.js'; 2 | 3 | /** 4 | * SVG Metadata Element. 5 | * 6 | * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGMetadataElement 7 | */ 8 | export default class SVGMetadataElement extends SVGElement {} 9 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/svg-path-element/SVGPathElement.ts: -------------------------------------------------------------------------------- 1 | import SVGGeometryElement from '../svg-geometry-element/SVGGeometryElement.js'; 2 | 3 | /** 4 | * SVG Path Element. 5 | * 6 | * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGPathElement 7 | */ 8 | export default class SVGPathElement extends SVGGeometryElement {} 9 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/svg-set-element/SVGSetElement.ts: -------------------------------------------------------------------------------- 1 | import SVGAnimationElement from '../svg-animation-element/SVGAnimationElement.js'; 2 | 3 | /** 4 | * SVG Set Element. 5 | * 6 | * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGSetElement 7 | */ 8 | export default class SVGSetElement extends SVGAnimationElement {} 9 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/svg-stop-element/SVGStopElement.ts: -------------------------------------------------------------------------------- 1 | import * as PropertySymbol from '../../PropertySymbol.js'; 2 | import SVGAnimatedNumber from '../../svg/SVGAnimatedNumber.js'; 3 | import SVGElement from '../svg-element/SVGElement.js'; 4 | 5 | /** 6 | * SVG Stop Element. 7 | * 8 | * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGStopElement 9 | */ 10 | export default class SVGStopElement extends SVGElement { 11 | // Internal properties 12 | public [PropertySymbol.offset]: SVGAnimatedNumber | null = null; 13 | 14 | /** 15 | * Returns offset. 16 | * 17 | * @returns Offset. 18 | */ 19 | public get offset(): SVGAnimatedNumber { 20 | if (!this[PropertySymbol.offset]) { 21 | this[PropertySymbol.offset] = new SVGAnimatedNumber( 22 | PropertySymbol.illegalConstructor, 23 | this[PropertySymbol.window], 24 | { 25 | getAttribute: () => this.getAttribute('offset'), 26 | setAttribute: (value) => this.setAttribute('offset', value) 27 | } 28 | ); 29 | } 30 | return this[PropertySymbol.offset]; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/svg-switch-element/SVGSwitchElement.ts: -------------------------------------------------------------------------------- 1 | import SVGGraphicsElement from '../svg-graphics-element/SVGGraphicsElement.js'; 2 | 3 | /** 4 | * SVG Switch Element. 5 | * 6 | * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGSwitchElement 7 | */ 8 | export default class SVGSwitchElement extends SVGGraphicsElement {} 9 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/svg-symbol-element/SVGSymbolElement.ts: -------------------------------------------------------------------------------- 1 | import SVGGraphicsElement from '../svg-graphics-element/SVGGraphicsElement.js'; 2 | 3 | /** 4 | * SVG Symbol Element. 5 | * 6 | * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGSymbolElement 7 | */ 8 | export default class SVGSymbolElement extends SVGGraphicsElement {} 9 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/svg-t-span-element/SVGTSpanElement.ts: -------------------------------------------------------------------------------- 1 | import SVGTextPositioningElement from '../svg-text-positioning-element/SVGTextPositioningElement.js'; 2 | 3 | /** 4 | * SVG T-Span Element. 5 | * 6 | * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGTSpanElement 7 | */ 8 | export default class SVGTSpanElement extends SVGTextPositioningElement {} 9 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/svg-text-element/SVGTextElement.ts: -------------------------------------------------------------------------------- 1 | import SVGTextPositioningElement from '../svg-text-positioning-element/SVGTextPositioningElement.js'; 2 | 3 | /** 4 | * SVG Text Element. 5 | * 6 | * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGTextElement 7 | */ 8 | export default class SVGTextElement extends SVGTextPositioningElement {} 9 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/svg-title-element/SVGTitleElement.ts: -------------------------------------------------------------------------------- 1 | import SVGElement from '../svg-element/SVGElement.js'; 2 | 3 | /** 4 | * SVG Title Element. 5 | * 6 | * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGTitleElement 7 | */ 8 | export default class SVGTitleElement extends SVGElement {} 9 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/svg-view-element/SVGViewElement.ts: -------------------------------------------------------------------------------- 1 | import SVGElement from '../svg-element/SVGElement.js'; 2 | 3 | /** 4 | * SVG View Element. 5 | * 6 | * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGViewElement 7 | */ 8 | export default class SVGViewElement extends SVGElement {} 9 | -------------------------------------------------------------------------------- /packages/happy-dom/src/nodes/xml-document/XMLDocument.ts: -------------------------------------------------------------------------------- 1 | import Document from '../document/Document.js'; 2 | import * as PropertySymbol from '../../PropertySymbol.js'; 3 | 4 | /** 5 | * Document. 6 | */ 7 | export default class XMLDocument extends Document { 8 | // Internal properties 9 | public [PropertySymbol.contentType]: string = 'application/xml'; 10 | } 11 | -------------------------------------------------------------------------------- /packages/happy-dom/src/permissions/PermissionStatus.ts: -------------------------------------------------------------------------------- 1 | import EventTarget from '../event/EventTarget.js'; 2 | import Event from '../event/Event.js'; 3 | 4 | /** 5 | * Permission status. 6 | * 7 | * Reference: 8 | * https://developer.mozilla.org/en-US/docs/Web/API/PermissionStatus 9 | */ 10 | export default class PermissionStatus extends EventTarget { 11 | public state: 'granted' | 'denied' | 'prompt'; 12 | public onchange: ((event: Event) => void) | null = null; 13 | 14 | /** 15 | * Constructor. 16 | * 17 | * @param [state] State. 18 | */ 19 | constructor(state: 'granted' | 'denied' | 'prompt' = 'granted') { 20 | super(); 21 | this.state = state; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /packages/happy-dom/src/query-selector/ISelectorAttribute.ts: -------------------------------------------------------------------------------- 1 | export default interface ISelectorAttribute { 2 | name: string; 3 | operator: string | null; 4 | value: string | null; 5 | modifier: 's' | 'i' | null; 6 | regExp: RegExp | null; 7 | } 8 | -------------------------------------------------------------------------------- /packages/happy-dom/src/query-selector/ISelectorMatch.ts: -------------------------------------------------------------------------------- 1 | export default interface ISelectorMatch { 2 | priorityWeight: number; 3 | } 4 | -------------------------------------------------------------------------------- /packages/happy-dom/src/query-selector/ISelectorPseudo.ts: -------------------------------------------------------------------------------- 1 | import SelectorItem from './SelectorItem.js'; 2 | 3 | export default interface ISelectorPseudo { 4 | name: string; 5 | arguments: string | null; 6 | selectorItems: SelectorItem[] | null; 7 | nthFunction: ((n: number) => boolean) | null; 8 | } 9 | -------------------------------------------------------------------------------- /packages/happy-dom/src/query-selector/SelectorCombinatorEnum.ts: -------------------------------------------------------------------------------- 1 | enum SelectorCombinatorEnum { 2 | descendant = 'descendant', 3 | child = 'child', 4 | adjacentSibling = 'adjacentSibling', 5 | subsequentSibling = 'subsequentSibling' 6 | } 7 | 8 | export default SelectorCombinatorEnum; 9 | -------------------------------------------------------------------------------- /packages/happy-dom/src/range/IRangeBoundaryPoint.ts: -------------------------------------------------------------------------------- 1 | import Node from '../nodes/node/Node.js'; 2 | 3 | /** 4 | * Range boundary point. 5 | */ 6 | export default interface IRangeBoundaryPoint { 7 | node: Node; 8 | offset: number; 9 | } 10 | -------------------------------------------------------------------------------- /packages/happy-dom/src/range/RangeHowEnum.ts: -------------------------------------------------------------------------------- 1 | enum RangeHowEnum { 2 | endToEnd = 2, 3 | endToStart = 3, 4 | startToEnd = 1, 5 | startToStart = 0 6 | } 7 | 8 | export default RangeHowEnum; 9 | -------------------------------------------------------------------------------- /packages/happy-dom/src/resize-observer/ResizeObserver.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * The ResizeObserver interface reports changes to the dimensions of an Element's content or border box, or the bounding box of an SVGElement. 3 | * 4 | * @see https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver 5 | */ 6 | export default class ResizeObserver { 7 | /** 8 | * Starts observing. 9 | * 10 | * Not implemented. 11 | */ 12 | public observe(): void { 13 | // TODO: Not implemented 14 | } 15 | 16 | /** 17 | * Stops observing. 18 | * 19 | * Not implemented. 20 | */ 21 | public unobserve(): void { 22 | // TODO: Not implemented 23 | } 24 | 25 | /** 26 | * Disconnects. 27 | * 28 | * Not implemented. 29 | */ 30 | public disconnect(): void { 31 | // TODO: Not implemented 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /packages/happy-dom/src/screen/Screen.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | export default class Screen { 5 | public readonly width = 1024; 6 | public readonly height = 768; 7 | public readonly availWidth = 1024; 8 | public readonly availHeight = 768; 9 | public readonly colorDepth = 24; 10 | public readonly pixelDepth = 24; 11 | } 12 | -------------------------------------------------------------------------------- /packages/happy-dom/src/selection/SelectionDirectionEnum.ts: -------------------------------------------------------------------------------- 1 | enum SelectionDirectionEnum { 2 | forwards = 1, 3 | backwards = -1, 4 | directionless = 0 5 | } 6 | 7 | export default SelectionDirectionEnum; 8 | -------------------------------------------------------------------------------- /packages/happy-dom/src/svg/SVGAngleTypeEnum.ts: -------------------------------------------------------------------------------- 1 | enum SVGAngleTypeEnum { 2 | unknown = 0, 3 | unspecified = 1, 4 | deg = 2, 5 | rad = 3, 6 | grad = 4 7 | } 8 | 9 | export default SVGAngleTypeEnum; 10 | -------------------------------------------------------------------------------- /packages/happy-dom/src/svg/SVGLengthTypeEnum.ts: -------------------------------------------------------------------------------- 1 | enum SVGLengthTypeEnum { 2 | unknown = 0, 3 | number = 1, 4 | percentage = 2, 5 | ems = 3, 6 | exs = 4, 7 | px = 5, 8 | cm = 6, 9 | mm = 7, 10 | in = 8, 11 | pt = 9, 12 | pc = 10 13 | } 14 | 15 | export default SVGLengthTypeEnum; 16 | -------------------------------------------------------------------------------- /packages/happy-dom/src/svg/SVGPreserveAspectRatioAlignEnum.ts: -------------------------------------------------------------------------------- 1 | enum SVGPreserveAspectRatioAlignEnum { 2 | unknown = 0, 3 | none = 1, 4 | xMinYMin = 2, 5 | xMidYMin = 3, 6 | xMaxYMin = 4, 7 | xMinYMid = 5, 8 | xMidYMid = 6, 9 | xMaxYMid = 7, 10 | xMinYMax = 8, 11 | xMidYMax = 9, 12 | xMaxYMax = 10 13 | } 14 | 15 | export default SVGPreserveAspectRatioAlignEnum; 16 | -------------------------------------------------------------------------------- /packages/happy-dom/src/svg/SVGPreserveAspectRatioMeetOrSliceEnum.ts: -------------------------------------------------------------------------------- 1 | enum SVGPreserveAspectRatioMeetOrSliceEnum { 2 | unknown = 0, 3 | meet = 1, 4 | slice = 2 5 | } 6 | 7 | export default SVGPreserveAspectRatioMeetOrSliceEnum; 8 | -------------------------------------------------------------------------------- /packages/happy-dom/src/svg/SVGTransformTypeEnum.ts: -------------------------------------------------------------------------------- 1 | enum SVGTransformTypeEnum { 2 | unknown = 0, 3 | matrix = 1, 4 | translate = 2, 5 | scale = 3, 6 | rotate = 4, 7 | skewX = 5, 8 | skewY = 6 9 | } 10 | 11 | export default SVGTransformTypeEnum; 12 | -------------------------------------------------------------------------------- /packages/happy-dom/src/svg/SVGUnitTypes.ts: -------------------------------------------------------------------------------- 1 | import * as PropertySymbol from '../PropertySymbol.js'; 2 | 3 | /** 4 | * SVG Unit Types. 5 | * 6 | * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGUnitTypes 7 | */ 8 | export default class SVGUnitTypes { 9 | public static readonly SVG_UNIT_TYPE_UNKNOWN = 0; 10 | public static readonly SVG_UNIT_TYPE_USERSPACEONUSE = 1; 11 | public static readonly SVG_UNIT_TYPE_OBJECTBOUNDINGBOX = 2; 12 | public readonly SVG_UNIT_TYPE_UNKNOWN = 0; 13 | public readonly SVG_UNIT_TYPE_USERSPACEONUSE = 1; 14 | public readonly SVG_UNIT_TYPE_OBJECTBOUNDINGBOX = 2; 15 | 16 | /** 17 | * Constructor. 18 | * 19 | * @param illegalConstructorSymbol Illegal constructor symbol. 20 | */ 21 | constructor(illegalConstructorSymbol: Symbol) { 22 | if (illegalConstructorSymbol !== PropertySymbol.illegalConstructor) { 23 | throw new TypeError('Illegal constructor'); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /packages/happy-dom/src/tree-walker/INodeFilter.ts: -------------------------------------------------------------------------------- 1 | import Node from '../nodes/node/Node.js'; 2 | 3 | type INodeFilter = ((node: Node) => number) | { acceptNode(node: Node): number }; 4 | 5 | export default INodeFilter; 6 | -------------------------------------------------------------------------------- /packages/happy-dom/src/tree-walker/NodeFilter.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | FILTER_ACCEPT: 1, 3 | FILTER_REJECT: 2, 4 | FILTER_SKIP: 3, 5 | SHOW_ALL: -1, 6 | SHOW_ELEMENT: 1, 7 | SHOW_ATTRIBUTE: 2, 8 | SHOW_TEXT: 4, 9 | SHOW_CDATA_SECTION: 8, 10 | SHOW_ENTITY_REFERENCE: 16, 11 | SHOW_ENTITY: 32, 12 | SHOW_PROCESSING_INSTRUCTION: 64, 13 | SHOW_COMMENT: 128, 14 | SHOW_DOCUMENT: 256, 15 | SHOW_DOCUMENT_TYPE: 512, 16 | SHOW_DOCUMENT_FRAGMENT: 1024, 17 | SHOW_NOTATION: 2048 18 | }; 19 | -------------------------------------------------------------------------------- /packages/happy-dom/src/tree-walker/NodeFilterMask.ts: -------------------------------------------------------------------------------- 1 | import NodeFilter from './NodeFilter.js'; 2 | 3 | export default { 4 | /* ELEMENT_NODE */ 5 | 1: NodeFilter.SHOW_ELEMENT, 6 | /* ATTRIBUTE_NODE */ 7 | 2: NodeFilter.SHOW_ATTRIBUTE, 8 | /* TEXT_NODE */ 9 | 3: NodeFilter.SHOW_TEXT, 10 | /* CDATA_SECTION_NODE */ 11 | 4: NodeFilter.SHOW_CDATA_SECTION, 12 | /* ENTITY_REFERENCE_NODE */ 13 | 5: NodeFilter.SHOW_ENTITY_REFERENCE, 14 | /* ENTITY_NODE */ 15 | 6: NodeFilter.SHOW_PROCESSING_INSTRUCTION, 16 | /* PROCESSING_INSTRUCTION_NODE */ 17 | 7: NodeFilter.SHOW_PROCESSING_INSTRUCTION, 18 | /* COMMENT_NODE */ 19 | 8: NodeFilter.SHOW_COMMENT, 20 | /* DOCUMENT_NODE */ 21 | 9: NodeFilter.SHOW_DOCUMENT, 22 | /* DOCUMENT_TYPE_NODE */ 23 | 10: NodeFilter.SHOW_DOCUMENT_TYPE, 24 | /* DOCUMENT_FRAGMENT_NODE */ 25 | 11: NodeFilter.SHOW_DOCUMENT_FRAGMENT, 26 | /* NOTATION_NODE */ 27 | 12: NodeFilter.SHOW_NOTATION 28 | }; 29 | -------------------------------------------------------------------------------- /packages/happy-dom/src/url/URL.ts: -------------------------------------------------------------------------------- 1 | import { URL as NodeJSURL } from 'url'; 2 | import * as PropertySymbol from '../PropertySymbol.js'; 3 | import { Blob as NodeJSBlob } from 'buffer'; 4 | import Blob from '../file/Blob.js'; 5 | 6 | /** 7 | * URL. 8 | */ 9 | export default class URL extends NodeJSURL { 10 | /** 11 | * Creates a string containing a URL representing the object given in the parameter. 12 | * 13 | * @param object Object. 14 | * @returns URL. 15 | */ 16 | public static override createObjectURL(object: NodeJSBlob | Blob): string { 17 | if (object instanceof Blob) { 18 | const blob = new NodeJSBlob([object[PropertySymbol.buffer]], { type: object.type }); 19 | return super.createObjectURL(blob); 20 | } 21 | return super.createObjectURL(object); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /packages/happy-dom/src/version.ts: -------------------------------------------------------------------------------- 1 | export default { version: '0.0.0' }; 2 | -------------------------------------------------------------------------------- /packages/happy-dom/src/window/IScrollToOptions.ts: -------------------------------------------------------------------------------- 1 | export default interface IScrollToOptions { 2 | top?: number; 3 | left?: number; 4 | behavior?: 'auto' | 'smooth'; 5 | } 6 | -------------------------------------------------------------------------------- /packages/happy-dom/src/xml-http-request/XMLHttpRequestEventTarget.ts: -------------------------------------------------------------------------------- 1 | import ProgressEvent from '../event/events/ProgressEvent.js'; 2 | import EventTarget from '../event/EventTarget.js'; 3 | 4 | export type ProgressEventListener = (event: ProgressEvent) => void; 5 | 6 | /** 7 | * References: https://xhr.spec.whatwg.org/#xmlhttprequesteventtarget. 8 | */ 9 | export default class XMLHttpRequestEventTarget extends EventTarget { 10 | public onloadstart: ProgressEventListener | null = null; 11 | public onprogress: ProgressEventListener | null = null; 12 | public onabort: ((event: ProgressEvent) => void) | null = null; 13 | public onerror: ProgressEventListener | null = null; 14 | public onload: ProgressEventListener | null = null; 15 | public ontimeout: ProgressEventListener | null = null; 16 | public onloadend: ProgressEventListener | null = null; 17 | } 18 | -------------------------------------------------------------------------------- /packages/happy-dom/src/xml-http-request/XMLHttpRequestReadyStateEnum.ts: -------------------------------------------------------------------------------- 1 | enum XMLHttpRequestReadyStateEnum { 2 | unsent = 0, 3 | opened = 1, 4 | headersRecieved = 2, 5 | loading = 3, 6 | done = 4 7 | } 8 | 9 | export default XMLHttpRequestReadyStateEnum; 10 | -------------------------------------------------------------------------------- /packages/happy-dom/src/xml-http-request/XMLHttpRequestUpload.ts: -------------------------------------------------------------------------------- 1 | import XMLHttpRequestEventTarget from './XMLHttpRequestEventTarget.js'; 2 | 3 | /** 4 | * References: https://xhr.spec.whatwg.org/#xmlhttprequestupload. 5 | */ 6 | export default class XMLHttpRequestUpload extends XMLHttpRequestEventTarget {} 7 | -------------------------------------------------------------------------------- /packages/happy-dom/src/xml-http-request/XMLHttpResponseTypeEnum.ts: -------------------------------------------------------------------------------- 1 | enum XMLHttpResponseTypeEnum { 2 | arraybuffer = 'arraybuffer', 3 | blob = 'blob', 4 | document = 'document', 5 | json = 'json', 6 | text = 'text' 7 | } 8 | 9 | export default XMLHttpResponseTypeEnum; 10 | -------------------------------------------------------------------------------- /packages/happy-dom/test/css/CSSUnitValue.test.ts: -------------------------------------------------------------------------------- 1 | import CSSUnitValue from '../../src/css/CSSUnitValue.js'; 2 | import { describe, it, expect } from 'vitest'; 3 | 4 | describe('CSSUnitValue', () => { 5 | describe('constructor()', () => { 6 | it('Creates an instance of CSSUnitValue.', () => { 7 | const cssUnitValue = new CSSUnitValue(5, 'cm'); 8 | expect(cssUnitValue.unit).toBe('cm'); 9 | expect(cssUnitValue.value).toBe(5); 10 | }); 11 | 12 | it('Throws exception when invalid unit.', () => { 13 | expect(() => new CSSUnitValue(5, 'invalid')).toThrowError( 14 | new TypeError('Invalid unit: invalid') 15 | ); 16 | }); 17 | }); 18 | }); 19 | -------------------------------------------------------------------------------- /packages/happy-dom/test/dom-parser/data/DOMParserHTML.ts: -------------------------------------------------------------------------------- 1 | export default ` 2 | 3 | 4 | 5 | Title 6 | 7 | 8 |
9 | 10 | Bold 11 | 12 | Span 13 |
14 |
15 | 16 | Bold 17 | 18 |
19 | 20 | 21 | `.trim(); 22 | -------------------------------------------------------------------------------- /packages/happy-dom/test/dom-parser/data/DOMParserSVG.ts: -------------------------------------------------------------------------------- 1 | export default ` 2 | 3 | 4 | 5 | `; 6 | -------------------------------------------------------------------------------- /packages/happy-dom/test/event/events/ClipboardEvent.test.ts: -------------------------------------------------------------------------------- 1 | import ClipboardEvent from '../../../src/event/events/ClipboardEvent.js'; 2 | import DataTransfer from '../../../src/event/DataTransfer.js'; 3 | import { describe, it, expect } from 'vitest'; 4 | 5 | describe('ClipboardEvent', () => { 6 | describe('constructor()', () => { 7 | it('Creates a ClipboardEvent', () => { 8 | const eventType = 'paste'; 9 | const event = new ClipboardEvent(eventType); 10 | expect(event.type).toBe(eventType); 11 | expect(event.clipboardData).toBeNull(); 12 | }); 13 | 14 | it('Creates a CustomEvent with clipboardData', () => { 15 | const eventType = 'paste'; 16 | const clipboardData = new DataTransfer(); 17 | const event = new ClipboardEvent(eventType, { clipboardData }); 18 | expect(event.type).toBe(eventType); 19 | expect(event.clipboardData).toBe(clipboardData); 20 | }); 21 | }); 22 | }); 23 | -------------------------------------------------------------------------------- /packages/happy-dom/test/event/events/SubmitEvent.test.ts: -------------------------------------------------------------------------------- 1 | import Event from '../../../src/event/Event.js'; 2 | import SubmitEvent from '../../../src/event/events/SubmitEvent.js'; 3 | import HTMLButtonElement from '../../../src/nodes/html-button-element/HTMLButtonElement.js'; 4 | import Window from '../../../src/window/Window.js'; 5 | import { describe, it, expect } from 'vitest'; 6 | 7 | describe('SubmitEvent', () => { 8 | describe('constructor', () => { 9 | it('Creates a submit event.', () => { 10 | const window = new Window(); 11 | const document = window.document; 12 | const submitter = document.createElement('button'); 13 | const event = new SubmitEvent('submit', { bubbles: true, submitter }); 14 | expect(event).toBeInstanceOf(Event); 15 | expect(event.bubbles).toBe(true); 16 | expect(event.cancelable).toBe(false); 17 | expect(event.submitter).toBe(submitter); 18 | }); 19 | }); 20 | }); 21 | -------------------------------------------------------------------------------- /packages/happy-dom/test/fetch/data/test-image.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/capricorn86/happy-dom/24912049d7ec70748dc987da1dfbde9fbd5bd848/packages/happy-dom/test/fetch/data/test-image.jpg -------------------------------------------------------------------------------- /packages/happy-dom/test/fetch/virtual-server/css/style.css: -------------------------------------------------------------------------------- 1 | body { 2 | background-color: red; 3 | } -------------------------------------------------------------------------------- /packages/happy-dom/test/fetch/virtual-server/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Virtual Server 6 | 7 | 8 | 9 | 10 | 11 |
false
12 |
false
13 |
false
14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /packages/happy-dom/test/fetch/virtual-server/js/async.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable no-undef */ 2 | function main() { 3 | document.querySelector('#async-1').textContent = 'true'; 4 | setTimeout(() => { 5 | document.querySelector('#async-2').textContent = 'true'; 6 | }, 10); 7 | } 8 | 9 | main(); 10 | -------------------------------------------------------------------------------- /packages/happy-dom/test/fetch/virtual-server/js/sync.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable no-undef */ 2 | function main() { 3 | document.querySelector('#sync').textContent = 'true'; 4 | } 5 | 6 | main(); 7 | -------------------------------------------------------------------------------- /packages/happy-dom/test/file/File.test.ts: -------------------------------------------------------------------------------- 1 | import File from '../../src/file/File.js'; 2 | import { afterEach, describe, it, expect, vi } from 'vitest'; 3 | 4 | const NOW = 1; 5 | 6 | describe('File', () => { 7 | afterEach(() => { 8 | vi.restoreAllMocks(); 9 | }); 10 | 11 | describe('get name()', () => { 12 | it('Returns the name of the File.', () => { 13 | const file = new File(['TEST'], 'filename.jpg'); 14 | expect(file.name).toBe('filename.jpg'); 15 | }); 16 | }); 17 | 18 | describe('get lastModified()', () => { 19 | it('Returns the current time if not provided to the constructor.', () => { 20 | vi.spyOn(Date, 'now').mockImplementation(() => NOW); 21 | const file = new File(['TEST'], 'filename.jpg'); 22 | expect(file.lastModified).toBe(NOW); 23 | }); 24 | 25 | it('Returns the current time if not provided to the constructor.', () => { 26 | const file = new File(['TEST'], 'filename.jpg', { lastModified: NOW }); 27 | expect(file.lastModified).toBe(NOW); 28 | }); 29 | }); 30 | }); 31 | -------------------------------------------------------------------------------- /packages/happy-dom/test/index.test.ts: -------------------------------------------------------------------------------- 1 | import { beforeEach, afterEach, describe, it, expect, vi } from 'vitest'; 2 | import HTMLElementConfig from '../src/config/HTMLElementConfig.js'; 3 | import * as Index from '../src/index.js'; 4 | 5 | describe('Index', () => { 6 | for (const tagName of Object.keys(HTMLElementConfig)) { 7 | it(`Exposes the element class "${HTMLElementConfig[tagName].className}" for tag name "${tagName}"`, () => { 8 | expect(Index[HTMLElementConfig[tagName].className].name).toBe( 9 | HTMLElementConfig[tagName].className 10 | ); 11 | }); 12 | } 13 | }); 14 | -------------------------------------------------------------------------------- /packages/happy-dom/test/nodes/html-br-element/HTMLBRElement.test.ts: -------------------------------------------------------------------------------- 1 | import HTMLBRElement from '../../../src/nodes/html-br-element/HTMLBRElement.js'; 2 | import Window from '../../../src/window/Window.js'; 3 | import Document from '../../../src/nodes/document/Document.js'; 4 | import { beforeEach, describe, it, expect } from 'vitest'; 5 | 6 | describe('HTMLBRElement', () => { 7 | let window: Window; 8 | let document: Document; 9 | let element: HTMLBRElement; 10 | 11 | beforeEach(() => { 12 | window = new Window(); 13 | document = window.document; 14 | element = document.createElement('br'); 15 | }); 16 | 17 | describe('constructor()', () => { 18 | it('Should be an instanceof HTMLBRElement', () => { 19 | expect(element instanceof HTMLBRElement).toBe(true); 20 | }); 21 | }); 22 | }); 23 | -------------------------------------------------------------------------------- /packages/happy-dom/test/nodes/html-canvas-element/ImageBitmap.test.ts: -------------------------------------------------------------------------------- 1 | import { describe, it, expect } from 'vitest'; 2 | import ImageBitmap from '../../../src/nodes/html-canvas-element/ImageBitmap.js'; 3 | 4 | describe('ImageBitmap', () => { 5 | describe('get width()', () => { 6 | it('Returns width.', () => { 7 | const imageBitmap = new ImageBitmap(800, 600); 8 | expect(imageBitmap.width).toBe(800); 9 | }); 10 | }); 11 | describe('get height()', () => { 12 | it('Returns height.', () => { 13 | const imageBitmap = new ImageBitmap(800, 600); 14 | expect(imageBitmap.height).toBe(600); 15 | }); 16 | }); 17 | 18 | describe('close()', () => { 19 | it('Does nothing (not implemented yet).', () => { 20 | const imageBitmap = new ImageBitmap(800, 600); 21 | expect(() => imageBitmap.close()).not.toThrow(); 22 | }); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /packages/happy-dom/test/nodes/html-d-list-element/HTMLDListElement.test.ts: -------------------------------------------------------------------------------- 1 | import HTMLDListElement from '../../../src/nodes/html-d-list-element/HTMLDListElement.js'; 2 | import Window from '../../../src/window/Window.js'; 3 | import Document from '../../../src/nodes/document/Document.js'; 4 | import { beforeEach, describe, it, expect } from 'vitest'; 5 | 6 | describe('HTMLDListElement', () => { 7 | let window: Window; 8 | let document: Document; 9 | let element: HTMLDListElement; 10 | 11 | beforeEach(() => { 12 | window = new Window(); 13 | document = window.document; 14 | element = document.createElement('dl'); 15 | }); 16 | 17 | describe('constructor()', () => { 18 | it('Should be an instanceof HTMLDListElement', () => { 19 | expect(element instanceof HTMLDListElement).toBe(true); 20 | }); 21 | }); 22 | }); 23 | -------------------------------------------------------------------------------- /packages/happy-dom/test/nodes/html-div-element/HTMLDivElement.test.ts: -------------------------------------------------------------------------------- 1 | import HTMLDivElement from '../../../src/nodes/html-div-element/HTMLDivElement.js'; 2 | import Window from '../../../src/window/Window.js'; 3 | import Document from '../../../src/nodes/document/Document.js'; 4 | import { beforeEach, describe, it, expect } from 'vitest'; 5 | 6 | describe('HTMLDivElement', () => { 7 | let window: Window; 8 | let document: Document; 9 | let element: HTMLDivElement; 10 | 11 | beforeEach(() => { 12 | window = new Window(); 13 | document = window.document; 14 | element = document.createElement('div'); 15 | }); 16 | 17 | describe('constructor()', () => { 18 | it('Should be an instanceof HTMLDivElement', () => { 19 | expect(element instanceof HTMLDivElement).toBe(true); 20 | }); 21 | }); 22 | }); 23 | -------------------------------------------------------------------------------- /packages/happy-dom/test/nodes/html-head-element/HTMLHeadElement.test.ts: -------------------------------------------------------------------------------- 1 | import HTMLHeadElement from '../../../src/nodes/html-head-element/HTMLHeadElement.js'; 2 | import Window from '../../../src/window/Window.js'; 3 | import Document from '../../../src/nodes/document/Document.js'; 4 | import { beforeEach, describe, it, expect } from 'vitest'; 5 | 6 | describe('HTMLHeadElement', () => { 7 | let window: Window; 8 | let document: Document; 9 | let element: HTMLHeadElement; 10 | 11 | beforeEach(() => { 12 | window = new Window(); 13 | document = window.document; 14 | element = document.createElement('head'); 15 | }); 16 | 17 | describe('constructor()', () => { 18 | it('Should be an instanceof HTMLHeadElement', () => { 19 | expect(element instanceof HTMLHeadElement).toBe(true); 20 | }); 21 | }); 22 | }); 23 | -------------------------------------------------------------------------------- /packages/happy-dom/test/nodes/html-heading-element/HTMLHeadingElement.test.ts: -------------------------------------------------------------------------------- 1 | import HTMLHeadingElement from '../../../src/nodes/html-heading-element/HTMLHeadingElement.js'; 2 | import Window from '../../../src/window/Window.js'; 3 | import Document from '../../../src/nodes/document/Document.js'; 4 | import { beforeEach, describe, it, expect } from 'vitest'; 5 | 6 | describe('HTMLHeadingElement', () => { 7 | let window: Window; 8 | let document: Document; 9 | let element: HTMLHeadingElement; 10 | 11 | beforeEach(() => { 12 | window = new Window(); 13 | document = window.document; 14 | element = document.createElement('h6'); 15 | }); 16 | 17 | describe('constructor()', () => { 18 | it('Should be an instanceof HTMLHeadingElement', () => { 19 | expect(element instanceof HTMLHeadingElement).toBe(true); 20 | }); 21 | }); 22 | }); 23 | -------------------------------------------------------------------------------- /packages/happy-dom/test/nodes/html-hr-element/HTMLHRElement.test.ts: -------------------------------------------------------------------------------- 1 | import HTMLHRElement from '../../../src/nodes/html-hr-element/HTMLHRElement.js'; 2 | import Window from '../../../src/window/Window.js'; 3 | import Document from '../../../src/nodes/document/Document.js'; 4 | import { beforeEach, describe, it, expect } from 'vitest'; 5 | 6 | describe('HTMLHRElement', () => { 7 | let window: Window; 8 | let document: Document; 9 | let element: HTMLHRElement; 10 | 11 | beforeEach(() => { 12 | window = new Window(); 13 | document = window.document; 14 | element = document.createElement('hr'); 15 | }); 16 | 17 | describe('constructor()', () => { 18 | it('Should be an instanceof HTMLHRElement', () => { 19 | expect(element instanceof HTMLHRElement).toBe(true); 20 | }); 21 | }); 22 | }); 23 | -------------------------------------------------------------------------------- /packages/happy-dom/test/nodes/html-html-element/HTMLHtmlElement.test.ts: -------------------------------------------------------------------------------- 1 | import HTMLHtmlElement from '../../../src/nodes/html-html-element/HTMLHtmlElement.js'; 2 | import Window from '../../../src/window/Window.js'; 3 | import Document from '../../../src/nodes/document/Document.js'; 4 | import { beforeEach, describe, it, expect } from 'vitest'; 5 | 6 | describe('HTMLHtmlElement', () => { 7 | let window: Window; 8 | let document: Document; 9 | let element: HTMLHtmlElement; 10 | 11 | beforeEach(() => { 12 | window = new Window(); 13 | document = window.document; 14 | element = document.createElement('html'); 15 | }); 16 | 17 | describe('constructor()', () => { 18 | it('Should be an instanceof HTMLHtmlElement', () => { 19 | expect(element instanceof HTMLHtmlElement).toBe(true); 20 | }); 21 | }); 22 | }); 23 | -------------------------------------------------------------------------------- /packages/happy-dom/test/nodes/html-input-element/FileList.test.ts: -------------------------------------------------------------------------------- 1 | import Window from '../../../src/window/Window.js'; 2 | import Document from '../../../src/nodes/document/Document.js'; 3 | import File from '../../../src/file/File.js'; 4 | import HTMLInputElement from '../../../src/nodes/html-input-element/HTMLInputElement.js'; 5 | import { beforeEach, afterEach, describe, it, expect } from 'vitest'; 6 | 7 | describe('FileList', () => { 8 | let window: Window; 9 | let document: Document; 10 | 11 | beforeEach(() => { 12 | window = new Window(); 13 | document = window.document; 14 | }); 15 | 16 | describe('item()', () => { 17 | it('Returns file at index.', () => { 18 | const element = document.createElement('input'); 19 | const file1 = new File([''], 'file.txt'); 20 | const file2 = new File([''], 'file2.txt'); 21 | 22 | element.files.push(file1); 23 | element.files.push(file2); 24 | 25 | expect(element.files.item(0)).toBe(file1); 26 | expect(element.files.item(1)).toBe(file2); 27 | }); 28 | }); 29 | }); 30 | -------------------------------------------------------------------------------- /packages/happy-dom/test/nodes/html-link-element/preload-resources/data.json: -------------------------------------------------------------------------------- 1 | { "data": "loaded" } 2 | -------------------------------------------------------------------------------- /packages/happy-dom/test/nodes/html-link-element/preload-resources/main.js: -------------------------------------------------------------------------------- 1 | // eslint-disable-next-line no-console 2 | console.log('Resource loaded'); 3 | 4 | (async () => { 5 | const data = await fetch('preload/data.json'); 6 | // eslint-disable-next-line no-console 7 | console.log(await data.json()); 8 | })(); 9 | -------------------------------------------------------------------------------- /packages/happy-dom/test/nodes/html-link-element/preload-resources/style.css: -------------------------------------------------------------------------------- 1 | body { 2 | background-color: red; 3 | } -------------------------------------------------------------------------------- /packages/happy-dom/test/nodes/html-menu-element/HTMLMenuElement.test.ts: -------------------------------------------------------------------------------- 1 | import HTMLMenuElement from '../../../src/nodes/html-menu-element/HTMLMenuElement.js'; 2 | import Window from '../../../src/window/Window.js'; 3 | import Document from '../../../src/nodes/document/Document.js'; 4 | import { beforeEach, describe, it, expect } from 'vitest'; 5 | 6 | describe('HTMLMenuElement', () => { 7 | let window: Window; 8 | let document: Document; 9 | let element: HTMLMenuElement; 10 | 11 | beforeEach(() => { 12 | window = new Window(); 13 | document = window.document; 14 | element = document.createElement('menu'); 15 | }); 16 | 17 | describe('constructor()', () => { 18 | it('Should be an instanceof HTMLMenuElement', () => { 19 | expect(element instanceof HTMLMenuElement).toBe(true); 20 | }); 21 | }); 22 | }); 23 | -------------------------------------------------------------------------------- /packages/happy-dom/test/nodes/html-paragraph-element/HTMLParagraphElement.test.ts: -------------------------------------------------------------------------------- 1 | import HTMLParagraphElement from '../../../src/nodes/html-paragraph-element/HTMLParagraphElement.js'; 2 | import Window from '../../../src/window/Window.js'; 3 | import Document from '../../../src/nodes/document/Document.js'; 4 | import { beforeEach, describe, it, expect } from 'vitest'; 5 | 6 | describe('HTMLParagraphElement', () => { 7 | let window: Window; 8 | let document: Document; 9 | let element: HTMLParagraphElement; 10 | 11 | beforeEach(() => { 12 | window = new Window(); 13 | document = window.document; 14 | element = document.createElement('p'); 15 | }); 16 | 17 | describe('constructor()', () => { 18 | it('Should be an instanceof HTMLParagraphElement', () => { 19 | expect(element instanceof HTMLParagraphElement).toBe(true); 20 | }); 21 | }); 22 | }); 23 | -------------------------------------------------------------------------------- /packages/happy-dom/test/nodes/html-param-element/HTMLParamElement.test.ts: -------------------------------------------------------------------------------- 1 | import HTMLParamElement from '../../../src/nodes/html-param-element/HTMLParamElement.js'; 2 | import Window from '../../../src/window/Window.js'; 3 | import Document from '../../../src/nodes/document/Document.js'; 4 | import { beforeEach, describe, it, expect } from 'vitest'; 5 | 6 | describe('HTMLParamElement', () => { 7 | let window: Window; 8 | let document: Document; 9 | let element: HTMLParamElement; 10 | 11 | beforeEach(() => { 12 | window = new Window(); 13 | document = window.document; 14 | element = document.createElement('param'); 15 | }); 16 | 17 | describe('constructor()', () => { 18 | it('Should be an instanceof HTMLParamElement', () => { 19 | expect(element instanceof HTMLParamElement).toBe(true); 20 | }); 21 | }); 22 | }); 23 | -------------------------------------------------------------------------------- /packages/happy-dom/test/nodes/html-picture-element/HTMLPictureElement.test.ts: -------------------------------------------------------------------------------- 1 | import HTMLPictureElement from '../../../src/nodes/html-picture-element/HTMLPictureElement.js'; 2 | import Window from '../../../src/window/Window.js'; 3 | import Document from '../../../src/nodes/document/Document.js'; 4 | import { beforeEach, describe, it, expect } from 'vitest'; 5 | 6 | describe('HTMLPictureElement', () => { 7 | let window: Window; 8 | let document: Document; 9 | let element: HTMLPictureElement; 10 | 11 | beforeEach(() => { 12 | window = new Window(); 13 | document = window.document; 14 | element = document.createElement('picture'); 15 | }); 16 | 17 | describe('constructor()', () => { 18 | it('Should be an instanceof HTMLPictureElement', () => { 19 | expect(element instanceof HTMLPictureElement).toBe(true); 20 | }); 21 | }); 22 | }); 23 | -------------------------------------------------------------------------------- /packages/happy-dom/test/nodes/html-pre-element/HTMLPreElement.test.ts: -------------------------------------------------------------------------------- 1 | import HTMLPreElement from '../../../src/nodes/html-pre-element/HTMLPreElement.js'; 2 | import Window from '../../../src/window/Window.js'; 3 | import Document from '../../../src/nodes/document/Document.js'; 4 | import { beforeEach, describe, it, expect } from 'vitest'; 5 | 6 | describe('HTMLPreElement', () => { 7 | let window: Window; 8 | let document: Document; 9 | let element: HTMLPreElement; 10 | 11 | beforeEach(() => { 12 | window = new Window(); 13 | document = window.document; 14 | element = document.createElement('pre'); 15 | }); 16 | 17 | describe('constructor()', () => { 18 | it('Should be an instanceof HTMLPreElement', () => { 19 | expect(element instanceof HTMLPreElement).toBe(true); 20 | }); 21 | }); 22 | }); 23 | -------------------------------------------------------------------------------- /packages/happy-dom/test/nodes/html-script-element/modules-with-compilation-error/TestModuleElement.js: -------------------------------------------------------------------------------- 1 | import { toLowerCase, toUpperCase, trim } from './utilities/stringUtility.js'; 2 | 3 | /* eslint-disable no-undef */ 4 | 5 | /** 6 | * Module element. 7 | */ 8 | class TestModule extends HTMLElement { 9 | /** 10 | * Constructor. 11 | */ 12 | constructor() { 13 | super(); 14 | this.attachShadow({ mode: 'open' }); 15 | this.shadowRoot.adoptedStyleSheets = [Style]; 16 | } 17 | 18 | /** 19 | * Connected callback. 20 | */ 21 | connectedCallback() { 22 | this.shadowRoot.innerHTML = `
23 | Expect lower case: ${StringUtility.toLowerCase(Data.upperCase)} 24 | Expect upper case: ${toUpperCase(Data.lowerCase)} 25 | Expect lower case. ${toLowerCase(Data.upperCase)} 26 | Expect trimmed lower case: ${trim(Data.untrimmed)} 27 |
`; 28 | } 29 | } 30 | 31 | customElements.define('test-module', TestModule); 32 | -------------------------------------------------------------------------------- /packages/happy-dom/test/nodes/html-script-element/modules-with-compilation-error/utilities/stringUtility.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | 3 | export const toLowerCase = (str) => str.toLowerCase(); 4 | 5 | const toUpperCase = (str) => str.toUpperCase(); 6 | const trim = (str) => str.trim(); 7 | 8 | export error { toUpperCase, trim }; 9 | -------------------------------------------------------------------------------- /packages/happy-dom/test/nodes/html-script-element/modules-with-evaluation-error/TestModuleElement.js: -------------------------------------------------------------------------------- 1 | import { toLowerCase, toUpperCase, trim } from './utilities/stringUtility.js'; 2 | 3 | /* eslint-disable no-undef */ 4 | 5 | /** 6 | * Module element. 7 | */ 8 | class TestModule extends HTMLElement { 9 | /** 10 | * Constructor. 11 | */ 12 | constructor() { 13 | super(); 14 | this.attachShadow({ mode: 'open' }); 15 | this.shadowRoot.adoptedStyleSheets = [Style]; 16 | } 17 | 18 | /** 19 | * Connected callback. 20 | */ 21 | connectedCallback() { 22 | this.shadowRoot.innerHTML = `
23 | Expect lower case: ${StringUtility.toLowerCase(Data.upperCase)} 24 | Expect upper case: ${toUpperCase(Data.lowerCase)} 25 | Expect lower case. ${toLowerCase(Data.upperCase)} 26 | Expect trimmed lower case: ${trim(Data.untrimmed)} 27 |
`; 28 | } 29 | } 30 | 31 | customElements.define('test-module', TestModule); 32 | -------------------------------------------------------------------------------- /packages/happy-dom/test/nodes/html-script-element/modules-with-evaluation-error/utilities/stringUtility.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | 3 | export const toLowerCase = (str) => str.toLowerCase(); 4 | 5 | const toUpperCase = (str) => str.toUpperCase(); 6 | const trim = (str) => str.trim(); 7 | 8 | (() => { 9 | console.log(notFound); 10 | })(); 11 | 12 | export { toUpperCase, trim }; 13 | -------------------------------------------------------------------------------- /packages/happy-dom/test/nodes/html-script-element/modules-with-import-map/default/utilities/StringUtilityClass.js: -------------------------------------------------------------------------------- 1 | import { apostrophWrapper } from 'external-scripts/utilities/apostrophWrapper.js'; 2 | 3 | /* eslint-disable no-undef */ 4 | 5 | window['moduleLoadOrder'] = window['moduleLoadOrder'] || []; 6 | window['moduleLoadOrder'].push('StringUtilityClass.js'); 7 | 8 | /** 9 | * String utility. 10 | */ 11 | export default class StringUtilityClass { 12 | /** 13 | * Converts a string to lower case. 14 | * 15 | * @param {string} value Value. 16 | * @returns {string} Lower case value. 17 | */ 18 | static toLowerCase(value) { 19 | return apostrophWrapper(value.toLowerCase()); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /packages/happy-dom/test/nodes/html-script-element/modules-with-import-map/default/utilities/lazyload.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable no-undef */ 2 | 3 | window['moduleLoadOrder'] = window['moduleLoadOrder'] || []; 4 | window['moduleLoadOrder'].push('lazyload.js'); 5 | 6 | const obj = { lazyloaded: true }; 7 | 8 | export const { lazyloaded } = obj; 9 | -------------------------------------------------------------------------------- /packages/happy-dom/test/nodes/html-script-element/modules-with-import-map/external-resources/css/style.css: -------------------------------------------------------------------------------- 1 | div { 2 | background: red; 3 | } -------------------------------------------------------------------------------- /packages/happy-dom/test/nodes/html-script-element/modules-with-import-map/external-resources/json/data.json: -------------------------------------------------------------------------------- 1 | { 2 | "lowerCase": "value", 3 | "upperCase": "VALUE", 4 | "untrimmed": " value " 5 | } 6 | -------------------------------------------------------------------------------- /packages/happy-dom/test/nodes/html-script-element/modules-with-import-map/external-scripts/utilities/apostrophWrapper.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable no-undef */ 2 | 3 | window['moduleLoadOrder'] = window['moduleLoadOrder'] || []; 4 | window['moduleLoadOrder'].push('apostrophWrapper.js'); 5 | 6 | export const apostrophWrapper = (str) => `"${str}"`; 7 | -------------------------------------------------------------------------------- /packages/happy-dom/test/nodes/html-script-element/modules-with-import-map/external-scripts/utilities/stringUtility.js: -------------------------------------------------------------------------------- 1 | import { apostrophWrapper } from './apostrophWrapper.js'; 2 | import Data from 'second-external-resources/json/data.json' with { type: 'json' }; 3 | 4 | /* eslint-disable no-undef */ 5 | 6 | window['moduleLoadOrder'] = window['moduleLoadOrder'] || []; 7 | window['moduleLoadOrder'].push('stringUtility.js'); 8 | 9 | export const toLowerCase = (str) => apostrophWrapper(str.toLowerCase()); 10 | 11 | const toUpperCase = (str) => apostrophWrapper(str.toUpperCase()); 12 | const trim = (str) => apostrophWrapper(str.trim()); 13 | const getData = () => Data; 14 | 15 | export { toUpperCase, trim, getData }; 16 | -------------------------------------------------------------------------------- /packages/happy-dom/test/nodes/html-script-element/modules-with-not-found-error/TestModuleElement.js: -------------------------------------------------------------------------------- 1 | import { toLowerCase, toUpperCase, trim } from './utilities/stringUtility.js'; 2 | 3 | /* eslint-disable no-undef */ 4 | 5 | /** 6 | * Module element. 7 | */ 8 | class TestModule extends HTMLElement { 9 | /** 10 | * Constructor. 11 | */ 12 | constructor() { 13 | super(); 14 | this.attachShadow({ mode: 'open' }); 15 | this.shadowRoot.adoptedStyleSheets = [Style]; 16 | } 17 | 18 | /** 19 | * Connected callback. 20 | */ 21 | connectedCallback() { 22 | this.shadowRoot.innerHTML = `
23 | Expect lower case: ${StringUtility.toLowerCase(Data.upperCase)} 24 | Expect upper case: ${toUpperCase(Data.lowerCase)} 25 | Expect lower case. ${toLowerCase(Data.upperCase)} 26 | Expect trimmed lower case: ${trim(Data.untrimmed)} 27 |
`; 28 | } 29 | } 30 | 31 | customElements.define('test-module', TestModule); 32 | -------------------------------------------------------------------------------- /packages/happy-dom/test/nodes/html-script-element/modules-with-not-found-error/utilities/stringUtility.js: -------------------------------------------------------------------------------- 1 | import { notFound } from './notFound.js'; 2 | 3 | export const toLowerCase = (str) => notFound(str.toLowerCase()); 4 | 5 | const toUpperCase = (str) => notFound(str.toUpperCase()); 6 | const trim = (str) => notFound(str.trim()); 7 | 8 | export { toUpperCase, trim }; 9 | -------------------------------------------------------------------------------- /packages/happy-dom/test/nodes/html-script-element/modules/css/style.css: -------------------------------------------------------------------------------- 1 | div { 2 | background: red; 3 | } -------------------------------------------------------------------------------- /packages/happy-dom/test/nodes/html-script-element/modules/json/data.json: -------------------------------------------------------------------------------- 1 | { 2 | "lowerCase": "value", 3 | "upperCase": "VALUE", 4 | "untrimmed": " value " 5 | } 6 | -------------------------------------------------------------------------------- /packages/happy-dom/test/nodes/html-script-element/modules/utilities/StringUtilityClass.js: -------------------------------------------------------------------------------- 1 | import { apostrophWrapper } from './apostrophWrapper.js'; 2 | 3 | /* eslint-disable no-undef */ 4 | 5 | window['moduleLoadOrder'] = window['moduleLoadOrder'] || []; 6 | window['moduleLoadOrder'].push('StringUtilityClass.js'); 7 | 8 | /** 9 | * String utility. 10 | */ 11 | export default class StringUtilityClass { 12 | /** 13 | * Converts a string to lower case. 14 | * 15 | * @param {string} value Value. 16 | * @returns {string} Lower case value. 17 | */ 18 | static toLowerCase(value) { 19 | return apostrophWrapper(value.toLowerCase()); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /packages/happy-dom/test/nodes/html-script-element/modules/utilities/apostrophWrapper.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable no-undef */ 2 | 3 | window['moduleLoadOrder'] = window['moduleLoadOrder'] || []; 4 | window['moduleLoadOrder'].push('apostrophWrapper.js'); 5 | 6 | export const apostrophWrapper = (str) => `"${str}"`; 7 | -------------------------------------------------------------------------------- /packages/happy-dom/test/nodes/html-script-element/modules/utilities/lazyload.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable no-undef */ 2 | 3 | window['moduleLoadOrder'] = window['moduleLoadOrder'] || []; 4 | window['moduleLoadOrder'].push('lazyload.js'); 5 | 6 | const obj = { lazyloaded: true }; 7 | 8 | export const { lazyloaded } = obj; 9 | -------------------------------------------------------------------------------- /packages/happy-dom/test/nodes/html-script-element/modules/utilities/stringUtility.js: -------------------------------------------------------------------------------- 1 | import { apostrophWrapper } from './apostrophWrapper.js'; 2 | 3 | /* eslint-disable no-undef */ 4 | 5 | window['moduleLoadOrder'] = window['moduleLoadOrder'] || []; 6 | window['moduleLoadOrder'].push('stringUtility.js'); 7 | 8 | export const toLowerCase = (str) => apostrophWrapper(str.toLowerCase()); 9 | 10 | const toUpperCase = (str) => apostrophWrapper(str.toUpperCase()); 11 | const trim = (str) => apostrophWrapper(str.trim()); 12 | 13 | export { toUpperCase, trim }; 14 | -------------------------------------------------------------------------------- /packages/happy-dom/test/nodes/html-select-element/__snapshots__/HTMLSelectElement.test.ts.snap: -------------------------------------------------------------------------------- 1 | // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html 2 | 3 | exports[`HTMLSelectElement > constructor() > Matches snapshot. 1`] = ` 4 | 12 | `; 13 | -------------------------------------------------------------------------------- /packages/happy-dom/test/nodes/html-slot-element/CustomElementWithNamedSlots.ts: -------------------------------------------------------------------------------- 1 | import HTMLElement from '../../../src/nodes/html-element/HTMLElement.js'; 2 | import ShadowRoot from '../../../src/nodes/shadow-root/ShadowRoot.js'; 3 | 4 | /** 5 | * Custom element test class. 6 | */ 7 | export default class CustomElementWithNamedSlots extends HTMLElement { 8 | /** 9 | * Constructor. 10 | */ 11 | constructor() { 12 | super(); 13 | this.attachShadow({ mode: 'open' }); 14 | } 15 | 16 | /** 17 | * @override 18 | */ 19 | public connectedCallback(): void { 20 | (this.shadowRoot).innerHTML = ` 21 |
22 | 23 | 24 | 25 |
26 | `; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /packages/happy-dom/test/nodes/html-slot-element/CustomElementWithSlot.ts: -------------------------------------------------------------------------------- 1 | import HTMLElement from '../../../src/nodes/html-element/HTMLElement.js'; 2 | import ShadowRoot from '../../../src/nodes/shadow-root/ShadowRoot.js'; 3 | 4 | /** 5 | * Custom element test class. 6 | */ 7 | export default class CustomElementWithSlot extends HTMLElement { 8 | /** 9 | * Constructor. 10 | */ 11 | constructor() { 12 | super(); 13 | this.attachShadow({ mode: 'open' }); 14 | } 15 | 16 | /** 17 | * @override 18 | */ 19 | public connectedCallback(): void { 20 | (this.shadowRoot).innerHTML = ` 21 |
22 | 23 |
24 | `; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /packages/happy-dom/test/nodes/html-span-element/HTMLSpanElement.test.ts: -------------------------------------------------------------------------------- 1 | import HTMLSpanElement from '../../../src/nodes/html-span-element/HTMLSpanElement.js'; 2 | import Window from '../../../src/window/Window.js'; 3 | import Document from '../../../src/nodes/document/Document.js'; 4 | import { beforeEach, describe, it, expect } from 'vitest'; 5 | 6 | describe('HTMLSpanElement', () => { 7 | let window: Window; 8 | let document: Document; 9 | let element: HTMLSpanElement; 10 | 11 | beforeEach(() => { 12 | window = new Window(); 13 | document = window.document; 14 | element = document.createElement('span'); 15 | }); 16 | 17 | describe('constructor()', () => { 18 | it('Should be an instanceof HTMLSpanElement', () => { 19 | expect(element instanceof HTMLSpanElement).toBe(true); 20 | }); 21 | }); 22 | }); 23 | -------------------------------------------------------------------------------- /packages/happy-dom/test/nodes/html-table-caption-element/HTMLTableCaptionElement.test.ts: -------------------------------------------------------------------------------- 1 | import HTMLTableCaptionElement from '../../../src/nodes/html-table-caption-element/HTMLTableCaptionElement.js'; 2 | import Window from '../../../src/window/Window.js'; 3 | import Document from '../../../src/nodes/document/Document.js'; 4 | import { beforeEach, describe, it, expect } from 'vitest'; 5 | 6 | describe('HTMLTableCaptionElement', () => { 7 | let window: Window; 8 | let document: Document; 9 | let element: HTMLTableCaptionElement; 10 | 11 | beforeEach(() => { 12 | window = new Window(); 13 | document = window.document; 14 | element = document.createElement('caption'); 15 | }); 16 | 17 | describe('constructor()', () => { 18 | it('Should be an instanceof HTMLTableCaptionElement', () => { 19 | expect(element instanceof HTMLTableCaptionElement).toBe(true); 20 | }); 21 | }); 22 | }); 23 | -------------------------------------------------------------------------------- /packages/happy-dom/test/nodes/html-table-col-element/HTMLTableColElement.test.ts: -------------------------------------------------------------------------------- 1 | import HTMLTableColElement from '../../../src/nodes/html-table-col-element/HTMLTableColElement.js'; 2 | import Window from '../../../src/window/Window.js'; 3 | import Document from '../../../src/nodes/document/Document.js'; 4 | import { beforeEach, describe, it, expect } from 'vitest'; 5 | 6 | describe('HTMLTableColElement', () => { 7 | let window: Window; 8 | let document: Document; 9 | let element: HTMLTableColElement; 10 | 11 | beforeEach(() => { 12 | window = new Window(); 13 | document = window.document; 14 | element = document.createElement('colgroup'); 15 | }); 16 | 17 | describe('constructor()', () => { 18 | it('Should be an instanceof HTMLTableColElement', () => { 19 | expect(element instanceof HTMLTableColElement).toBe(true); 20 | }); 21 | }); 22 | }); 23 | -------------------------------------------------------------------------------- /packages/happy-dom/test/nodes/html-u-list-element/HTMLUListElement.test.ts: -------------------------------------------------------------------------------- 1 | import HTMLUListElement from '../../../src/nodes/html-u-list-element/HTMLUListElement.js'; 2 | import Window from '../../../src/window/Window.js'; 3 | import Document from '../../../src/nodes/document/Document.js'; 4 | import { beforeEach, describe, it, expect } from 'vitest'; 5 | 6 | describe('HTMLUListElement', () => { 7 | let window: Window; 8 | let document: Document; 9 | let element: HTMLUListElement; 10 | 11 | beforeEach(() => { 12 | window = new Window(); 13 | document = window.document; 14 | element = document.createElement('ul'); 15 | }); 16 | 17 | describe('constructor()', () => { 18 | it('Should be an instanceof HTMLUListElement', () => { 19 | expect(element instanceof HTMLUListElement).toBe(true); 20 | }); 21 | }); 22 | }); 23 | -------------------------------------------------------------------------------- /packages/happy-dom/test/nodes/svg-animate-element/SVGAnimateElement.test.ts: -------------------------------------------------------------------------------- 1 | import SVGAnimateElement from '../../../src/nodes/svg-animate-element/SVGAnimateElement.js'; 2 | import Window from '../../../src/window/Window.js'; 3 | import Document from '../../../src/nodes/document/Document.js'; 4 | import { beforeEach, describe, it, expect } from 'vitest'; 5 | import SVGAnimationElement from '../../../src/nodes/svg-animation-element/SVGAnimationElement.js'; 6 | 7 | describe('SVGAnimateElement', () => { 8 | let window: Window; 9 | let document: Document; 10 | let element: SVGAnimateElement; 11 | 12 | beforeEach(() => { 13 | window = new Window(); 14 | document = window.document; 15 | element = document.createElementNS('http://www.w3.org/2000/svg', 'animate'); 16 | }); 17 | 18 | describe('constructor()', () => { 19 | it('Should be an instanceof SVGAnimateElement', () => { 20 | expect(element instanceof SVGAnimateElement).toBe(true); 21 | }); 22 | 23 | it('Should be an instanceof SVGAnimationElement', () => { 24 | expect(element instanceof SVGAnimationElement).toBe(true); 25 | }); 26 | }); 27 | }); 28 | -------------------------------------------------------------------------------- /packages/happy-dom/test/nodes/svg-defs-element/SVGDefsElement.test.ts: -------------------------------------------------------------------------------- 1 | import SVGDefsElement from '../../../src/nodes/svg-defs-element/SVGDefsElement.js'; 2 | import Window from '../../../src/window/Window.js'; 3 | import Document from '../../../src/nodes/document/Document.js'; 4 | import { beforeEach, describe, it, expect } from 'vitest'; 5 | import SVGGraphicsElement from '../../../src/nodes/svg-graphics-element/SVGGraphicsElement.js'; 6 | 7 | describe('SVGDefsElement', () => { 8 | let window: Window; 9 | let document: Document; 10 | let element: SVGDefsElement; 11 | 12 | beforeEach(() => { 13 | window = new Window(); 14 | document = window.document; 15 | element = document.createElementNS('http://www.w3.org/2000/svg', 'defs'); 16 | }); 17 | 18 | describe('constructor()', () => { 19 | it('Should be an instanceof SVGDefsElement', () => { 20 | expect(element instanceof SVGDefsElement).toBe(true); 21 | }); 22 | 23 | it('Should be an instanceof SVGGraphicsElement', () => { 24 | expect(element instanceof SVGGraphicsElement).toBe(true); 25 | }); 26 | }); 27 | }); 28 | -------------------------------------------------------------------------------- /packages/happy-dom/test/nodes/svg-desc-element/SVGDescElement.test.ts: -------------------------------------------------------------------------------- 1 | import SVGDescElement from '../../../src/nodes/svg-desc-element/SVGDescElement.js'; 2 | import Window from '../../../src/window/Window.js'; 3 | import Document from '../../../src/nodes/document/Document.js'; 4 | import { beforeEach, describe, it, expect } from 'vitest'; 5 | import SVGElement from '../../../src/nodes/svg-element/SVGElement.js'; 6 | 7 | describe('SVGDescElement', () => { 8 | let window: Window; 9 | let document: Document; 10 | let element: SVGDescElement; 11 | 12 | beforeEach(() => { 13 | window = new Window(); 14 | document = window.document; 15 | element = document.createElementNS('http://www.w3.org/2000/svg', 'desc'); 16 | }); 17 | 18 | describe('constructor()', () => { 19 | it('Should be an instanceof SVGDescElement', () => { 20 | expect(element instanceof SVGDescElement).toBe(true); 21 | }); 22 | 23 | it('Should be an instanceof SVGElement', () => { 24 | expect(element instanceof SVGElement).toBe(true); 25 | }); 26 | }); 27 | }); 28 | -------------------------------------------------------------------------------- /packages/happy-dom/test/nodes/svg-g-element/SVGGElement.test.ts: -------------------------------------------------------------------------------- 1 | import SVGGElement from '../../../src/nodes/svg-g-element/SVGGElement.js'; 2 | import Window from '../../../src/window/Window.js'; 3 | import Document from '../../../src/nodes/document/Document.js'; 4 | import { beforeEach, describe, it, expect } from 'vitest'; 5 | import SVGGraphicsElement from '../../../src/nodes/svg-graphics-element/SVGGraphicsElement.js'; 6 | import BrowserWindow from '../../../src/window/BrowserWindow.js'; 7 | 8 | describe('SVGGElement', () => { 9 | let window: BrowserWindow; 10 | let document: Document; 11 | let element: SVGGElement; 12 | 13 | beforeEach(() => { 14 | window = new Window(); 15 | document = window.document; 16 | element = document.createElementNS('http://www.w3.org/2000/svg', 'g'); 17 | }); 18 | 19 | describe('constructor()', () => { 20 | it('Should be an instanceof SVGGElement', () => { 21 | expect(element instanceof SVGGElement).toBe(true); 22 | }); 23 | 24 | it('Should be an instanceof SVGGraphicsElement', () => { 25 | expect(element instanceof SVGGraphicsElement).toBe(true); 26 | }); 27 | }); 28 | }); 29 | -------------------------------------------------------------------------------- /packages/happy-dom/test/nodes/svg-metadata-element/SVGMetadataElement.test.ts: -------------------------------------------------------------------------------- 1 | import SVGMetadataElement from '../../../src/nodes/svg-metadata-element/SVGMetadataElement.js'; 2 | import BrowserWindow from '../../../src/window/BrowserWindow.js'; 3 | import Document from '../../../src/nodes/document/Document.js'; 4 | import { beforeEach, describe, it, expect } from 'vitest'; 5 | import SVGElement from '../../../src/nodes/svg-element/SVGElement.js'; 6 | import Window from '../../../src/window/Window.js'; 7 | 8 | describe('SVGMetadataElement', () => { 9 | let window: BrowserWindow; 10 | let document: Document; 11 | let element: SVGMetadataElement; 12 | 13 | beforeEach(() => { 14 | window = new Window(); 15 | document = window.document; 16 | element = document.createElementNS('http://www.w3.org/2000/svg', 'metadata'); 17 | }); 18 | 19 | describe('constructor()', () => { 20 | it('Should be an instanceof SVGMetadataElement', () => { 21 | expect(element instanceof SVGMetadataElement).toBe(true); 22 | }); 23 | 24 | it('Should be an instanceof SVGElement', () => { 25 | expect(element instanceof SVGElement).toBe(true); 26 | }); 27 | }); 28 | }); 29 | -------------------------------------------------------------------------------- /packages/happy-dom/test/nodes/svg-path-element/SVGPathElement.test.ts: -------------------------------------------------------------------------------- 1 | import SVGPathElement from '../../../src/nodes/svg-path-element/SVGPathElement.js'; 2 | import Window from '../../../src/window/Window.js'; 3 | import BrowserWindow from '../../../src/window/BrowserWindow.js'; 4 | import { beforeEach, describe, it, expect } from 'vitest'; 5 | import SVGGeometryElement from '../../../src/nodes/svg-geometry-element/SVGGeometryElement.js'; 6 | import Document from '../../../src/nodes/document/Document.js'; 7 | 8 | describe('SVGPathElement', () => { 9 | let window: BrowserWindow; 10 | let document: Document; 11 | let element: SVGPathElement; 12 | 13 | beforeEach(() => { 14 | window = new Window(); 15 | document = window.document; 16 | element = document.createElementNS('http://www.w3.org/2000/svg', 'path'); 17 | }); 18 | 19 | describe('constructor()', () => { 20 | it('Should be an instanceof SVGPathElement', () => { 21 | expect(element instanceof SVGPathElement).toBe(true); 22 | }); 23 | 24 | it('Should be an instanceof SVGGeometryElement', () => { 25 | expect(element instanceof SVGGeometryElement).toBe(true); 26 | }); 27 | }); 28 | }); 29 | -------------------------------------------------------------------------------- /packages/happy-dom/test/nodes/svg-set-element/SVGSetElement.test.ts: -------------------------------------------------------------------------------- 1 | import SVGSetElement from '../../../src/nodes/svg-set-element/SVGSetElement.js'; 2 | import Window from '../../../src/window/Window.js'; 3 | import Document from '../../../src/nodes/document/Document.js'; 4 | import { beforeEach, describe, it, expect } from 'vitest'; 5 | import SVGAnimationElement from '../../../src/nodes/svg-animation-element/SVGAnimationElement.js'; 6 | import BrowserWindow from '../../../src/window/BrowserWindow.js'; 7 | 8 | describe('SVGSetElement', () => { 9 | let window: BrowserWindow; 10 | let document: Document; 11 | let element: SVGSetElement; 12 | 13 | beforeEach(() => { 14 | window = new Window(); 15 | document = window.document; 16 | element = document.createElementNS('http://www.w3.org/2000/svg', 'set'); 17 | }); 18 | 19 | describe('constructor()', () => { 20 | it('Should be an instanceof SVGSetElement', () => { 21 | expect(element instanceof SVGSetElement).toBe(true); 22 | }); 23 | 24 | it('Should be an instanceof SVGAnimationElement', () => { 25 | expect(element instanceof SVGAnimationElement).toBe(true); 26 | }); 27 | }); 28 | }); 29 | -------------------------------------------------------------------------------- /packages/happy-dom/test/nodes/svg-title-element/SVGTitleElement.test.ts: -------------------------------------------------------------------------------- 1 | import SVGTitleElement from '../../../src/nodes/svg-title-element/SVGTitleElement.js'; 2 | import Window from '../../../src/window/Window.js'; 3 | import Document from '../../../src/nodes/document/Document.js'; 4 | import { beforeEach, describe, it, expect } from 'vitest'; 5 | import BrowserWindow from '../../../src/window/BrowserWindow.js'; 6 | import SVGElement from '../../../src/nodes/svg-element/SVGElement.js'; 7 | 8 | describe('SVGTitleElement', () => { 9 | let window: BrowserWindow; 10 | let document: Document; 11 | let element: SVGTitleElement; 12 | 13 | beforeEach(() => { 14 | window = new Window(); 15 | document = window.document; 16 | element = document.createElementNS('http://www.w3.org/2000/svg', 'title'); 17 | }); 18 | 19 | describe('constructor()', () => { 20 | it('Should be an instanceof SVGTitleElement', () => { 21 | expect(element instanceof SVGTitleElement).toBe(true); 22 | }); 23 | 24 | it('Should be an instanceof SVGElement', () => { 25 | expect(element instanceof SVGElement).toBe(true); 26 | }); 27 | }); 28 | }); 29 | -------------------------------------------------------------------------------- /packages/happy-dom/test/nodes/svg-view-element/SVGViewElement.test.ts: -------------------------------------------------------------------------------- 1 | import SVGViewElement from '../../../src/nodes/svg-view-element/SVGViewElement.js'; 2 | import Window from '../../../src/window/Window.js'; 3 | import Document from '../../../src/nodes/document/Document.js'; 4 | import { beforeEach, describe, it, expect } from 'vitest'; 5 | import BrowserWindow from '../../../src/window/BrowserWindow.js'; 6 | import SVGElement from '../../../src/nodes/svg-element/SVGElement.js'; 7 | 8 | describe('SVGViewElement', () => { 9 | let window: BrowserWindow; 10 | let document: Document; 11 | let element: SVGViewElement; 12 | 13 | beforeEach(() => { 14 | window = new Window(); 15 | document = window.document; 16 | element = document.createElementNS('http://www.w3.org/2000/svg', 'view'); 17 | }); 18 | 19 | describe('constructor()', () => { 20 | it('Should be an instanceof SVGViewElement', () => { 21 | expect(element instanceof SVGViewElement).toBe(true); 22 | }); 23 | 24 | it('Should be an instanceof SVGElement', () => { 25 | expect(element instanceof SVGElement).toBe(true); 26 | }); 27 | }); 28 | }); 29 | -------------------------------------------------------------------------------- /packages/happy-dom/test/query-selector/data/QuerySelectorHTML.ts: -------------------------------------------------------------------------------- 1 | export default ` 2 |
3 | 4 |

Heading1

5 | 6 |
7 | Span1 8 | Span2 9 | Span3 10 |
11 |
12 |
13 | 14 |

Heading1

15 | 16 |
17 | `.trim(); 18 | -------------------------------------------------------------------------------- /packages/happy-dom/test/query-selector/data/QuerySelectorNthChildHTML.ts: -------------------------------------------------------------------------------- 1 | export default ` 2 |
3 | 4 | 5 |
6 | 7 | 8 |
9 | 10 | 11 |
12 | 13 |
14 | `.trim(); 15 | -------------------------------------------------------------------------------- /packages/happy-dom/test/tree-walker/data/TreeWalkerHTML.ts: -------------------------------------------------------------------------------- 1 | export default ` 2 | 3 | 4 | Title 5 | 6 | 7 |
8 | 9 | Bold 10 | 11 | Span 12 |
13 |
14 | 15 | Bold 16 | 17 |
18 | 19 | 20 | `.trim(); 21 | -------------------------------------------------------------------------------- /packages/happy-dom/test/types.d.ts: -------------------------------------------------------------------------------- 1 | declare let mockModule: (name: string, module: unknown) => void; 2 | declare let resetMockedModules: () => void; 3 | -------------------------------------------------------------------------------- /packages/happy-dom/test/url/URL.test.ts: -------------------------------------------------------------------------------- 1 | import URL from '../../src/url/URL.js'; 2 | import Blob from '../../src/file/Blob.js'; 3 | import { Blob as NodeJSBlob } from 'buffer'; 4 | import { describe, it, expect } from 'vitest'; 5 | 6 | describe('URL', () => { 7 | describe('createObjectURL()', () => { 8 | it('Creates a string containing a URL representing the object given in the parameter.', () => { 9 | const blob = new Blob(['TEST']); 10 | expect(URL.createObjectURL(blob).startsWith('blob:nodedata:')).toBe(true); 11 | }); 12 | 13 | it('Supports Node.js Blob objects.', () => { 14 | const blob = new NodeJSBlob(['TEST']); 15 | expect(URL.createObjectURL(blob).startsWith('blob:nodedata:')).toBe(true); 16 | }); 17 | }); 18 | }); 19 | -------------------------------------------------------------------------------- /packages/happy-dom/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "outDir": "lib", 4 | "rootDir": "src", 5 | "target": "ES2022", 6 | "declaration": true, 7 | "declarationMap": true, 8 | "module": "Node16", 9 | "moduleResolution": "Node16", 10 | "esModuleInterop": true, 11 | "experimentalDecorators": true, 12 | "allowSyntheticDefaultImports": true, 13 | "resolveJsonModule": true, 14 | "noUnusedLocals": true, 15 | "noUnusedParameters": true, 16 | "removeComments": false, 17 | "preserveConstEnums": true, 18 | "sourceMap": true, 19 | "skipLibCheck": true, 20 | "baseUrl": ".", 21 | "composite": false, 22 | "incremental": false, 23 | "lib": [ 24 | "ES2022" 25 | ], 26 | "types": [ 27 | "node" 28 | ] 29 | }, 30 | "include": [ 31 | "@types/node", 32 | "src" 33 | ], 34 | "exclude": [ 35 | "@types/dom" 36 | ] 37 | } -------------------------------------------------------------------------------- /packages/happy-dom/vitest.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vitest/config'; 2 | 3 | export default defineConfig({ 4 | test: { 5 | environment: 'node', 6 | include: ['./test/**/*.test.ts'], 7 | setupFiles: ['./test/setup.ts'], 8 | testTimeout: 500, 9 | restoreMocks: true 10 | } 11 | }); 12 | -------------------------------------------------------------------------------- /packages/integration-test/.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: http://EditorConfig.org 2 | 3 | # top-most EditorConfig file 4 | root = true 5 | 6 | # Indentation override for all JS under lib directory 7 | [{**.js,**.ts,**.json}] 8 | indent_style = tab -------------------------------------------------------------------------------- /packages/integration-test/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | tmp 3 | lib 4 | cjs -------------------------------------------------------------------------------- /packages/integration-test/.npmignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | tmp 3 | test 4 | .turbo 5 | npm-shrinkwrap.json -------------------------------------------------------------------------------- /packages/integration-test/.prettierrc.cjs: -------------------------------------------------------------------------------- 1 | module.exports = require('../happy-dom/.prettierrc.cjs'); 2 | -------------------------------------------------------------------------------- /packages/integration-test/README.md: -------------------------------------------------------------------------------- 1 | This package is used internally for testing the integration of Happy DOM in various environments. 2 | -------------------------------------------------------------------------------- /packages/integration-test/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@happy-dom/integration-test", 3 | "private": true, 4 | "version": "0.0.0", 5 | "license": "MIT", 6 | "author": "David Ortner", 7 | "description": "Private package used for integration testing of Happy DOM.", 8 | "type": "module", 9 | "publishConfig": { 10 | "access": "restricted" 11 | }, 12 | "scripts": { 13 | "test": "node ./test/index.js", 14 | "test:debug": "node --inspect-brk ./test/index.js" 15 | }, 16 | "dependencies": { 17 | "happy-dom": "^0.0.0" 18 | }, 19 | "devDependencies": { 20 | "@typescript-eslint/eslint-plugin": "^5.16.0", 21 | "@typescript-eslint/parser": "^5.16.0", 22 | "@types/node": "^16.11.7", 23 | "chalk": "^5.3.0", 24 | "prettier": "^2.6.0", 25 | "express": "^4.20.0" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /packages/integration-test/test/index.js: -------------------------------------------------------------------------------- 1 | await Promise.all([ 2 | import('./tests/Fetch.test.js'), 3 | import('./tests/XMLHttpRequest.test.js'), 4 | import('./tests/WindowGlobals.test.js'), 5 | import('./tests/BrowserExceptionObserver.test.js'), 6 | import('./tests/Browser.test.js'), 7 | import('./tests/CommonJS.test.cjs') 8 | ]); 9 | -------------------------------------------------------------------------------- /packages/integration-test/test/tests/CommonJS.test.cjs: -------------------------------------------------------------------------------- 1 | const { Window } = require('happy-dom'); 2 | 3 | const window = new Window(); 4 | const document = window.document; 5 | 6 | const element = document.createElement('div'); 7 | element.innerHTML = 'Test'; 8 | 9 | document.body.appendChild(element); 10 | 11 | if (document.body.innerHTML !== '
Test
') { 12 | throw new Error(`CommonJS doesn't work.`); 13 | } 14 | -------------------------------------------------------------------------------- /packages/jest-environment/.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: http://EditorConfig.org 2 | 3 | # top-most EditorConfig file 4 | root = true 5 | 6 | # Indentation override for all JS under lib directory 7 | [{**.js,**.ts,**.json}] 8 | indent_style = tab -------------------------------------------------------------------------------- /packages/jest-environment/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | tmp 3 | lib -------------------------------------------------------------------------------- /packages/jest-environment/.npmignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | tmp 3 | test 4 | .turbo 5 | npm-shrinkwrap.json -------------------------------------------------------------------------------- /packages/jest-environment/.prettierrc.cjs: -------------------------------------------------------------------------------- 1 | module.exports = require('../happy-dom/.prettierrc.cjs'); 2 | -------------------------------------------------------------------------------- /packages/jest-environment/test/angular/Angular.test.ts: -------------------------------------------------------------------------------- 1 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 2 | import { enableProdMode } from '@angular/core'; 3 | import 'zone.js'; 4 | import AngularModule from './AngularModule'; 5 | 6 | describe('Angular', () => { 7 | let appElement: Element; 8 | 9 | beforeEach(() => { 10 | appElement = document.createElement('app'); 11 | document.body.appendChild(appElement); 12 | }); 13 | 14 | afterEach(() => { 15 | document.body.removeChild(appElement); 16 | }); 17 | 18 | it('Tests integration with Angular.', async () => { 19 | enableProdMode(); 20 | await platformBrowserDynamic().bootstrapModule(AngularModule); 21 | expect(appElement.innerHTML).toBe('
Test
'); 22 | }); 23 | }); 24 | -------------------------------------------------------------------------------- /packages/jest-environment/test/angular/AngularComponent.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | /** 3 | * 4 | */ 5 | @Component({ 6 | selector: 'app', 7 | template: `
Test
` 8 | }) 9 | export default class AngularComponent {} 10 | -------------------------------------------------------------------------------- /packages/jest-environment/test/angular/AngularModule.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { BrowserModule } from '@angular/platform-browser'; 3 | import AngularComponent from './AngularComponent'; 4 | 5 | /** 6 | * 7 | */ 8 | @NgModule({ 9 | imports: [BrowserModule], 10 | declarations: [AngularComponent], 11 | bootstrap: [AngularComponent] 12 | }) 13 | export default class AngularModule {} 14 | -------------------------------------------------------------------------------- /packages/jest-environment/test/jquery/JQuery.test.ts: -------------------------------------------------------------------------------- 1 | import JQuery from 'jquery'; 2 | 3 | describe('JQuery', () => { 4 | beforeEach(() => { 5 | document.body.innerHTML = ` 6 |
7 | 8 | Bold 9 | 10 | Span 11 |
12 |
13 | 14 | Bold 15 | 16 |
17 | `; 18 | }); 19 | 20 | afterEach(() => { 21 | document.body.innerHTML = ''; 22 | }); 23 | 24 | it('Tests integration.', () => { 25 | JQuery('span').addClass('test-span'); 26 | expect(document.body.children[0].children[1].getAttribute('class')).toBe('test-span'); 27 | }); 28 | }); 29 | -------------------------------------------------------------------------------- /packages/jest-environment/test/lit-element/LitElementComponent.ts: -------------------------------------------------------------------------------- 1 | import { LitElement, TemplateResult, html, css, CSSResult } from '../../lib/node_modules/lit'; 2 | import { customElement, property } from '../../lib/node_modules/lit/decorators'; 3 | 4 | /** 5 | * 6 | */ 7 | @customElement('lit-element-component') 8 | export default class LitElementComponent extends LitElement { 9 | public static styles: CSSResult = css` 10 | span { 11 | color: green; 12 | } 13 | `; 14 | 15 | @property({ type: String }) 16 | public prop1: string = null; 17 | 18 | /** 19 | * Renders the component. 20 | */ 21 | public render(): TemplateResult { 22 | return html` Some text ${this.prop1}! `; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /packages/jest-environment/test/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "outDir": "../tmp", 4 | "rootDir": ".", 5 | "tsBuildInfoFile": "../tmp/.tsbuildinfo-test", 6 | "target": "ES2022", 7 | "declaration": true, 8 | "module": "CommonJS", 9 | "moduleResolution": "node", 10 | "esModuleInterop": true, 11 | "experimentalDecorators": true, 12 | "allowSyntheticDefaultImports": true, 13 | "resolveJsonModule": true, 14 | "noUnusedLocals": true, 15 | "noUnusedParameters": true, 16 | "removeComments": false, 17 | "preserveConstEnums": true, 18 | "sourceMap": true, 19 | "skipLibCheck": true, 20 | "baseUrl": ".", 21 | "composite": true, 22 | "incremental": true, 23 | "jsx": "react", 24 | "types": [ 25 | "jest" 26 | ], 27 | "lib": [ 28 | "ES2022", 29 | "dom" 30 | ] 31 | }, 32 | "include": [ 33 | "@types/node", 34 | "@types/jest", 35 | "@types/react", 36 | "@types/react-dom", 37 | "." 38 | ] 39 | } -------------------------------------------------------------------------------- /packages/jest-environment/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "outDir": "lib", 4 | "rootDir": "src", 5 | "tsBuildInfoFile": "tmp/.tsbuildinfo", 6 | "target": "ES2022", 7 | "declaration": true, 8 | "declarationMap": true, 9 | "module": "CommonJS", 10 | "moduleResolution": "node", 11 | "esModuleInterop": true, 12 | "experimentalDecorators": true, 13 | "allowSyntheticDefaultImports": true, 14 | "resolveJsonModule": true, 15 | "noUnusedLocals": true, 16 | "noUnusedParameters": true, 17 | "removeComments": false, 18 | "preserveConstEnums": true, 19 | "sourceMap": true, 20 | "skipLibCheck": true, 21 | "baseUrl": ".", 22 | "composite": true, 23 | "incremental": true, 24 | "types": [ 25 | "node" 26 | ], 27 | "lib": [ 28 | "ES2022", 29 | "dom" 30 | ] 31 | }, 32 | "include": [ 33 | "@types/node", 34 | "src" 35 | ] 36 | } -------------------------------------------------------------------------------- /vitest.workspace.ts: -------------------------------------------------------------------------------- 1 | import { defineWorkspace } from 'vitest/config'; 2 | 3 | export default defineWorkspace(['./packages/happy-dom/vitest.config.ts']); 4 | --------------------------------------------------------------------------------