From 7bab05ac69e7992be25b23b2017b03d2ef4f7869 Mon Sep 17 00:00:00 2001 From: Wenson Hsieh Date: Tue, 27 Aug 2024 05:57:53 -0700 Subject: [PATCH] Add the autocorrect attribute Tests: https://github.com/web-platform-tests/wpt/pull/25073. Fixes #3595. Co-authored-by: Anne van Kesteren --- source | 160 +++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 145 insertions(+), 15 deletions(-) diff --git a/source b/source index 6cce41c8b7f..f7c5dcfe634 100644 --- a/source +++ b/source @@ -11790,6 +11790,7 @@ interface HTMLElement : Element { [CEReactions] attribute boolean spellcheck; [CEReactions] attribute DOMString writingSuggestions; [CEReactions] attribute DOMString autocapitalize; + [CEReactions] attribute boolean autocorrect; [CEReactions] attribute [LegacyNullToEmptyString] DOMString innerText; [CEReactions] attribute [LegacyNullToEmptyString] DOMString outerText; @@ -13035,6 +13036,7 @@ https://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20HTML%3E% -
Autocapitalize-inheriting elements
+
Autocapitalize-and-autocorrect-inheriting + elements

Denotes elements that inherit the autocapitalize - attribute from their form owner.

+ and autocorrect attributes from their form + owner.

    @@ -46418,8 +46423,8 @@ interface HTMLLabelElement : HTMLElement {
    Flow content.
    Phrasing content.
    If the type attribute is not in the Hidden state: Interactive content.
    -
    If the type attribute is not in the Hidden state: Listed, labelable, submittable, resettable, and autocapitalize-inheriting form-associated element.
    -
    If the type attribute is in the Hidden state: Listed, submittable, resettable, and autocapitalize-inheriting form-associated element.
    +
    If the type attribute is not in the Hidden state: Listed, labelable, submittable, resettable, and autocapitalize-and-autocorrect inheriting form-associated element.
    +
    If the type attribute is in the Hidden state: Listed, submittable, resettable, and autocapitalize-and-autocorrect inheriting form-associated element.
    If the type attribute is not in the Hidden state: Palpable content.
    Contexts in which this element can be used:
    Where phrasing content is expected.
    @@ -52995,7 +53000,7 @@ You cannot submit this form when the field is incorrect.
    Flow content.
    Phrasing content.
    Interactive content.
    -
    Listed, labelable, submittable, and autocapitalize-inheriting form-associated element.
    +
    Listed, labelable, submittable, and autocapitalize-and-autocorrect inheriting form-associated element.
    Palpable content.
    Contexts in which this element can be used:
    Where phrasing content is expected.
    @@ -53210,7 +53215,7 @@ interface HTMLButtonElement : HTMLElement {
    Flow content.
    Phrasing content.
    Interactive content.
    -
    Listed, labelable, submittable, resettable, and autocapitalize-inheriting form-associated element.
    +
    Listed, labelable, submittable, resettable, and autocapitalize-and-autocorrect inheriting form-associated element.
    Palpable content.
    Contexts in which this element can be used:
    Where phrasing content is expected.
    @@ -54308,7 +54313,7 @@ interface HTMLOptionElement : HTMLElement {
    Flow content.
    Phrasing content.
    Interactive content.
    -
    Listed, labelable, submittable, resettable, and autocapitalize-inheriting form-associated element.
    +
    Listed, labelable, submittable, resettable, and autocapitalize-and-autocorrect inheriting form-associated element.
    Palpable content.
    Contexts in which this element can be used:
    Where phrasing content is expected.
    @@ -54821,7 +54826,7 @@ Daddy"></textarea>
    Categories:
    Flow content.
    Phrasing content.
    -
    Listed, labelable, resettable, and autocapitalize-inheriting form-associated element.
    +
    Listed, labelable, resettable, and autocapitalize-and-autocorrect inheriting form-associated element.
    Palpable content.
    Contexts in which this element can be used:
    Where phrasing content is expected.
    @@ -55578,7 +55583,7 @@ out of 233 257 824 bytes available</meter></p>
    Categories:
    Flow content.
    -
    Listed and autocapitalize-inheriting form-associated element.
    +
    Listed and autocapitalize-and-autocorrect inheriting form-associated element.
    Palpable content.
    Contexts in which this element can be used:
    Where flow content is expected.
    @@ -81543,8 +81548,9 @@ body { display:none } data-x="editing host">editing host to control autocapitalization behavior for the hosted editable region, on an input or textarea element to control the behavior for inputting text into that element, or on a form element to control the default - behavior for all autocapitalize-inheriting elements - associated with the form element. + behavior for all autocapitalize-and-autocorrect inheriting + elements associated with the form element.

    The autocapitalize attribute never causes autocapitalization to be enabled for input elements whose

  • If element is an autocapitalize-inheriting element and has a non-null - form owner, return the own autocapitalization hint of - element's form owner.

  • + data-x="category-autocapitalize-and-autocorrect">autocapitalize-and-autocorrect inheriting + element and has a non-null form owner, return the own + autocapitalization hint of element's form owner.

  • Return default.

  • @@ -81717,6 +81723,122 @@ body { display:none } +

    Autocorrection

    + +

    Some methods of entering text assist users by automatically correcting misspelled words while + typing, a process also known as autocorrection. User agents can support autocorrection of editable + text, either in form controls (such as the value of textarea elements), or in + elements in an editing host (e.g., using contenteditable). Autocorrection may be accompanied by user + interfaces indicating that text is about to be autocorrected or has been autocorrected, and is + commonly performed when inserting punctuation characters, spaces, or new paragraphs after + misspelled words. The autocorrect attribute allows authors + to control such behavior.

    + +

    The autocorrect attribute can be used on an editing host + to control autocorrection behavior for the hosted editable region, on an input or + textarea element to control the behavior when inserting text into that element, or on + a form element to control the default behavior for all autocapitalize-and-autocorrect inheriting + elements associated with the form element.

    + +

    The autocorrect attribute never causes autocorrection to + be enabled for input elements whose type + attribute is in one of the URL, E-mail, or Password states. (This behavior is included + in the used autocorrection state algorithm below.)

    + +

    The autocorrect attribute is an enumerated attribute with the + following keywords and states:

    + + + + + + + + +
    Keyword + State + Brief description +
    on + on + The user agent is permitted to automatically correct spelling errors while the user types. + Whether spelling is automatically corrected while typing left is for the user agent to decide, + and may depend on the element as well as the user's preferences. +
    (the empty string) +
    off + off + The user agent is not allowed to automatically correct spelling while the user types. +
    + +

    The attribute's invalid value default and missing value default are both the on state.

    + +

    The autocorrect + getter steps are: return true if the element's used autocorrection state is on and false if the element's used autocorrection + state is off. The setter steps are: if the + given value is true, then the element's autocorrect + attribute must be set to "on"; otherwise it must be set to "off".

    + +

    To compute the used autocorrection state of an element element, run these + steps:

    + +
      +
    1. If element is an input element whose type attribute is in one of the URL, E-mail, or + Password states, then return off.

    2. + +
    3. If the autocorrect content attribute is present on + element, then return the state of the attribute.

    4. + +
    5. If element is an autocapitalize-and-autocorrect inheriting + element and has a non-null form owner, then return the state of + element's form owner's autocorrect + attribute.

    6. + +
    7. Return on.

    8. +
    + +
    +
    element . autocorrect
    +

    Returns the autocorrection behavior of the element. Note that for autocapitalize-and-autocorrect inheriting + elements that inherit their state from a form element, this will return the + autocorrection behavior of the form element, but for an element in an editable + region, this will not return the autocorrection behavior of the editing host (unless + this element is, in fact, the editing host).

    + +
    element . autocorrect = + value
    +

    Updates the autocorrect content attribute (and + thereby changes the autocorrection behavior of the element).

    +
    + +
    +

    The input element in the following example would not allow autocorrection, since + it does not have an autocorrect content attribute and + therefore inherits from the form element, which has an attribute of "off". However, the textarea element would allow + autocorrection, since it has an autocorrect content + attribute with a value of "on".

    + +
    <form autocorrect="off">
    + <input type="search">
    + <textarea autocorrect="on"></textarea>
    +</form>
    +
    + +

    Input modalities: the inputmode attribute

    User agents can support the inputmode attribute on form @@ -140394,7 +140516,8 @@ interface External { — - Autocapitalize-inheriting elements + Autocapitalize-and-autocorrect + inheriting elements button; fieldset; @@ -140599,6 +140722,12 @@ interface External { textarea Hint for form autofill feature Autofill field name and related tokens* + + autocorrect + HTML elements + Recommended autocorrection behavior (for supported input methods) + "on"; + "off" autofocus HTML elements @@ -144786,6 +144915,7 @@ INSERT INTERFACES HERE Wayne Carr, Wayne Pollock, Wellington Fernando de Macedo, + Wenson Hsieh, Weston Ruter, Wilhelm Joys Andersen, Will Levine,