From ef9854e8bc9998966fbdb59b9f43048b7448cc1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yann=20Breli=C3=A8re?= Date: Mon, 9 Jan 2023 20:03:08 +0100 Subject: [PATCH 1/8] Add more precise typing for autoComplete HTML attribute MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replaces: microsoft/TypeScript#52169 This will allow to autocomplete… the `autoComplete` attribute in vscode for example. ![autoComplete autocomplete in vscode](https://user-images.githubusercontent.com/58247/211378145-c01c665b-9f4b-4918-83cc-16532f555935.png) The list is quite long and it's not easy remembering the spelling of each one of them (first_name or given-name? password or current-password?), and it would improve the UX of sites if they were more appropriately used (for example, some people may think that the input's `type` and/or `name` attributes may be enough for fields like email or password, but knowing to use `autoComplete="new-password"` or `one-time-code` can be really useful). --- baselines/dom.generated.d.ts | 2 +- inputfiles/overridingTypes.jsonc | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/baselines/dom.generated.d.ts b/baselines/dom.generated.d.ts index 95307ebba..9752ea27a 100644 --- a/baselines/dom.generated.d.ts +++ b/baselines/dom.generated.d.ts @@ -10260,7 +10260,7 @@ interface HTMLFormElement extends HTMLElement { * * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLFormElement/autocomplete) */ - autocomplete: string; + autocomplete: "off" | "on" | "name" | "honorific-prefix" | "given-name" | "family-name" | "honorific-suffix" | "nickname" | "email" | "username" | "new-password" | "current-password" | "one-time-code" | "organization-title" | "organization" | "street-address" | "address-line1" | "address-line2" | "address-line3" | "address-level4" | "address-level3" | "address-level2" | "address-level1" | "country" | "country-name" | "postal-code" | "cc-name" | "cc-given-name" | "cc-additional-name" | "cc-family-name" | "cc-number" | "cc-exp" | "cc-exp-month" | "cc-exp-year" | "cc-csc" | "cc-type" | "transaction-currency" | "transaction-amount" | "language" | "bday" | "bday-day" | "bday-month" | "bday-year" | "sex" | "tel" | "tel-country-code" | "tel-national" | "tel-area-code" | "tel-local" | "tel-extension" | "impp" | "url" | "photo" | (string & {}); /** * Retrieves a collection, in source order, of all controls in a given form. * diff --git a/inputfiles/overridingTypes.jsonc b/inputfiles/overridingTypes.jsonc index 640982f05..176557152 100644 --- a/inputfiles/overridingTypes.jsonc +++ b/inputfiles/overridingTypes.jsonc @@ -1281,6 +1281,10 @@ "HTMLSelectElement": { "properties": { "property": { + "autocomplete": { + "name": "autocomplete", + "overrideType": "\"off\" | \"on\" | \"name\" | \"honorific-prefix\" | \"given-name\" | \"family-name\" | \"honorific-suffix\" | \"nickname\" | \"email\" | \"username\" | \"new-password\" | \"current-password\" | \"one-time-code\" | \"organization-title\" | \"organization\" | \"street-address\" | \"address-line1\" | \"address-line2\" | \"address-line3\" | \"address-level4\" | \"address-level3\" | \"address-level2\" | \"address-level1\" | \"country\" | \"country-name\" | \"postal-code\" | \"cc-name\" | \"cc-given-name\" | \"cc-additional-name\" | \"cc-family-name\" | \"cc-number\" | \"cc-exp\" | \"cc-exp-month\" | \"cc-exp-year\" | \"cc-csc\" | \"cc-type\" | \"transaction-currency\" | \"transaction-amount\" | \"language\" | \"bday\" | \"bday-day\" | \"bday-month\" | \"bday-year\" | \"sex\" | \"tel\" | \"tel-country-code\" | \"tel-national\" | \"tel-area-code\" | \"tel-local\" | \"tel-extension\" | \"impp\" | \"url\" | \"photo\" | (string & {})" + }, "selectedOptions": { "name": "selectedOptions", "overrideType": "HTMLCollectionOf" @@ -1684,6 +1688,10 @@ "HTMLInputElement": { "properties": { "property": { + "autocomplete": { + "name": "autocomplete", + "overrideType": "\"off\" | \"on\" | \"name\" | \"honorific-prefix\" | \"given-name\" | \"family-name\" | \"honorific-suffix\" | \"nickname\" | \"email\" | \"username\" | \"new-password\" | \"current-password\" | \"one-time-code\" | \"organization-title\" | \"organization\" | \"street-address\" | \"address-line1\" | \"address-line2\" | \"address-line3\" | \"address-level4\" | \"address-level3\" | \"address-level2\" | \"address-level1\" | \"country\" | \"country-name\" | \"postal-code\" | \"cc-name\" | \"cc-given-name\" | \"cc-additional-name\" | \"cc-family-name\" | \"cc-number\" | \"cc-exp\" | \"cc-exp-month\" | \"cc-exp-year\" | \"cc-csc\" | \"cc-type\" | \"transaction-currency\" | \"transaction-amount\" | \"language\" | \"bday\" | \"bday-day\" | \"bday-month\" | \"bday-year\" | \"sex\" | \"tel\" | \"tel-country-code\" | \"tel-national\" | \"tel-area-code\" | \"tel-local\" | \"tel-extension\" | \"impp\" | \"url\" | \"photo\" | (string & {})" + }, "selectionDirection": { "name": "selectionDirection", "overrideType": "\"forward\" | \"backward\" | \"none\"" @@ -1806,6 +1814,10 @@ "HTMLTextAreaElement": { "properties": { "property": { + "autocomplete": { + "name": "autocomplete", + "overrideType": "\"off\" | \"on\" | \"name\" | \"honorific-prefix\" | \"given-name\" | \"family-name\" | \"honorific-suffix\" | \"nickname\" | \"email\" | \"username\" | \"new-password\" | \"current-password\" | \"one-time-code\" | \"organization-title\" | \"organization\" | \"street-address\" | \"address-line1\" | \"address-line2\" | \"address-line3\" | \"address-level4\" | \"address-level3\" | \"address-level2\" | \"address-level1\" | \"country\" | \"country-name\" | \"postal-code\" | \"cc-name\" | \"cc-given-name\" | \"cc-additional-name\" | \"cc-family-name\" | \"cc-number\" | \"cc-exp\" | \"cc-exp-month\" | \"cc-exp-year\" | \"cc-csc\" | \"cc-type\" | \"transaction-currency\" | \"transaction-amount\" | \"language\" | \"bday\" | \"bday-day\" | \"bday-month\" | \"bday-year\" | \"sex\" | \"tel\" | \"tel-country-code\" | \"tel-national\" | \"tel-area-code\" | \"tel-local\" | \"tel-extension\" | \"impp\" | \"url\" | \"photo\" | (string & {})" + }, "labels": { "name": "labels", "overrideType": "NodeListOf" @@ -2443,7 +2455,15 @@ "overrideIndexSignatures": [ "[index: number]: Element", "[name: string]: any" - ] + ], + "properties": { + "property": { + "autocomplete": { + "name": "autocomplete", + "overrideType": "\"off\" | \"on\" | \"name\" | \"honorific-prefix\" | \"given-name\" | \"family-name\" | \"honorific-suffix\" | \"nickname\" | \"email\" | \"username\" | \"new-password\" | \"current-password\" | \"one-time-code\" | \"organization-title\" | \"organization\" | \"street-address\" | \"address-line1\" | \"address-line2\" | \"address-line3\" | \"address-level4\" | \"address-level3\" | \"address-level2\" | \"address-level1\" | \"country\" | \"country-name\" | \"postal-code\" | \"cc-name\" | \"cc-given-name\" | \"cc-additional-name\" | \"cc-family-name\" | \"cc-number\" | \"cc-exp\" | \"cc-exp-month\" | \"cc-exp-year\" | \"cc-csc\" | \"cc-type\" | \"transaction-currency\" | \"transaction-amount\" | \"language\" | \"bday\" | \"bday-day\" | \"bday-month\" | \"bday-year\" | \"sex\" | \"tel\" | \"tel-country-code\" | \"tel-national\" | \"tel-area-code\" | \"tel-local\" | \"tel-extension\" | \"impp\" | \"url\" | \"photo\" | (string & {})" + } + } + } }, "Blob": { "methods": { From b62fee275346500206c13a988c616467fbab81f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yann=20Breli=C3=A8re?= Date: Tue, 10 Jan 2023 13:34:51 +0100 Subject: [PATCH 2/8] Declare AutoFill enum for autocomplete values Add missing value according to spec (`webauthn`). --- baselines/dom.generated.d.ts | 9 ++-- inputfiles/addedTypes.jsonc | 77 ++++++++++++++++++++++++++++++++ inputfiles/knownTypes.json | 1 + inputfiles/overridingTypes.jsonc | 11 +++-- 4 files changed, 90 insertions(+), 8 deletions(-) diff --git a/baselines/dom.generated.d.ts b/baselines/dom.generated.d.ts index 9752ea27a..be79ec44c 100644 --- a/baselines/dom.generated.d.ts +++ b/baselines/dom.generated.d.ts @@ -10260,7 +10260,7 @@ interface HTMLFormElement extends HTMLElement { * * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLFormElement/autocomplete) */ - autocomplete: "off" | "on" | "name" | "honorific-prefix" | "given-name" | "family-name" | "honorific-suffix" | "nickname" | "email" | "username" | "new-password" | "current-password" | "one-time-code" | "organization-title" | "organization" | "street-address" | "address-line1" | "address-line2" | "address-line3" | "address-level4" | "address-level3" | "address-level2" | "address-level1" | "country" | "country-name" | "postal-code" | "cc-name" | "cc-given-name" | "cc-additional-name" | "cc-family-name" | "cc-number" | "cc-exp" | "cc-exp-month" | "cc-exp-year" | "cc-csc" | "cc-type" | "transaction-currency" | "transaction-amount" | "language" | "bday" | "bday-day" | "bday-month" | "bday-year" | "sex" | "tel" | "tel-country-code" | "tel-national" | "tel-area-code" | "tel-local" | "tel-extension" | "impp" | "url" | "photo" | (string & {}); + autocomplete: "off" | "on"; /** * Retrieves a collection, in source order, of all controls in a given form. * @@ -10928,7 +10928,7 @@ interface HTMLInputElement extends HTMLElement, PopoverInvokerElement { * * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLInputElement/autocomplete) */ - autocomplete: string; + autocomplete: AutoFill | (string & {}); capture: string; /** Sets or retrieves the state of the check box or radio button. */ checked: boolean; @@ -12309,7 +12309,7 @@ declare var HTMLScriptElement: { */ interface HTMLSelectElement extends HTMLElement { /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLSelectElement/autocomplete) */ - autocomplete: string; + autocomplete: AutoFill | (string & {}); /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLSelectElement/disabled) */ disabled: boolean; /** @@ -13111,7 +13111,7 @@ declare var HTMLTemplateElement: { */ interface HTMLTextAreaElement extends HTMLElement { /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLTextAreaElement/autocomplete) */ - autocomplete: string; + autocomplete: AutoFill | (string & {}); /** Sets or retrieves the width of the object. */ cols: number; /** Sets or retrieves the initial contents of the object. */ @@ -28000,6 +28000,7 @@ type AudioContextLatencyCategory = "balanced" | "interactive" | "playback"; type AudioContextState = "closed" | "running" | "suspended"; type AuthenticatorAttachment = "cross-platform" | "platform"; type AuthenticatorTransport = "ble" | "hybrid" | "internal" | "nfc" | "usb"; +type AutoFill = "additional-name" | "address-level1" | "address-level2" | "address-level3" | "address-level4" | "address-line1" | "address-line2" | "address-line3" | "bday" | "bday-day" | "bday-month" | "bday-year" | "cc-additional-name" | "cc-csc" | "cc-exp" | "cc-exp-month" | "cc-exp-year" | "cc-family-name" | "cc-given-name" | "cc-name" | "cc-number" | "cc-type" | "country" | "country-name" | "current-password" | "email" | "family-name" | "given-name" | "honorific-prefix" | "honorific-suffix" | "impp" | "language" | "name" | "new-password" | "nickname" | "off" | "on" | "one-time-code" | "organization" | "organization-title" | "photo" | "postal-code" | "sex" | "street-address" | "tel" | "tel-area-code" | "tel-country-code" | "tel-extension" | "tel-local" | "tel-national" | "transaction-amount" | "transaction-currency" | "url" | "username" | "webauthn"; type AutoKeyword = "auto"; type AutomationRate = "a-rate" | "k-rate"; type AvcBitstreamFormat = "annexb" | "avc"; diff --git a/inputfiles/addedTypes.jsonc b/inputfiles/addedTypes.jsonc index c2d236a40..4c10a59c2 100644 --- a/inputfiles/addedTypes.jsonc +++ b/inputfiles/addedTypes.jsonc @@ -352,6 +352,83 @@ // https://developer.mozilla.org/en-US/docs/Web/API/WebXR_Device_API#browser_compatibility "xr-spatial-tracking" ] + }, + "AutoFill": { + "name": "AutoFill", + // See the full list of possible autofill values for the `autocomplete`attribut: + // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#determine-a-field's-category + // Note that other values are also possible, like section-*, so it should still allow a string. + // Full spec at https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill. + "value": [ + // Off + "off", + // Automatic + "on", + + // Normal + "name", + "honorific-prefix", + "given-name", + "additional-name", + "family-name", + "honorific-suffix", + "nickname", + "organization-title", + + "username", + "new-password", + "current-password", + "one-time-code", + + "organization", + "street-address", + "address-line1", + "address-line2", + "address-line3", + "address-level4", + "address-level3", + "address-level2", + "address-level1", + "country", + "country-name", + "postal-code", + + "cc-name", + "cc-given-name", + "cc-additional-name", + "cc-family-name", + "cc-number", + "cc-exp", + "cc-exp-month", + "cc-exp-year", + "cc-csc", + "cc-type", + "transaction-currency", + "transaction-amount", + + "language", + "bday", + "bday-day", + "bday-month", + "bday-year", + "sex", + "url", + "photo", + + // Contact + "tel", + "tel-country-code", + "tel-national", + "tel-area-code", + "tel-local", + "tel-extension", + + "email", + "impp", + + // Credential + "webauthn" + ] } } }, diff --git a/inputfiles/knownTypes.json b/inputfiles/knownTypes.json index aba727e73..e41b7090e 100644 --- a/inputfiles/knownTypes.json +++ b/inputfiles/knownTypes.json @@ -6,6 +6,7 @@ "AesGcmParams", "AesKeyAlgorithm", "AesKeyGenParams", + "AutoFill", "BigInteger", "ClientQueryOptions", "ClientTypes", diff --git a/inputfiles/overridingTypes.jsonc b/inputfiles/overridingTypes.jsonc index 176557152..aacb648fc 100644 --- a/inputfiles/overridingTypes.jsonc +++ b/inputfiles/overridingTypes.jsonc @@ -1283,7 +1283,8 @@ "property": { "autocomplete": { "name": "autocomplete", - "overrideType": "\"off\" | \"on\" | \"name\" | \"honorific-prefix\" | \"given-name\" | \"family-name\" | \"honorific-suffix\" | \"nickname\" | \"email\" | \"username\" | \"new-password\" | \"current-password\" | \"one-time-code\" | \"organization-title\" | \"organization\" | \"street-address\" | \"address-line1\" | \"address-line2\" | \"address-line3\" | \"address-level4\" | \"address-level3\" | \"address-level2\" | \"address-level1\" | \"country\" | \"country-name\" | \"postal-code\" | \"cc-name\" | \"cc-given-name\" | \"cc-additional-name\" | \"cc-family-name\" | \"cc-number\" | \"cc-exp\" | \"cc-exp-month\" | \"cc-exp-year\" | \"cc-csc\" | \"cc-type\" | \"transaction-currency\" | \"transaction-amount\" | \"language\" | \"bday\" | \"bday-day\" | \"bday-month\" | \"bday-year\" | \"sex\" | \"tel\" | \"tel-country-code\" | \"tel-national\" | \"tel-area-code\" | \"tel-local\" | \"tel-extension\" | \"impp\" | \"url\" | \"photo\" | (string & {})" + // allow custom values like section-* without losing type completion + "overrideType": "AutoFill | (string & {})" }, "selectedOptions": { "name": "selectedOptions", @@ -1690,7 +1691,8 @@ "property": { "autocomplete": { "name": "autocomplete", - "overrideType": "\"off\" | \"on\" | \"name\" | \"honorific-prefix\" | \"given-name\" | \"family-name\" | \"honorific-suffix\" | \"nickname\" | \"email\" | \"username\" | \"new-password\" | \"current-password\" | \"one-time-code\" | \"organization-title\" | \"organization\" | \"street-address\" | \"address-line1\" | \"address-line2\" | \"address-line3\" | \"address-level4\" | \"address-level3\" | \"address-level2\" | \"address-level1\" | \"country\" | \"country-name\" | \"postal-code\" | \"cc-name\" | \"cc-given-name\" | \"cc-additional-name\" | \"cc-family-name\" | \"cc-number\" | \"cc-exp\" | \"cc-exp-month\" | \"cc-exp-year\" | \"cc-csc\" | \"cc-type\" | \"transaction-currency\" | \"transaction-amount\" | \"language\" | \"bday\" | \"bday-day\" | \"bday-month\" | \"bday-year\" | \"sex\" | \"tel\" | \"tel-country-code\" | \"tel-national\" | \"tel-area-code\" | \"tel-local\" | \"tel-extension\" | \"impp\" | \"url\" | \"photo\" | (string & {})" + // allow custom values like section-* without losing type completion + "overrideType": "AutoFill | (string & {})" }, "selectionDirection": { "name": "selectionDirection", @@ -1816,7 +1818,8 @@ "property": { "autocomplete": { "name": "autocomplete", - "overrideType": "\"off\" | \"on\" | \"name\" | \"honorific-prefix\" | \"given-name\" | \"family-name\" | \"honorific-suffix\" | \"nickname\" | \"email\" | \"username\" | \"new-password\" | \"current-password\" | \"one-time-code\" | \"organization-title\" | \"organization\" | \"street-address\" | \"address-line1\" | \"address-line2\" | \"address-line3\" | \"address-level4\" | \"address-level3\" | \"address-level2\" | \"address-level1\" | \"country\" | \"country-name\" | \"postal-code\" | \"cc-name\" | \"cc-given-name\" | \"cc-additional-name\" | \"cc-family-name\" | \"cc-number\" | \"cc-exp\" | \"cc-exp-month\" | \"cc-exp-year\" | \"cc-csc\" | \"cc-type\" | \"transaction-currency\" | \"transaction-amount\" | \"language\" | \"bday\" | \"bday-day\" | \"bday-month\" | \"bday-year\" | \"sex\" | \"tel\" | \"tel-country-code\" | \"tel-national\" | \"tel-area-code\" | \"tel-local\" | \"tel-extension\" | \"impp\" | \"url\" | \"photo\" | (string & {})" + // allow custom values like section-* without losing type completion + "overrideType": "AutoFill | (string & {})" }, "labels": { "name": "labels", @@ -2460,7 +2463,7 @@ "property": { "autocomplete": { "name": "autocomplete", - "overrideType": "\"off\" | \"on\" | \"name\" | \"honorific-prefix\" | \"given-name\" | \"family-name\" | \"honorific-suffix\" | \"nickname\" | \"email\" | \"username\" | \"new-password\" | \"current-password\" | \"one-time-code\" | \"organization-title\" | \"organization\" | \"street-address\" | \"address-line1\" | \"address-line2\" | \"address-line3\" | \"address-level4\" | \"address-level3\" | \"address-level2\" | \"address-level1\" | \"country\" | \"country-name\" | \"postal-code\" | \"cc-name\" | \"cc-given-name\" | \"cc-additional-name\" | \"cc-family-name\" | \"cc-number\" | \"cc-exp\" | \"cc-exp-month\" | \"cc-exp-year\" | \"cc-csc\" | \"cc-type\" | \"transaction-currency\" | \"transaction-amount\" | \"language\" | \"bday\" | \"bday-day\" | \"bday-month\" | \"bday-year\" | \"sex\" | \"tel\" | \"tel-country-code\" | \"tel-national\" | \"tel-area-code\" | \"tel-local\" | \"tel-extension\" | \"impp\" | \"url\" | \"photo\" | (string & {})" + "overrideType": "\"off\" | \"on\"" } } } From 8179c4445cfe3fd7b33feb0287ebdc6bedcdec21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yann=20Breli=C3=A8re?= Date: Sat, 21 Jan 2023 01:35:44 +0100 Subject: [PATCH 3/8] Use precise types allowing completion of several tokens --- baselines/dom.generated.d.ts | 18 +++++--- inputfiles/addedTypes.jsonc | 72 ++++++++++++++++++++++++-------- inputfiles/knownTypes.json | 8 ++++ inputfiles/overridingTypes.jsonc | 11 ++--- 4 files changed, 80 insertions(+), 29 deletions(-) diff --git a/baselines/dom.generated.d.ts b/baselines/dom.generated.d.ts index be79ec44c..3417032b4 100644 --- a/baselines/dom.generated.d.ts +++ b/baselines/dom.generated.d.ts @@ -10260,7 +10260,7 @@ interface HTMLFormElement extends HTMLElement { * * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLFormElement/autocomplete) */ - autocomplete: "off" | "on"; + autocomplete: AutoFillBase; /** * Retrieves a collection, in source order, of all controls in a given form. * @@ -10928,7 +10928,7 @@ interface HTMLInputElement extends HTMLElement, PopoverInvokerElement { * * [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLInputElement/autocomplete) */ - autocomplete: AutoFill | (string & {}); + autocomplete: AutoFill; capture: string; /** Sets or retrieves the state of the check box or radio button. */ checked: boolean; @@ -12309,7 +12309,7 @@ declare var HTMLScriptElement: { */ interface HTMLSelectElement extends HTMLElement { /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLSelectElement/autocomplete) */ - autocomplete: AutoFill | (string & {}); + autocomplete: AutoFill; /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLSelectElement/disabled) */ disabled: boolean; /** @@ -13111,7 +13111,7 @@ declare var HTMLTemplateElement: { */ interface HTMLTextAreaElement extends HTMLElement { /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/HTMLTextAreaElement/autocomplete) */ - autocomplete: AutoFill | (string & {}); + autocomplete: AutoFill; /** Sets or retrieves the width of the object. */ cols: number; /** Sets or retrieves the initial contents of the object. */ @@ -27926,6 +27926,9 @@ declare function addEventListener(type: string, listener: EventListenerOrEventLi declare function removeEventListener(type: K, listener: (this: Window, ev: WindowEventMap[K]) => any, options?: boolean | EventListenerOptions): void; declare function removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; type AlgorithmIdentifier = Algorithm | string; +type AutoFill = AutoFillBase | AutoFillField | `${AutoFillSection} ${AutoFillField}` | `${AutoFillAddressKind} ${AutoFillField}` | `${AutoFillSection} ${AutoFillAddressKind} ${AutoFillField}` | `${AutoFillSection} ${AutoFillAddressKind} ${AutoFillField} ${AutoFillCredentialField}` | `${AutoFillAddressKind} ${AutoFillField} ${AutoFillCredentialField}` | `${AutoFillSection} ${AutoFillField} ${AutoFillCredentialField}` | `${AutoFillField} ${AutoFillCredentialField}`; +type AutoFillField = AutoFillNormalField | AutoFillContactField | `${AutoFillContactKind} ${AutoFillContactField}`; +type AutoFillSection = `section-${string}`; type BigInteger = Uint8Array; type BinaryData = ArrayBuffer | ArrayBufferView; type BlobPart = BufferSource | Blob | string; @@ -28000,7 +28003,12 @@ type AudioContextLatencyCategory = "balanced" | "interactive" | "playback"; type AudioContextState = "closed" | "running" | "suspended"; type AuthenticatorAttachment = "cross-platform" | "platform"; type AuthenticatorTransport = "ble" | "hybrid" | "internal" | "nfc" | "usb"; -type AutoFill = "additional-name" | "address-level1" | "address-level2" | "address-level3" | "address-level4" | "address-line1" | "address-line2" | "address-line3" | "bday" | "bday-day" | "bday-month" | "bday-year" | "cc-additional-name" | "cc-csc" | "cc-exp" | "cc-exp-month" | "cc-exp-year" | "cc-family-name" | "cc-given-name" | "cc-name" | "cc-number" | "cc-type" | "country" | "country-name" | "current-password" | "email" | "family-name" | "given-name" | "honorific-prefix" | "honorific-suffix" | "impp" | "language" | "name" | "new-password" | "nickname" | "off" | "on" | "one-time-code" | "organization" | "organization-title" | "photo" | "postal-code" | "sex" | "street-address" | "tel" | "tel-area-code" | "tel-country-code" | "tel-extension" | "tel-local" | "tel-national" | "transaction-amount" | "transaction-currency" | "url" | "username" | "webauthn"; +type AutoFillAddressKind = "billing" | "shipping"; +type AutoFillBase = "off" | "on"; +type AutoFillContactField = "email" | "impp" | "tel" | "tel-area-code" | "tel-country-code" | "tel-extension" | "tel-local" | "tel-local-prefix" | "tel-local-suffix" | "tel-national"; +type AutoFillContactKind = "fax" | "home" | "mobile" | "pager" | "work"; +type AutoFillCredentialField = "webauthn"; +type AutoFillNormalField = "additional-name" | "address-level1" | "address-level2" | "address-level3" | "address-level4" | "address-line1" | "address-line2" | "address-line3" | "bday" | "bday-day" | "bday-month" | "bday-year" | "cc-additional-name" | "cc-csc" | "cc-exp" | "cc-exp-month" | "cc-exp-year" | "cc-family-name" | "cc-given-name" | "cc-name" | "cc-number" | "cc-type" | "country" | "country-name" | "current-password" | "family-name" | "given-name" | "honorific-prefix" | "honorific-suffix" | "language" | "name" | "new-password" | "nickname" | "one-time-code" | "organization" | "organization-title" | "photo" | "postal-code" | "sex" | "street-address" | "transaction-amount" | "transaction-currency" | "url" | "username"; type AutoKeyword = "auto"; type AutomationRate = "a-rate" | "k-rate"; type AvcBitstreamFormat = "annexb" | "avc"; diff --git a/inputfiles/addedTypes.jsonc b/inputfiles/addedTypes.jsonc index 4c10a59c2..59dd28136 100644 --- a/inputfiles/addedTypes.jsonc +++ b/inputfiles/addedTypes.jsonc @@ -353,19 +353,25 @@ "xr-spatial-tracking" ] }, - "AutoFill": { - "name": "AutoFill", - // See the full list of possible autofill values for the `autocomplete`attribut: - // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#determine-a-field's-category - // Note that other values are also possible, like section-*, so it should still allow a string. - // Full spec at https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill. + "AutoFillBase": { + "name": "AutoFillBase", "value": [ // Off "off", // Automatic - "on", - - // Normal + "on" + ] + }, + "AutoFillAddressKind": { + "name": "AutoFillAddressKind", + "value": [ + "shipping", + "billing" + ] + }, + "AutoFillNormalField": { + "name": "AutoFillNormalField", + "value": [ "name", "honorific-prefix", "given-name", @@ -373,13 +379,13 @@ "family-name", "honorific-suffix", "nickname", - "organization-title", "username", "new-password", "current-password", "one-time-code", + "organization-title", "organization", "street-address", "address-line1", @@ -413,20 +419,37 @@ "bday-year", "sex", "url", - "photo", - - // Contact + "photo" + ] + }, + "AutoFillContactKind": { + "name": "AutoFillContactKind", + "value": [ + "home", + "work", + "mobile", + "fax", + "pager" + ] + }, + "AutoFillContactField": { + "name": "AutoFillContactField", + "value": [ "tel", "tel-country-code", "tel-national", "tel-area-code", "tel-local", + "tel-local-prefix", + "tel-local-suffix", "tel-extension", - "email", - "impp", - - // Credential + "impp" + ] + }, + "AutoFillCredentialField": { + "name": "AutoFillCredentialField", + "value": [ "webauthn" ] } @@ -1499,6 +1522,21 @@ { "name": "EventListenerOrEventListenerObject", "overrideType": "EventListener | EventListenerObject" + }, + { + "name": "AutoFillSection", + "overrideType": "`section-${string}`" + }, + { + "name": "AutoFillField", + "overrideType": "AutoFillNormalField | AutoFillContactField | `${AutoFillContactKind} ${AutoFillContactField}`" + }, + { + // See the full list of possible autofill values for the `autocomplete` attribute: + // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#determine-a-field's-category + // Full spec at https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill. + "name": "AutoFill", + "overrideType": "AutoFillBase | AutoFillField | `${AutoFillSection} ${AutoFillField}` | `${AutoFillAddressKind} ${AutoFillField}` | `${AutoFillSection} ${AutoFillAddressKind} ${AutoFillField}` | `${AutoFillSection} ${AutoFillAddressKind} ${AutoFillField} ${AutoFillCredentialField}` | `${AutoFillAddressKind} ${AutoFillField} ${AutoFillCredentialField}` | `${AutoFillSection} ${AutoFillField} ${AutoFillCredentialField}` | `${AutoFillField} ${AutoFillCredentialField}`" } ] } diff --git a/inputfiles/knownTypes.json b/inputfiles/knownTypes.json index e41b7090e..be0c8324f 100644 --- a/inputfiles/knownTypes.json +++ b/inputfiles/knownTypes.json @@ -6,6 +6,14 @@ "AesGcmParams", "AesKeyAlgorithm", "AesKeyGenParams", + "AutoFillBase", + "AutoFillSection", + "AutoFillAddressKind", + "AutoFillNormalField", + "AutoFillContactKind", + "AutoFillContactField", + "AutoFillField", + "AutoFillCredentialField", "AutoFill", "BigInteger", "ClientQueryOptions", diff --git a/inputfiles/overridingTypes.jsonc b/inputfiles/overridingTypes.jsonc index aacb648fc..7e072c3a7 100644 --- a/inputfiles/overridingTypes.jsonc +++ b/inputfiles/overridingTypes.jsonc @@ -1283,8 +1283,7 @@ "property": { "autocomplete": { "name": "autocomplete", - // allow custom values like section-* without losing type completion - "overrideType": "AutoFill | (string & {})" + "overrideType": "AutoFill" }, "selectedOptions": { "name": "selectedOptions", @@ -1691,8 +1690,7 @@ "property": { "autocomplete": { "name": "autocomplete", - // allow custom values like section-* without losing type completion - "overrideType": "AutoFill | (string & {})" + "overrideType": "AutoFill" }, "selectionDirection": { "name": "selectionDirection", @@ -1818,8 +1816,7 @@ "property": { "autocomplete": { "name": "autocomplete", - // allow custom values like section-* without losing type completion - "overrideType": "AutoFill | (string & {})" + "overrideType": "AutoFill" }, "labels": { "name": "labels", @@ -2463,7 +2460,7 @@ "property": { "autocomplete": { "name": "autocomplete", - "overrideType": "\"off\" | \"on\"" + "overrideType": "AutoFillBase" } } } From 88318d6ab5c4ec6bc61bc948404f3c22ae45a2ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yann=20Breli=C3=A8re?= Date: Wed, 1 Feb 2023 16:53:49 +0100 Subject: [PATCH 4/8] Remove unsupported impp autofill contact token --- baselines/dom.generated.d.ts | 2 +- inputfiles/addedTypes.jsonc | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/baselines/dom.generated.d.ts b/baselines/dom.generated.d.ts index 3417032b4..34c26d112 100644 --- a/baselines/dom.generated.d.ts +++ b/baselines/dom.generated.d.ts @@ -28005,7 +28005,7 @@ type AuthenticatorAttachment = "cross-platform" | "platform"; type AuthenticatorTransport = "ble" | "hybrid" | "internal" | "nfc" | "usb"; type AutoFillAddressKind = "billing" | "shipping"; type AutoFillBase = "off" | "on"; -type AutoFillContactField = "email" | "impp" | "tel" | "tel-area-code" | "tel-country-code" | "tel-extension" | "tel-local" | "tel-local-prefix" | "tel-local-suffix" | "tel-national"; +type AutoFillContactField = "email" | "tel" | "tel-area-code" | "tel-country-code" | "tel-extension" | "tel-local" | "tel-local-prefix" | "tel-local-suffix" | "tel-national"; type AutoFillContactKind = "fax" | "home" | "mobile" | "pager" | "work"; type AutoFillCredentialField = "webauthn"; type AutoFillNormalField = "additional-name" | "address-level1" | "address-level2" | "address-level3" | "address-level4" | "address-line1" | "address-line2" | "address-line3" | "bday" | "bday-day" | "bday-month" | "bday-year" | "cc-additional-name" | "cc-csc" | "cc-exp" | "cc-exp-month" | "cc-exp-year" | "cc-family-name" | "cc-given-name" | "cc-name" | "cc-number" | "cc-type" | "country" | "country-name" | "current-password" | "family-name" | "given-name" | "honorific-prefix" | "honorific-suffix" | "language" | "name" | "new-password" | "nickname" | "one-time-code" | "organization" | "organization-title" | "photo" | "postal-code" | "sex" | "street-address" | "transaction-amount" | "transaction-currency" | "url" | "username"; diff --git a/inputfiles/addedTypes.jsonc b/inputfiles/addedTypes.jsonc index 59dd28136..201323810 100644 --- a/inputfiles/addedTypes.jsonc +++ b/inputfiles/addedTypes.jsonc @@ -443,8 +443,7 @@ "tel-local-prefix", "tel-local-suffix", "tel-extension", - "email", - "impp" + "email" ] }, "AutoFillCredentialField": { From 6d6f63ed60776e0362134d7cd48a30c8dbcd2f6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yann=20Breli=C3=A8re?= Date: Thu, 2 Feb 2023 22:24:02 +0100 Subject: [PATCH 5/8] Remove poorly supported attributes Per https://github.com/microsoft/TypeScript-DOM-lib-generator/pull/1467#issuecomment-1412324759 --- baselines/dom.generated.d.ts | 4 ++-- inputfiles/addedTypes.jsonc | 14 ++------------ 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/baselines/dom.generated.d.ts b/baselines/dom.generated.d.ts index 34c26d112..df724aaea 100644 --- a/baselines/dom.generated.d.ts +++ b/baselines/dom.generated.d.ts @@ -28006,9 +28006,9 @@ type AuthenticatorTransport = "ble" | "hybrid" | "internal" | "nfc" | "usb"; type AutoFillAddressKind = "billing" | "shipping"; type AutoFillBase = "off" | "on"; type AutoFillContactField = "email" | "tel" | "tel-area-code" | "tel-country-code" | "tel-extension" | "tel-local" | "tel-local-prefix" | "tel-local-suffix" | "tel-national"; -type AutoFillContactKind = "fax" | "home" | "mobile" | "pager" | "work"; +type AutoFillContactKind = "home" | "mobile" | "work"; type AutoFillCredentialField = "webauthn"; -type AutoFillNormalField = "additional-name" | "address-level1" | "address-level2" | "address-level3" | "address-level4" | "address-line1" | "address-line2" | "address-line3" | "bday" | "bday-day" | "bday-month" | "bday-year" | "cc-additional-name" | "cc-csc" | "cc-exp" | "cc-exp-month" | "cc-exp-year" | "cc-family-name" | "cc-given-name" | "cc-name" | "cc-number" | "cc-type" | "country" | "country-name" | "current-password" | "family-name" | "given-name" | "honorific-prefix" | "honorific-suffix" | "language" | "name" | "new-password" | "nickname" | "one-time-code" | "organization" | "organization-title" | "photo" | "postal-code" | "sex" | "street-address" | "transaction-amount" | "transaction-currency" | "url" | "username"; +type AutoFillNormalField = "additional-name" | "address-level1" | "address-level2" | "address-level3" | "address-level4" | "address-line1" | "address-line2" | "address-line3" | "bday-day" | "bday-month" | "bday-year" | "cc-csc" | "cc-exp" | "cc-exp-month" | "cc-exp-year" | "cc-family-name" | "cc-given-name" | "cc-name" | "cc-number" | "cc-type" | "country" | "country-name" | "current-password" | "family-name" | "given-name" | "honorific-prefix" | "honorific-suffix" | "name" | "new-password" | "one-time-code" | "organization" | "postal-code" | "street-address" | "transaction-amount" | "transaction-currency" | "username"; type AutoKeyword = "auto"; type AutomationRate = "a-rate" | "k-rate"; type AvcBitstreamFormat = "annexb" | "avc"; diff --git a/inputfiles/addedTypes.jsonc b/inputfiles/addedTypes.jsonc index 201323810..2b175860c 100644 --- a/inputfiles/addedTypes.jsonc +++ b/inputfiles/addedTypes.jsonc @@ -378,14 +378,12 @@ "additional-name", "family-name", "honorific-suffix", - "nickname", "username", "new-password", "current-password", "one-time-code", - "organization-title", "organization", "street-address", "address-line1", @@ -401,7 +399,6 @@ "cc-name", "cc-given-name", - "cc-additional-name", "cc-family-name", "cc-number", "cc-exp", @@ -412,14 +409,9 @@ "transaction-currency", "transaction-amount", - "language", - "bday", "bday-day", "bday-month", - "bday-year", - "sex", - "url", - "photo" + "bday-year" ] }, "AutoFillContactKind": { @@ -427,9 +419,7 @@ "value": [ "home", "work", - "mobile", - "fax", - "pager" + "mobile" ] }, "AutoFillContactField": { From 5bc8f656494e91f5d43744c61bc6f3720466858b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yann=20Breli=C3=A8re?= Date: Thu, 2 Feb 2023 22:26:37 +0100 Subject: [PATCH 6/8] Add tests for autofill values --- unittests/files/autocomplete.ts | 59 +++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 unittests/files/autocomplete.ts diff --git a/unittests/files/autocomplete.ts b/unittests/files/autocomplete.ts new file mode 100644 index 000000000..3d0b6c023 --- /dev/null +++ b/unittests/files/autocomplete.ts @@ -0,0 +1,59 @@ +// @ts-expect-error should be a string +document.body.getElementsByTagName("input")[0].autocomplete = false; +// @ts-expect-error should not be empty +document.body.getElementsByTagName("input")[0].autocomplete = ""; +// @ts-expect-error wrong value for this attribute +document.body.getElementsByTagName("input")[0].autocomplete = "undefined"; +// @ts-expect-error does not accept boolean attributes +document.body.getElementsByTagName("input")[0].autocomplete = "true"; +// @ts-expect-error does not accept boolean attributes +document.body.getElementsByTagName("input")[0].autocomplete = "false"; + +// @ts-expect-error missing autofill token before webauthn +document.body.getElementsByTagName("input")[0].autocomplete = "webauthn"; + +// @ts-expect-error wrong order for webauthn token +document.body.getElementsByTagName("input")[0].autocomplete = + "webauthn username"; + +// @ts-expect-error wrong order for contact specifier +document.body.getElementsByTagName("input")[0].autocomplete = "tel mobile"; + +// @ts-expect-error off should be standalone +document.body.getElementsByTagName("input")[0].autocomplete = + "section-wrong off"; + +// @ts-expect-error on should be standalone +document.body.getElementsByTagName("input")[0].autocomplete = "on username"; + +// @ts-expect-error home, work or mobile are only for contact tokens +document.body.getElementsByTagName("input")[0].autocomplete = "mobile username"; + +// @ts-expect-error should probably be current-password or new-password +document.body.getElementsByTagName("input")[0].autocomplete = "password"; + +document.body.getElementsByTagName("input")[0].autocomplete = "on"; +document.body.getElementsByTagName("input")[0].autocomplete = "off"; +document.body.getElementsByTagName("input")[0].autocomplete = "new-password"; +document.body.getElementsByTagName("input")[0].autocomplete = + "current-password"; + +document.body.getElementsByTagName("input")[0].autocomplete = + "username webauthn"; + +document.body.getElementsByTagName("input")[0].autocomplete = + "shipping street-address"; +document.body.getElementsByTagName("input")[0].autocomplete = + "section-custom shipping street-address"; + +document.body.getElementsByTagName("input")[0].autocomplete = "work email"; +document.body.getElementsByTagName("input")[0].autocomplete = + "section-custom billing mobile tel"; + +// @ts-expect-error only on and off are available on a form +document.body.getElementsByTagName("form")[0].autocomplete = "new-password"; + +document.body.getElementsByTagName("form")[0].autocomplete = "off"; + +// @ts-expect-error autocomplete attribute is only for form elements +document.body.getElementsByTagName("p")[0].autocomplete = "off"; From b3466edc8d05a2a467e7a74404c7f0b2465c097f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yann=20Breli=C3=A8re?= Date: Tue, 21 Mar 2023 12:53:52 +0100 Subject: [PATCH 7/8] Simplify optional tokens to improve maintainability Don't list all possible alterations manually. https://github.com/microsoft/TypeScript-DOM-lib-generator/pull/1467#discussion_r1111650249 --- baselines/dom.generated.d.ts | 6 ++++-- inputfiles/addedTypes.jsonc | 22 ++++++++++++++++++++-- inputfiles/knownTypes.json | 2 ++ 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/baselines/dom.generated.d.ts b/baselines/dom.generated.d.ts index df724aaea..01769a052 100644 --- a/baselines/dom.generated.d.ts +++ b/baselines/dom.generated.d.ts @@ -27926,8 +27926,8 @@ declare function addEventListener(type: string, listener: EventListenerOrEventLi declare function removeEventListener(type: K, listener: (this: Window, ev: WindowEventMap[K]) => any, options?: boolean | EventListenerOptions): void; declare function removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; type AlgorithmIdentifier = Algorithm | string; -type AutoFill = AutoFillBase | AutoFillField | `${AutoFillSection} ${AutoFillField}` | `${AutoFillAddressKind} ${AutoFillField}` | `${AutoFillSection} ${AutoFillAddressKind} ${AutoFillField}` | `${AutoFillSection} ${AutoFillAddressKind} ${AutoFillField} ${AutoFillCredentialField}` | `${AutoFillAddressKind} ${AutoFillField} ${AutoFillCredentialField}` | `${AutoFillSection} ${AutoFillField} ${AutoFillCredentialField}` | `${AutoFillField} ${AutoFillCredentialField}`; -type AutoFillField = AutoFillNormalField | AutoFillContactField | `${AutoFillContactKind} ${AutoFillContactField}`; +type AutoFill = AutoFillBase | `${OptionalPrefixToken}${OptionalPrefixToken}${AutoFillField}${OptionalPostfixToken}`; +type AutoFillField = AutoFillNormalField | `${OptionalPrefixToken}${AutoFillContactField}`; type AutoFillSection = `section-${string}`; type BigInteger = Uint8Array; type BinaryData = ArrayBuffer | ArrayBufferView; @@ -27979,6 +27979,8 @@ type NamedCurve = string; type OffscreenRenderingContext = OffscreenCanvasRenderingContext2D | ImageBitmapRenderingContext | WebGLRenderingContext | WebGL2RenderingContext; type OnBeforeUnloadEventHandler = OnBeforeUnloadEventHandlerNonNull | null; type OnErrorEventHandler = OnErrorEventHandlerNonNull | null; +type OptionalPostfixToken = ` ${T}` | ""; +type OptionalPrefixToken = `${T} ` | ""; type PerformanceEntryList = PerformanceEntry[]; type ReadableStreamController = ReadableStreamDefaultController | ReadableByteStreamController; type ReadableStreamReadResult = ReadableStreamReadValueResult | ReadableStreamReadDoneResult; diff --git a/inputfiles/addedTypes.jsonc b/inputfiles/addedTypes.jsonc index 2b175860c..788b79222 100644 --- a/inputfiles/addedTypes.jsonc +++ b/inputfiles/addedTypes.jsonc @@ -1512,20 +1512,38 @@ "name": "EventListenerOrEventListenerObject", "overrideType": "EventListener | EventListenerObject" }, + { + "name": "OptionalPrefixToken", + "typeParameters": [ + { + "name": "T extends string" + } + ], + "overrideType": "`${T} ` | \"\"" + }, + { + "name": "OptionalPostfixToken", + "typeParameters": [ + { + "name": "T extends string" + } + ], + "overrideType": "` ${T}` | \"\"" + }, { "name": "AutoFillSection", "overrideType": "`section-${string}`" }, { "name": "AutoFillField", - "overrideType": "AutoFillNormalField | AutoFillContactField | `${AutoFillContactKind} ${AutoFillContactField}`" + "overrideType": "AutoFillNormalField | `${OptionalPrefixToken}${AutoFillContactField}`" }, { // See the full list of possible autofill values for the `autocomplete` attribute: // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#determine-a-field's-category // Full spec at https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill. "name": "AutoFill", - "overrideType": "AutoFillBase | AutoFillField | `${AutoFillSection} ${AutoFillField}` | `${AutoFillAddressKind} ${AutoFillField}` | `${AutoFillSection} ${AutoFillAddressKind} ${AutoFillField}` | `${AutoFillSection} ${AutoFillAddressKind} ${AutoFillField} ${AutoFillCredentialField}` | `${AutoFillAddressKind} ${AutoFillField} ${AutoFillCredentialField}` | `${AutoFillSection} ${AutoFillField} ${AutoFillCredentialField}` | `${AutoFillField} ${AutoFillCredentialField}`" + "overrideType": "AutoFillBase | `${OptionalPrefixToken}${OptionalPrefixToken}${AutoFillField}${OptionalPostfixToken}`" } ] } diff --git a/inputfiles/knownTypes.json b/inputfiles/knownTypes.json index be0c8324f..85c2528b2 100644 --- a/inputfiles/knownTypes.json +++ b/inputfiles/knownTypes.json @@ -38,6 +38,8 @@ "Keyframe", "MutationRecordType", "NamedCurve", + "OptionalPrefixToken", + "OptionalPostfixToken", "Pbkdf2Params", "PropertyIndexedKeyframes", "RsaHashedImportParams", From 5453d21bc77c5988b56d424b06abc779eeec6c18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yann=20Breli=C3=A8re?= Date: Mon, 19 Jun 2023 19:47:39 +0200 Subject: [PATCH 8/8] Fixes after review https://github.com/microsoft/TypeScript-DOM-lib-generator/pull/1467#pullrequestreview-1486440515 --- baselines/dom.generated.d.ts | 2 +- inputfiles/addedTypes.jsonc | 8 +++++++- unittests/files/autocomplete.ts | 4 ++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/baselines/dom.generated.d.ts b/baselines/dom.generated.d.ts index 01769a052..cbf1a3c97 100644 --- a/baselines/dom.generated.d.ts +++ b/baselines/dom.generated.d.ts @@ -28006,7 +28006,7 @@ type AudioContextState = "closed" | "running" | "suspended"; type AuthenticatorAttachment = "cross-platform" | "platform"; type AuthenticatorTransport = "ble" | "hybrid" | "internal" | "nfc" | "usb"; type AutoFillAddressKind = "billing" | "shipping"; -type AutoFillBase = "off" | "on"; +type AutoFillBase = "" | "off" | "on"; type AutoFillContactField = "email" | "tel" | "tel-area-code" | "tel-country-code" | "tel-extension" | "tel-local" | "tel-local-prefix" | "tel-local-suffix" | "tel-national"; type AutoFillContactKind = "home" | "mobile" | "work"; type AutoFillCredentialField = "webauthn"; diff --git a/inputfiles/addedTypes.jsonc b/inputfiles/addedTypes.jsonc index 788b79222..dce7677b9 100644 --- a/inputfiles/addedTypes.jsonc +++ b/inputfiles/addedTypes.jsonc @@ -359,7 +359,8 @@ // Off "off", // Automatic - "on" + "on", + "" ] }, "AutoFillAddressKind": { @@ -382,6 +383,8 @@ "username", "new-password", "current-password", + // Supported in iOS Safari too even though WPT tests + // for Safari currently fail as of 2023-06. "one-time-code", "organization", @@ -1532,6 +1535,9 @@ }, { "name": "AutoFillSection", + // Note: this will also eagerly match any invalid string + // after section- instead of stopping at the first whitespace. + // It should be something like /section-\S/ if it were supported. "overrideType": "`section-${string}`" }, { diff --git a/unittests/files/autocomplete.ts b/unittests/files/autocomplete.ts index 3d0b6c023..051243fa7 100644 --- a/unittests/files/autocomplete.ts +++ b/unittests/files/autocomplete.ts @@ -1,7 +1,5 @@ // @ts-expect-error should be a string document.body.getElementsByTagName("input")[0].autocomplete = false; -// @ts-expect-error should not be empty -document.body.getElementsByTagName("input")[0].autocomplete = ""; // @ts-expect-error wrong value for this attribute document.body.getElementsByTagName("input")[0].autocomplete = "undefined"; // @ts-expect-error does not accept boolean attributes @@ -32,11 +30,13 @@ document.body.getElementsByTagName("input")[0].autocomplete = "mobile username"; // @ts-expect-error should probably be current-password or new-password document.body.getElementsByTagName("input")[0].autocomplete = "password"; +document.body.getElementsByTagName("input")[0].autocomplete = ""; document.body.getElementsByTagName("input")[0].autocomplete = "on"; document.body.getElementsByTagName("input")[0].autocomplete = "off"; document.body.getElementsByTagName("input")[0].autocomplete = "new-password"; document.body.getElementsByTagName("input")[0].autocomplete = "current-password"; +document.body.getElementsByTagName("input")[0].autocomplete = "one-time-code"; document.body.getElementsByTagName("input")[0].autocomplete = "username webauthn";