diff --git a/inputfiles/overridingTypes.jsonc b/inputfiles/overridingTypes.jsonc index 1e86d1786..c625ea1a9 100644 --- a/inputfiles/overridingTypes.jsonc +++ b/inputfiles/overridingTypes.jsonc @@ -536,60 +536,6 @@ ] } } - }, - "properties": { - "property": { - "defaultView": { - "name": "defaultView", - "overrideType": "WindowProxy & typeof globalThis" - }, - "documentElement": { - "name": "documentElement", - "overrideType": "HTMLElement", - "nullable": false - }, - "head": { - "nullable": false - }, - "anchors": { - "name": "anchors", - "overrideType": "HTMLCollectionOf" - }, - "embeds": { - "name": "embeds", - "overrideType": "HTMLCollectionOf" - }, - "forms": { - "name": "forms", - "overrideType": "HTMLCollectionOf" - }, - "images": { - "name": "images", - "overrideType": "HTMLCollectionOf" - }, - "links": { - "name": "links", - "overrideType": "HTMLCollectionOf" - }, - "plugins": { - "name": "plugins", - "overrideType": "HTMLCollectionOf" - }, - "scripts": { - "name": "scripts", - "overrideType": "HTMLCollectionOf" - }, - "location": { - // Pre-TS-5.1 hack to make document.location assignable - "readonly": false, - // Technically this can be null for a detached iframe. - // But that's an edge case and flipping this also breaks compatibility. - "nullable": false - }, - "body": { - "nullable": false - } - } } }, "DocumentFragment": { diff --git a/inputfiles/patches/dom.kdl b/inputfiles/patches/dom.kdl index 146a24389..99ee4a789 100644 --- a/inputfiles/patches/dom.kdl +++ b/inputfiles/patches/dom.kdl @@ -11,6 +11,12 @@ interface EventListenerObject noInterfaceObject=#true { } } +interface Document { + property documentElement { + type HTMLElement nullable=#false + } +} + enum InsertPosition { beforebegin beforeend diff --git a/inputfiles/patches/html.kdl b/inputfiles/patches/html.kdl index 00b0380a4..2dc299e82 100644 --- a/inputfiles/patches/html.kdl +++ b/inputfiles/patches/html.kdl @@ -79,6 +79,66 @@ dictionary StructuredSerializeOptions { } } +// https://html.spec.whatwg.org/multipage/dom.html#the-document-object +interface Document { + // Pre-TS-5.1 hack to make document.location assignable + property location readonly=#false { + // Technically this can be null for a detached iframe. + // But that's an edge case and flipping this also breaks compatibility. + type nullable=#false + } + + // Similarly body and head are mostly non-null for HTML documents. + // body can frequently be null when executing scripts in head, but flipping + // it also breaks compatibiliity. + property body { + type nullable=#false + } + property head { + type nullable=#false + } + + // More specific types for HTMLCollection properties + property anchors { + type HTMLCollectionOf { + type HTMLAnchorElement + } + } + property embeds { + type HTMLCollectionOf { + type HTMLEmbedElement + } + } + property forms { + type HTMLCollectionOf { + type HTMLFormElement + } + } + property images { + type HTMLCollectionOf { + type HTMLImageElement + } + } + property links { + type HTMLCollectionOf { + type HTMLAnchorElement + type HTMLAreaElement + } + } + property plugins { + type HTMLCollectionOf { + type HTMLEmbedElement + } + } + property scripts { + type HTMLCollectionOf { + type HTMLScriptElement + } + } + + property defaultView overrideType="WindowProxy & typeof globalThis" +} + removals { dictionary CanvasRenderingContext2DSettings { member colorType // Blink-only as of 2025-12, being tested in WebKit