From bff030ea6e20f2dd1ece7c6242074aca4ffb2386 Mon Sep 17 00:00:00 2001 From: Bashamega Date: Wed, 31 Dec 2025 07:08:54 +0200 Subject: [PATCH 1/7] Migrate Document element properties --- inputfiles/overridingTypes.jsonc | 48 +---------------------- inputfiles/patches/dom.kdl | 65 ++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 47 deletions(-) diff --git a/inputfiles/overridingTypes.jsonc b/inputfiles/overridingTypes.jsonc index 1e86d1786..9a78b32e4 100644 --- a/inputfiles/overridingTypes.jsonc +++ b/inputfiles/overridingTypes.jsonc @@ -542,53 +542,7 @@ "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 - } + } } } }, diff --git a/inputfiles/patches/dom.kdl b/inputfiles/patches/dom.kdl index 146a24389..880f6a0ef 100644 --- a/inputfiles/patches/dom.kdl +++ b/inputfiles/patches/dom.kdl @@ -11,6 +11,71 @@ interface EventListenerObject noInterfaceObject=#true { } } +interface Document { + property anchors nullable=#false { + type HTMLCollectionOf { + type HTMLAnchorElement + } + } + + property body { + type nullable=#false + } + + property documentElement { + type HTMLElement nullable=#false + } + + property embeds nullable=#false { + type HTMLCollectionOf { + type HTMLEmbedElement + } + } + + property forms nullable=#false { + type HTMLCollectionOf { + type HTMLFormElement + } + } + + property head { + type nullable=#false + } + + property images nullable=#false { + type HTMLCollectionOf { + type HTMLImageElement + } + } + + property links nullable=#false { + type HTMLCollectionOf { + type HTMLAnchorElement + type HTMLAreaElement + } + } + + // 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 + } + + property plugins nullable=#false { + type HTMLCollectionOf { + type HTMLEmbedElement + } + } + + property scripts nullable=#false { + type HTMLCollectionOf { + type HTMLScriptElement + } + } +} + + enum InsertPosition { beforebegin beforeend From 3c006f60a7f4f47a747578e46c757c7ef0f75e4f Mon Sep 17 00:00:00 2001 From: Bashamega Date: Wed, 31 Dec 2025 07:09:44 +0200 Subject: [PATCH 2/7] - --- inputfiles/patches/dom.kdl | 1 - 1 file changed, 1 deletion(-) diff --git a/inputfiles/patches/dom.kdl b/inputfiles/patches/dom.kdl index 880f6a0ef..225f813b1 100644 --- a/inputfiles/patches/dom.kdl +++ b/inputfiles/patches/dom.kdl @@ -75,7 +75,6 @@ interface Document { } } - enum InsertPosition { beforebegin beforeend From c19fbbfa1f83dfbfa93bef9f66ad89458dfb523b Mon Sep 17 00:00:00 2001 From: Bashamega Date: Wed, 31 Dec 2025 13:13:46 +0200 Subject: [PATCH 3/7] Update --- inputfiles/overridingTypes.jsonc | 8 -------- inputfiles/patches/dom.kdl | 2 ++ 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/inputfiles/overridingTypes.jsonc b/inputfiles/overridingTypes.jsonc index 9a78b32e4..c625ea1a9 100644 --- a/inputfiles/overridingTypes.jsonc +++ b/inputfiles/overridingTypes.jsonc @@ -536,14 +536,6 @@ ] } } - }, - "properties": { - "property": { - "defaultView": { - "name": "defaultView", - "overrideType": "WindowProxy & typeof globalThis" - } - } } }, "DocumentFragment": { diff --git a/inputfiles/patches/dom.kdl b/inputfiles/patches/dom.kdl index 225f813b1..fb507ad0d 100644 --- a/inputfiles/patches/dom.kdl +++ b/inputfiles/patches/dom.kdl @@ -73,6 +73,8 @@ interface Document { type HTMLScriptElement } } + + property defaultView overrideType="WindowProxy & typeof globalThis" } enum InsertPosition { From a94c6cb4aeeb9948c8787653c384b5100be6ff3d Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Wed, 31 Dec 2025 20:47:10 +0100 Subject: [PATCH 4/7] moving `documentElement` to dom, reordering properties --- inputfiles/patches/dom.kdl | 51 ++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 29 deletions(-) diff --git a/inputfiles/patches/dom.kdl b/inputfiles/patches/dom.kdl index fb507ad0d..514f131b7 100644 --- a/inputfiles/patches/dom.kdl +++ b/inputfiles/patches/dom.kdl @@ -12,63 +12,56 @@ interface EventListenerObject noInterfaceObject=#true { } interface Document { - property anchors nullable=#false { - type HTMLCollectionOf { - type HTMLAnchorElement - } + // 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 documentElement { - type HTMLElement nullable=#false + property head { + type nullable=#false } - property embeds nullable=#false { + // More specific types for HTMLCollection properties + property anchors { + type HTMLCollectionOf { + type HTMLAnchorElement + } + } + property embeds { type HTMLCollectionOf { type HTMLEmbedElement } } - - property forms nullable=#false { + property forms { type HTMLCollectionOf { type HTMLFormElement } } - - property head { - type nullable=#false - } - - property images nullable=#false { + property images { type HTMLCollectionOf { type HTMLImageElement } } - - property links nullable=#false { + property links { type HTMLCollectionOf { type HTMLAnchorElement type HTMLAreaElement } } - - // 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 - } - - property plugins nullable=#false { + property plugins { type HTMLCollectionOf { type HTMLEmbedElement } } - - property scripts nullable=#false { + property scripts { type HTMLCollectionOf { type HTMLScriptElement } From 80288c4f5966c7365ec00813c12982c769a89643 Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Wed, 31 Dec 2025 20:48:13 +0100 Subject: [PATCH 5/7] err actually most of this is from HTML. Removed deprecated properties and added documentElement with non-nullable type. --- inputfiles/patches/dom.kdl | 57 ++------------------------------------ 1 file changed, 2 insertions(+), 55 deletions(-) diff --git a/inputfiles/patches/dom.kdl b/inputfiles/patches/dom.kdl index 514f131b7..99ee4a789 100644 --- a/inputfiles/patches/dom.kdl +++ b/inputfiles/patches/dom.kdl @@ -12,62 +12,9 @@ interface EventListenerObject noInterfaceObject=#true { } 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 + property documentElement { + type HTMLElement 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" } enum InsertPosition { From a578f27c58b7d4f958bbe880aee94d576ae77f50 Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Wed, 31 Dec 2025 20:49:25 +0100 Subject: [PATCH 6/7] put things into html --- inputfiles/patches/html.kdl | 60 +++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) 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 From c9de82fd265f0fd21f920e8fb4ff6dbe56180902 Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Thu, 1 Jan 2026 21:00:55 +0100 Subject: [PATCH 7/7] globals.kdl --- inputfiles/patches/events.kdl | 2 ++ inputfiles/patches/globals.kdl | 5 +++++ inputfiles/patches/html.kdl | 2 -- 3 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 inputfiles/patches/globals.kdl diff --git a/inputfiles/patches/events.kdl b/inputfiles/patches/events.kdl index f002f4218..4d11ba797 100644 --- a/inputfiles/patches/events.kdl +++ b/inputfiles/patches/events.kdl @@ -1,3 +1,5 @@ +// Events should ideally be autogenerated. + interface-mixin AbstractWorker { event error type=ErrorEvent } diff --git a/inputfiles/patches/globals.kdl b/inputfiles/patches/globals.kdl new file mode 100644 index 000000000..396ed5e7f --- /dev/null +++ b/inputfiles/patches/globals.kdl @@ -0,0 +1,5 @@ +// Emitter should ideally add globalThis automatically. + +interface Document { + property defaultView overrideType="WindowProxy & typeof globalThis" +} diff --git a/inputfiles/patches/html.kdl b/inputfiles/patches/html.kdl index 2dc299e82..9d9f56fbb 100644 --- a/inputfiles/patches/html.kdl +++ b/inputfiles/patches/html.kdl @@ -135,8 +135,6 @@ interface Document { type HTMLScriptElement } } - - property defaultView overrideType="WindowProxy & typeof globalThis" } removals {