From c1f04d842183cf037dcdb3beba9ce918289dd882 Mon Sep 17 00:00:00 2001 From: Bashamega Date: Sun, 28 Dec 2025 07:45:50 +0200 Subject: [PATCH 1/6] Migrate HTML Input --- baselines/dom.generated.d.ts | 5 ++-- baselines/ts5.5/dom.generated.d.ts | 5 ++-- baselines/ts5.6/dom.generated.d.ts | 5 ++-- baselines/ts5.9/dom.generated.d.ts | 5 ++-- inputfiles/addedTypes.jsonc | 13 +++------ inputfiles/knownTypes.json | 1 - inputfiles/overridingTypes.jsonc | 42 ------------------------------ inputfiles/patches/html.kdl | 16 ++++++++++++ src/build/patches.ts | 1 + 9 files changed, 33 insertions(+), 60 deletions(-) diff --git a/baselines/dom.generated.d.ts b/baselines/dom.generated.d.ts index a606f0991..2555232f5 100644 --- a/baselines/dom.generated.d.ts +++ b/baselines/dom.generated.d.ts @@ -17341,7 +17341,7 @@ interface HTMLInputElement extends HTMLElement, PopoverTargetAttributes { * * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLInputElement/selectionDirection) */ - selectionDirection: "forward" | "backward" | "none" | null; + selectionDirection: Directions | null; /** * The **`selectionEnd`** property of the HTMLInputElement interface is a number that represents the end index of the selected text. That is, it represents the index of the character immediately following the selection. Likewise, when there is no selection, this returns the offset of the character immediately following the current text input cursor position. * @@ -17470,7 +17470,7 @@ interface HTMLInputElement extends HTMLElement, PopoverTargetAttributes { * * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLInputElement/setSelectionRange) */ - setSelectionRange(start: number | null, end: number | null, direction?: "forward" | "backward" | "none"): void; + setSelectionRange(start: number | null, end: number | null, direction?: Directions): void; /** * The **`HTMLInputElement.showPicker()`** method displays the browser picker for an input element. * @@ -42434,6 +42434,7 @@ type ConstrainDouble = number | ConstrainDoubleRange; type ConstrainULong = number | ConstrainULongRange; type CookieList = CookieListItem[]; type DOMHighResTimeStamp = number; +type Directions = "forward" | "backward" | "none"; type EpochTimeStamp = number; type EventListenerOrEventListenerObject = EventListener | EventListenerObject; type FileSystemWriteChunkType = BufferSource | Blob | string | WriteParams; diff --git a/baselines/ts5.5/dom.generated.d.ts b/baselines/ts5.5/dom.generated.d.ts index 6b1ce43d3..d8b316670 100644 --- a/baselines/ts5.5/dom.generated.d.ts +++ b/baselines/ts5.5/dom.generated.d.ts @@ -17323,7 +17323,7 @@ interface HTMLInputElement extends HTMLElement, PopoverTargetAttributes { * * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLInputElement/selectionDirection) */ - selectionDirection: "forward" | "backward" | "none" | null; + selectionDirection: Directions | null; /** * The **`selectionEnd`** property of the HTMLInputElement interface is a number that represents the end index of the selected text. That is, it represents the index of the character immediately following the selection. Likewise, when there is no selection, this returns the offset of the character immediately following the current text input cursor position. * @@ -17452,7 +17452,7 @@ interface HTMLInputElement extends HTMLElement, PopoverTargetAttributes { * * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLInputElement/setSelectionRange) */ - setSelectionRange(start: number | null, end: number | null, direction?: "forward" | "backward" | "none"): void; + setSelectionRange(start: number | null, end: number | null, direction?: Directions): void; /** * The **`HTMLInputElement.showPicker()`** method displays the browser picker for an input element. * @@ -42408,6 +42408,7 @@ type ConstrainDouble = number | ConstrainDoubleRange; type ConstrainULong = number | ConstrainULongRange; type CookieList = CookieListItem[]; type DOMHighResTimeStamp = number; +type Directions = "forward" | "backward" | "none"; type EpochTimeStamp = number; type EventListenerOrEventListenerObject = EventListener | EventListenerObject; type FileSystemWriteChunkType = BufferSource | Blob | string | WriteParams; diff --git a/baselines/ts5.6/dom.generated.d.ts b/baselines/ts5.6/dom.generated.d.ts index e02807e16..b4f1bed31 100644 --- a/baselines/ts5.6/dom.generated.d.ts +++ b/baselines/ts5.6/dom.generated.d.ts @@ -17338,7 +17338,7 @@ interface HTMLInputElement extends HTMLElement, PopoverTargetAttributes { * * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLInputElement/selectionDirection) */ - selectionDirection: "forward" | "backward" | "none" | null; + selectionDirection: Directions | null; /** * The **`selectionEnd`** property of the HTMLInputElement interface is a number that represents the end index of the selected text. That is, it represents the index of the character immediately following the selection. Likewise, when there is no selection, this returns the offset of the character immediately following the current text input cursor position. * @@ -17467,7 +17467,7 @@ interface HTMLInputElement extends HTMLElement, PopoverTargetAttributes { * * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLInputElement/setSelectionRange) */ - setSelectionRange(start: number | null, end: number | null, direction?: "forward" | "backward" | "none"): void; + setSelectionRange(start: number | null, end: number | null, direction?: Directions): void; /** * The **`HTMLInputElement.showPicker()`** method displays the browser picker for an input element. * @@ -42431,6 +42431,7 @@ type ConstrainDouble = number | ConstrainDoubleRange; type ConstrainULong = number | ConstrainULongRange; type CookieList = CookieListItem[]; type DOMHighResTimeStamp = number; +type Directions = "forward" | "backward" | "none"; type EpochTimeStamp = number; type EventListenerOrEventListenerObject = EventListener | EventListenerObject; type FileSystemWriteChunkType = BufferSource | Blob | string | WriteParams; diff --git a/baselines/ts5.9/dom.generated.d.ts b/baselines/ts5.9/dom.generated.d.ts index ad1f341d2..b5817a16f 100644 --- a/baselines/ts5.9/dom.generated.d.ts +++ b/baselines/ts5.9/dom.generated.d.ts @@ -17338,7 +17338,7 @@ interface HTMLInputElement extends HTMLElement, PopoverTargetAttributes { * * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLInputElement/selectionDirection) */ - selectionDirection: "forward" | "backward" | "none" | null; + selectionDirection: Directions | null; /** * The **`selectionEnd`** property of the HTMLInputElement interface is a number that represents the end index of the selected text. That is, it represents the index of the character immediately following the selection. Likewise, when there is no selection, this returns the offset of the character immediately following the current text input cursor position. * @@ -17467,7 +17467,7 @@ interface HTMLInputElement extends HTMLElement, PopoverTargetAttributes { * * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLInputElement/setSelectionRange) */ - setSelectionRange(start: number | null, end: number | null, direction?: "forward" | "backward" | "none"): void; + setSelectionRange(start: number | null, end: number | null, direction?: Directions): void; /** * The **`HTMLInputElement.showPicker()`** method displays the browser picker for an input element. * @@ -42431,6 +42431,7 @@ type ConstrainDouble = number | ConstrainDoubleRange; type ConstrainULong = number | ConstrainULongRange; type CookieList = CookieListItem[]; type DOMHighResTimeStamp = number; +type Directions = "forward" | "backward" | "none"; type EpochTimeStamp = number; type EventListenerOrEventListenerObject = EventListener | EventListenerObject; type FileSystemWriteChunkType = BufferSource | Blob | string | WriteParams; diff --git a/inputfiles/addedTypes.jsonc b/inputfiles/addedTypes.jsonc index e377c9546..baf54fa5b 100644 --- a/inputfiles/addedTypes.jsonc +++ b/inputfiles/addedTypes.jsonc @@ -305,15 +305,6 @@ "name": "IDBOpenDBRequest", "extends": "IDBRequest" }, - "HTMLInputElement": { - "properties": { - "property": { - "labels": { - "overrideType": "NodeListOf" - } - } - } - }, // The spec removed `timestamp` but browsers still have it. // https://github.com/w3c/webrtc-encoded-transform/pull/204 "RTCEncodedAudioFrame": { @@ -606,6 +597,10 @@ // Full spec at https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill. "name": "AutoFill", "overrideType": "AutoFillBase | `${OptionalPrefixToken}${OptionalPrefixToken}${AutoFillField}${OptionalPostfixToken}`" + }, + { + "name": "Directions", + "overrideType": "\"forward\" | \"backward\" | \"none\"" } ] } diff --git a/inputfiles/knownTypes.json b/inputfiles/knownTypes.json index df1b8cda5..a16e077ba 100644 --- a/inputfiles/knownTypes.json +++ b/inputfiles/knownTypes.json @@ -14,7 +14,6 @@ "AutoFillContactField", "AutoFillField", "AutoFillCredentialField", - "AutoFill", "BigInteger", "ClientQueryOptions", "ClientTypes", diff --git a/inputfiles/overridingTypes.jsonc b/inputfiles/overridingTypes.jsonc index af2258aa5..1e86d1786 100644 --- a/inputfiles/overridingTypes.jsonc +++ b/inputfiles/overridingTypes.jsonc @@ -1445,48 +1445,6 @@ } } }, - "HTMLInputElement": { - "properties": { - "property": { - "autocomplete": { - "name": "autocomplete", - "overrideType": "AutoFill" - }, - "selectionDirection": { - "name": "selectionDirection", - "overrideType": "\"forward\" | \"backward\" | \"none\"" - }, - "valueAsDate": { - "name": "valueAsDate", - "overrideType": "Date" - } - } - }, - "methods": { - "method": { - "setSelectionRange": { - "signature": { - "0": { - "param": [ - { - "name": "start", - "nullable": true - }, - { - "name": "end", - "nullable": true - }, - { - "name": "direction", - "overrideType": "\"forward\" | \"backward\" | \"none\"" - } - ] - } - } - } - } - } - }, "MouseEvent": { "methods": { "method": { diff --git a/inputfiles/patches/html.kdl b/inputfiles/patches/html.kdl index edb9f0ed5..6be255e0d 100644 --- a/inputfiles/patches/html.kdl +++ b/inputfiles/patches/html.kdl @@ -47,6 +47,22 @@ interface HTMLImageElement { property loading overrideType=#""eager" | "lazy""# } +interface HTMLInputElement { + property labels { + type NodeListOf { + type HTMLLabelElement + } + } + property autocomplete type=AutoFill + property valueAsDate type=Date + property selectionDirection type=Directions + method setSelectionRange signatureIndex=0 { + param start nullable=#true + param end nullable=#true + param direction type=Directions + } +} + dictionary StructuredSerializeOptions { member transfer { type { diff --git a/src/build/patches.ts b/src/build/patches.ts index a2515c73f..4f20c59d8 100644 --- a/src/build/patches.ts +++ b/src/build/patches.ts @@ -320,6 +320,7 @@ function handleParam(node: Node) { name, ...optionalMember("type", "string", node.properties?.type), ...optionalMember("overrideType", "string", node.properties?.overrideType), + ...optionalMember("nullable", "boolean", node.properties?.nullable), additionalTypes, }; } From 4ad16bd52b51c45ad175e58e00c85d93714d89a7 Mon Sep 17 00:00:00 2001 From: Bashamega Date: Tue, 30 Dec 2025 14:08:08 +0200 Subject: [PATCH 2/6] Migrate KDL --- inputfiles/addedTypes.jsonc | 4 ---- inputfiles/patches/html.kdl | 2 ++ src/build/patches.ts | 1 + 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/inputfiles/addedTypes.jsonc b/inputfiles/addedTypes.jsonc index 43c724a15..9260d0783 100644 --- a/inputfiles/addedTypes.jsonc +++ b/inputfiles/addedTypes.jsonc @@ -546,10 +546,6 @@ // Full spec at https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill. "name": "AutoFill", "overrideType": "AutoFillBase | `${OptionalPrefixToken}${OptionalPrefixToken}${AutoFillField}${OptionalPostfixToken}`" - }, - { - "name": "Directions", - "overrideType": "\"forward\" | \"backward\" | \"none\"" } ] } diff --git a/inputfiles/patches/html.kdl b/inputfiles/patches/html.kdl index 6be255e0d..9d0c08148 100644 --- a/inputfiles/patches/html.kdl +++ b/inputfiles/patches/html.kdl @@ -63,6 +63,8 @@ interface HTMLInputElement { } } +typedef Directions overrideType=#""forward" | "backward" | "none""# + dictionary StructuredSerializeOptions { member transfer { type { diff --git a/src/build/patches.ts b/src/build/patches.ts index 2ce089785..c5b25524a 100644 --- a/src/build/patches.ts +++ b/src/build/patches.ts @@ -453,6 +453,7 @@ function handleTypedef(node: Node): DeepPartial { "string", node.properties?.legacyNamespace, ), + ...optionalMember("overrideType", "string", node.properties?.overrideType), }; } From 2d928d3180c756891093fcf19a99f609193598f8 Mon Sep 17 00:00:00 2001 From: Bashamega Date: Tue, 30 Dec 2025 14:10:03 +0200 Subject: [PATCH 3/6] Rename type --- baselines/dom.generated.d.ts | 7 ++++--- baselines/ts5.5/dom.generated.d.ts | 7 ++++--- baselines/ts5.6/dom.generated.d.ts | 7 ++++--- baselines/ts5.9/dom.generated.d.ts | 7 ++++--- inputfiles/patches/html.kdl | 6 +++--- 5 files changed, 19 insertions(+), 15 deletions(-) diff --git a/baselines/dom.generated.d.ts b/baselines/dom.generated.d.ts index 5ecf646bc..b3b17abc5 100644 --- a/baselines/dom.generated.d.ts +++ b/baselines/dom.generated.d.ts @@ -17154,6 +17154,7 @@ declare var HTMLImageElement: { * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLInputElement) */ interface HTMLInputElement extends HTMLElement, PopoverTargetAttributes { + SelectionDirection: SelectionDirection; /** * The **`accept`** property of the HTMLInputElement interface reflects the element's accept attribute, generally a comma-separated list of unique file type specifiers providing a hint for the expected file type for an of type file. If the attribute is not explicitly set, the accept property is an empty string. * @@ -17341,7 +17342,7 @@ interface HTMLInputElement extends HTMLElement, PopoverTargetAttributes { * * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLInputElement/selectionDirection) */ - selectionDirection: Directions | null; + selectionDirection: string | null; /** * The **`selectionEnd`** property of the HTMLInputElement interface is a number that represents the end index of the selected text. That is, it represents the index of the character immediately following the selection. Likewise, when there is no selection, this returns the offset of the character immediately following the current text input cursor position. * @@ -17470,7 +17471,7 @@ interface HTMLInputElement extends HTMLElement, PopoverTargetAttributes { * * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLInputElement/setSelectionRange) */ - setSelectionRange(start: number | null, end: number | null, direction?: Directions): void; + setSelectionRange(start: number | null, end: number | null, direction?: SelectionDirection): void; /** * The **`HTMLInputElement.showPicker()`** method displays the browser picker for an input element. * @@ -42433,7 +42434,6 @@ type ConstrainDouble = number | ConstrainDoubleRange; type ConstrainULong = number | ConstrainULongRange; type CookieList = CookieListItem[]; type DOMHighResTimeStamp = number; -type Directions = "forward" | "backward" | "none"; type EpochTimeStamp = number; type EventListenerOrEventListenerObject = EventListener | EventListenerObject; type FileSystemWriteChunkType = BufferSource | Blob | string | WriteParams; @@ -42479,6 +42479,7 @@ type ReadableStreamReader = ReadableStreamDefaultReader | ReadableStreamBY type RenderingContext = CanvasRenderingContext2D | ImageBitmapRenderingContext | WebGLRenderingContext | WebGL2RenderingContext; type ReportList = Report[]; type RequestInfo = Request | string; +type SelectionDirection = "forward" | "backward" | "none"; type TexImageSource = ImageBitmap | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | OffscreenCanvas | VideoFrame; type TimerHandler = string | Function; type Transferable = OffscreenCanvas | ImageBitmap | MessagePort | MediaSourceHandle | ReadableStream | WritableStream | TransformStream | AudioData | VideoFrame | RTCDataChannel | ArrayBuffer; diff --git a/baselines/ts5.5/dom.generated.d.ts b/baselines/ts5.5/dom.generated.d.ts index 3de68c6ca..01a384d94 100644 --- a/baselines/ts5.5/dom.generated.d.ts +++ b/baselines/ts5.5/dom.generated.d.ts @@ -17136,6 +17136,7 @@ declare var HTMLImageElement: { * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLInputElement) */ interface HTMLInputElement extends HTMLElement, PopoverTargetAttributes { + SelectionDirection: SelectionDirection; /** * The **`accept`** property of the HTMLInputElement interface reflects the element's accept attribute, generally a comma-separated list of unique file type specifiers providing a hint for the expected file type for an of type file. If the attribute is not explicitly set, the accept property is an empty string. * @@ -17323,7 +17324,7 @@ interface HTMLInputElement extends HTMLElement, PopoverTargetAttributes { * * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLInputElement/selectionDirection) */ - selectionDirection: Directions | null; + selectionDirection: string | null; /** * The **`selectionEnd`** property of the HTMLInputElement interface is a number that represents the end index of the selected text. That is, it represents the index of the character immediately following the selection. Likewise, when there is no selection, this returns the offset of the character immediately following the current text input cursor position. * @@ -17452,7 +17453,7 @@ interface HTMLInputElement extends HTMLElement, PopoverTargetAttributes { * * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLInputElement/setSelectionRange) */ - setSelectionRange(start: number | null, end: number | null, direction?: Directions): void; + setSelectionRange(start: number | null, end: number | null, direction?: SelectionDirection): void; /** * The **`HTMLInputElement.showPicker()`** method displays the browser picker for an input element. * @@ -42407,7 +42408,6 @@ type ConstrainDouble = number | ConstrainDoubleRange; type ConstrainULong = number | ConstrainULongRange; type CookieList = CookieListItem[]; type DOMHighResTimeStamp = number; -type Directions = "forward" | "backward" | "none"; type EpochTimeStamp = number; type EventListenerOrEventListenerObject = EventListener | EventListenerObject; type FileSystemWriteChunkType = BufferSource | Blob | string | WriteParams; @@ -42453,6 +42453,7 @@ type ReadableStreamReader = ReadableStreamDefaultReader | ReadableStreamBY type RenderingContext = CanvasRenderingContext2D | ImageBitmapRenderingContext | WebGLRenderingContext | WebGL2RenderingContext; type ReportList = Report[]; type RequestInfo = Request | string; +type SelectionDirection = "forward" | "backward" | "none"; type TexImageSource = ImageBitmap | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | OffscreenCanvas | VideoFrame; type TimerHandler = string | Function; type Transferable = OffscreenCanvas | ImageBitmap | MessagePort | MediaSourceHandle | ReadableStream | WritableStream | TransformStream | AudioData | VideoFrame | RTCDataChannel | ArrayBuffer; diff --git a/baselines/ts5.6/dom.generated.d.ts b/baselines/ts5.6/dom.generated.d.ts index a29d82331..bd9a9bca8 100644 --- a/baselines/ts5.6/dom.generated.d.ts +++ b/baselines/ts5.6/dom.generated.d.ts @@ -17151,6 +17151,7 @@ declare var HTMLImageElement: { * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLInputElement) */ interface HTMLInputElement extends HTMLElement, PopoverTargetAttributes { + SelectionDirection: SelectionDirection; /** * The **`accept`** property of the HTMLInputElement interface reflects the element's accept attribute, generally a comma-separated list of unique file type specifiers providing a hint for the expected file type for an of type file. If the attribute is not explicitly set, the accept property is an empty string. * @@ -17338,7 +17339,7 @@ interface HTMLInputElement extends HTMLElement, PopoverTargetAttributes { * * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLInputElement/selectionDirection) */ - selectionDirection: Directions | null; + selectionDirection: string | null; /** * The **`selectionEnd`** property of the HTMLInputElement interface is a number that represents the end index of the selected text. That is, it represents the index of the character immediately following the selection. Likewise, when there is no selection, this returns the offset of the character immediately following the current text input cursor position. * @@ -17467,7 +17468,7 @@ interface HTMLInputElement extends HTMLElement, PopoverTargetAttributes { * * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLInputElement/setSelectionRange) */ - setSelectionRange(start: number | null, end: number | null, direction?: Directions): void; + setSelectionRange(start: number | null, end: number | null, direction?: SelectionDirection): void; /** * The **`HTMLInputElement.showPicker()`** method displays the browser picker for an input element. * @@ -42430,7 +42431,6 @@ type ConstrainDouble = number | ConstrainDoubleRange; type ConstrainULong = number | ConstrainULongRange; type CookieList = CookieListItem[]; type DOMHighResTimeStamp = number; -type Directions = "forward" | "backward" | "none"; type EpochTimeStamp = number; type EventListenerOrEventListenerObject = EventListener | EventListenerObject; type FileSystemWriteChunkType = BufferSource | Blob | string | WriteParams; @@ -42476,6 +42476,7 @@ type ReadableStreamReader = ReadableStreamDefaultReader | ReadableStreamBY type RenderingContext = CanvasRenderingContext2D | ImageBitmapRenderingContext | WebGLRenderingContext | WebGL2RenderingContext; type ReportList = Report[]; type RequestInfo = Request | string; +type SelectionDirection = "forward" | "backward" | "none"; type TexImageSource = ImageBitmap | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | OffscreenCanvas | VideoFrame; type TimerHandler = string | Function; type Transferable = OffscreenCanvas | ImageBitmap | MessagePort | MediaSourceHandle | ReadableStream | WritableStream | TransformStream | AudioData | VideoFrame | RTCDataChannel | ArrayBuffer; diff --git a/baselines/ts5.9/dom.generated.d.ts b/baselines/ts5.9/dom.generated.d.ts index d70b33628..cc81eb621 100644 --- a/baselines/ts5.9/dom.generated.d.ts +++ b/baselines/ts5.9/dom.generated.d.ts @@ -17151,6 +17151,7 @@ declare var HTMLImageElement: { * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLInputElement) */ interface HTMLInputElement extends HTMLElement, PopoverTargetAttributes { + SelectionDirection: SelectionDirection; /** * The **`accept`** property of the HTMLInputElement interface reflects the element's accept attribute, generally a comma-separated list of unique file type specifiers providing a hint for the expected file type for an of type file. If the attribute is not explicitly set, the accept property is an empty string. * @@ -17338,7 +17339,7 @@ interface HTMLInputElement extends HTMLElement, PopoverTargetAttributes { * * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLInputElement/selectionDirection) */ - selectionDirection: Directions | null; + selectionDirection: string | null; /** * The **`selectionEnd`** property of the HTMLInputElement interface is a number that represents the end index of the selected text. That is, it represents the index of the character immediately following the selection. Likewise, when there is no selection, this returns the offset of the character immediately following the current text input cursor position. * @@ -17467,7 +17468,7 @@ interface HTMLInputElement extends HTMLElement, PopoverTargetAttributes { * * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLInputElement/setSelectionRange) */ - setSelectionRange(start: number | null, end: number | null, direction?: Directions): void; + setSelectionRange(start: number | null, end: number | null, direction?: SelectionDirection): void; /** * The **`HTMLInputElement.showPicker()`** method displays the browser picker for an input element. * @@ -42430,7 +42431,6 @@ type ConstrainDouble = number | ConstrainDoubleRange; type ConstrainULong = number | ConstrainULongRange; type CookieList = CookieListItem[]; type DOMHighResTimeStamp = number; -type Directions = "forward" | "backward" | "none"; type EpochTimeStamp = number; type EventListenerOrEventListenerObject = EventListener | EventListenerObject; type FileSystemWriteChunkType = BufferSource | Blob | string | WriteParams; @@ -42476,6 +42476,7 @@ type ReadableStreamReader = ReadableStreamDefaultReader | ReadableStreamBY type RenderingContext = CanvasRenderingContext2D | ImageBitmapRenderingContext | WebGLRenderingContext | WebGL2RenderingContext; type ReportList = Report[]; type RequestInfo = Request | string; +type SelectionDirection = "forward" | "backward" | "none"; type TexImageSource = ImageBitmap | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | OffscreenCanvas | VideoFrame; type TimerHandler = string | Function; type Transferable = OffscreenCanvas | ImageBitmap | MessagePort | MediaSourceHandle | ReadableStream | WritableStream | TransformStream | AudioData | VideoFrame | RTCDataChannel | ArrayBuffer; diff --git a/inputfiles/patches/html.kdl b/inputfiles/patches/html.kdl index 9d0c08148..ef18d89af 100644 --- a/inputfiles/patches/html.kdl +++ b/inputfiles/patches/html.kdl @@ -55,15 +55,15 @@ interface HTMLInputElement { } property autocomplete type=AutoFill property valueAsDate type=Date - property selectionDirection type=Directions + property SelectionDirection type=SelectionDirection method setSelectionRange signatureIndex=0 { param start nullable=#true param end nullable=#true - param direction type=Directions + param direction type=SelectionDirection } } -typedef Directions overrideType=#""forward" | "backward" | "none""# +typedef SelectionDirection overrideType=#""forward" | "backward" | "none""# dictionary StructuredSerializeOptions { member transfer { From cad1aa81d32978101e00f52a1a6dcfa33f41cced Mon Sep 17 00:00:00 2001 From: Bashamega Date: Tue, 30 Dec 2025 14:11:08 +0200 Subject: [PATCH 4/6] - --- baselines/dom.generated.d.ts | 3 +-- baselines/ts5.5/dom.generated.d.ts | 3 +-- baselines/ts5.6/dom.generated.d.ts | 3 +-- baselines/ts5.9/dom.generated.d.ts | 3 +-- inputfiles/patches/html.kdl | 2 +- 5 files changed, 5 insertions(+), 9 deletions(-) diff --git a/baselines/dom.generated.d.ts b/baselines/dom.generated.d.ts index b3b17abc5..0df481561 100644 --- a/baselines/dom.generated.d.ts +++ b/baselines/dom.generated.d.ts @@ -17154,7 +17154,6 @@ declare var HTMLImageElement: { * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLInputElement) */ interface HTMLInputElement extends HTMLElement, PopoverTargetAttributes { - SelectionDirection: SelectionDirection; /** * The **`accept`** property of the HTMLInputElement interface reflects the element's accept attribute, generally a comma-separated list of unique file type specifiers providing a hint for the expected file type for an of type file. If the attribute is not explicitly set, the accept property is an empty string. * @@ -17342,7 +17341,7 @@ interface HTMLInputElement extends HTMLElement, PopoverTargetAttributes { * * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLInputElement/selectionDirection) */ - selectionDirection: string | null; + selectionDirection: SelectionDirection | null; /** * The **`selectionEnd`** property of the HTMLInputElement interface is a number that represents the end index of the selected text. That is, it represents the index of the character immediately following the selection. Likewise, when there is no selection, this returns the offset of the character immediately following the current text input cursor position. * diff --git a/baselines/ts5.5/dom.generated.d.ts b/baselines/ts5.5/dom.generated.d.ts index 01a384d94..d10659836 100644 --- a/baselines/ts5.5/dom.generated.d.ts +++ b/baselines/ts5.5/dom.generated.d.ts @@ -17136,7 +17136,6 @@ declare var HTMLImageElement: { * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLInputElement) */ interface HTMLInputElement extends HTMLElement, PopoverTargetAttributes { - SelectionDirection: SelectionDirection; /** * The **`accept`** property of the HTMLInputElement interface reflects the element's accept attribute, generally a comma-separated list of unique file type specifiers providing a hint for the expected file type for an of type file. If the attribute is not explicitly set, the accept property is an empty string. * @@ -17324,7 +17323,7 @@ interface HTMLInputElement extends HTMLElement, PopoverTargetAttributes { * * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLInputElement/selectionDirection) */ - selectionDirection: string | null; + selectionDirection: SelectionDirection | null; /** * The **`selectionEnd`** property of the HTMLInputElement interface is a number that represents the end index of the selected text. That is, it represents the index of the character immediately following the selection. Likewise, when there is no selection, this returns the offset of the character immediately following the current text input cursor position. * diff --git a/baselines/ts5.6/dom.generated.d.ts b/baselines/ts5.6/dom.generated.d.ts index bd9a9bca8..2e5b922e6 100644 --- a/baselines/ts5.6/dom.generated.d.ts +++ b/baselines/ts5.6/dom.generated.d.ts @@ -17151,7 +17151,6 @@ declare var HTMLImageElement: { * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLInputElement) */ interface HTMLInputElement extends HTMLElement, PopoverTargetAttributes { - SelectionDirection: SelectionDirection; /** * The **`accept`** property of the HTMLInputElement interface reflects the element's accept attribute, generally a comma-separated list of unique file type specifiers providing a hint for the expected file type for an of type file. If the attribute is not explicitly set, the accept property is an empty string. * @@ -17339,7 +17338,7 @@ interface HTMLInputElement extends HTMLElement, PopoverTargetAttributes { * * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLInputElement/selectionDirection) */ - selectionDirection: string | null; + selectionDirection: SelectionDirection | null; /** * The **`selectionEnd`** property of the HTMLInputElement interface is a number that represents the end index of the selected text. That is, it represents the index of the character immediately following the selection. Likewise, when there is no selection, this returns the offset of the character immediately following the current text input cursor position. * diff --git a/baselines/ts5.9/dom.generated.d.ts b/baselines/ts5.9/dom.generated.d.ts index cc81eb621..3773a12d8 100644 --- a/baselines/ts5.9/dom.generated.d.ts +++ b/baselines/ts5.9/dom.generated.d.ts @@ -17151,7 +17151,6 @@ declare var HTMLImageElement: { * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLInputElement) */ interface HTMLInputElement extends HTMLElement, PopoverTargetAttributes { - SelectionDirection: SelectionDirection; /** * The **`accept`** property of the HTMLInputElement interface reflects the element's accept attribute, generally a comma-separated list of unique file type specifiers providing a hint for the expected file type for an of type file. If the attribute is not explicitly set, the accept property is an empty string. * @@ -17339,7 +17338,7 @@ interface HTMLInputElement extends HTMLElement, PopoverTargetAttributes { * * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLInputElement/selectionDirection) */ - selectionDirection: string | null; + selectionDirection: SelectionDirection | null; /** * The **`selectionEnd`** property of the HTMLInputElement interface is a number that represents the end index of the selected text. That is, it represents the index of the character immediately following the selection. Likewise, when there is no selection, this returns the offset of the character immediately following the current text input cursor position. * diff --git a/inputfiles/patches/html.kdl b/inputfiles/patches/html.kdl index ef18d89af..259dec2d5 100644 --- a/inputfiles/patches/html.kdl +++ b/inputfiles/patches/html.kdl @@ -55,7 +55,7 @@ interface HTMLInputElement { } property autocomplete type=AutoFill property valueAsDate type=Date - property SelectionDirection type=SelectionDirection + property selectionDirection type=SelectionDirection method setSelectionRange signatureIndex=0 { param start nullable=#true param end nullable=#true From 841cd8274039fc960c6de5df23637838fa85e095 Mon Sep 17 00:00:00 2001 From: Bashamega Date: Tue, 30 Dec 2025 18:05:12 +0200 Subject: [PATCH 5/6] Update --- inputfiles/patches/html.kdl | 8 ++++++-- src/build/patches.ts | 10 +++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/inputfiles/patches/html.kdl b/inputfiles/patches/html.kdl index 259dec2d5..34d6dd94b 100644 --- a/inputfiles/patches/html.kdl +++ b/inputfiles/patches/html.kdl @@ -57,8 +57,12 @@ interface HTMLInputElement { property valueAsDate type=Date property selectionDirection type=SelectionDirection method setSelectionRange signatureIndex=0 { - param start nullable=#true - param end nullable=#true + param start { + type nullable=#true + } + param end { + type nullable=#true + } param direction type=SelectionDirection } } diff --git a/src/build/patches.ts b/src/build/patches.ts index c5b25524a..f2484e436 100644 --- a/src/build/patches.ts +++ b/src/build/patches.ts @@ -307,6 +307,7 @@ function handleProperty(child: Node): DeepPartial { function handleParam(node: Node) { const name = string(node.values[0]); let additionalTypes: string[] | undefined; + const typeNodes: Node[] = []; for (const child of node.children) { switch (child.name) { @@ -317,6 +318,10 @@ function handleParam(node: Node) { additionalTypes = child.values.map(string); break; } + case "type": { + typeNodes.push(child); + break; + } default: throw new Error(`Unexpected child "${child.name}" in param "${name}"`); } @@ -324,9 +329,8 @@ function handleParam(node: Node) { return { name, - ...optionalMember("type", "string", node.properties?.type), + ...handleTyped(typeNodes, node.properties?.type), ...optionalMember("overrideType", "string", node.properties?.overrideType), - ...optionalMember("nullable", "boolean", node.properties?.nullable), additionalTypes, }; } @@ -344,7 +348,7 @@ function handleMethodAndConstructor( // Collect all type nodes into an array const typeNodes: Node[] = []; - const params: Partial[] = []; + const params: DeepPartial[] = []; for (const c of child.children) { switch (c.name) { From 8b49df9c568c7a780fabf18ad55744700000ae62 Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Tue, 30 Dec 2025 18:13:00 +0100 Subject: [PATCH 6/6] Clarify nullable types in setSelectionRange method Added comments to clarify nullable types in setSelectionRange method. --- inputfiles/patches/html.kdl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/inputfiles/patches/html.kdl b/inputfiles/patches/html.kdl index 34d6dd94b..00b0380a4 100644 --- a/inputfiles/patches/html.kdl +++ b/inputfiles/patches/html.kdl @@ -57,6 +57,8 @@ interface HTMLInputElement { property valueAsDate type=Date property selectionDirection type=SelectionDirection method setSelectionRange signatureIndex=0 { + // nullable types because we want to allow passing selectionStart/End properties, which are nullable. + // See also https://github.com/microsoft/TypeScript-DOM-lib-generator/pull/878. param start { type nullable=#true }