Description
What is the issue with the HTML Standard?
There are 3 places in the specification where the reset algorithm is triggered:
-
The reset algorithm, which resets the state of all form participants to default values
- If reset is true, then invoke the reset algorithm of each resettable element whose form owner is form.
-
The create an element for a token algorithm, whose task is to create an element for the HTML parser.
- If element is a resettable element, invoke its reset algorithm. (This initializes the element's value and checkedness based on the element's attributes.)
-
The reactivate algorithm, which is used to update the document
- For each formControl of form controls in document with an autofill field name of "off", invoke the reset algorithm for formControl.
The first case works fine, no questions about it, no matter whether via a button or via the reset() API, it works well and the formResetCallback
hook makes itself known.
The second case fails, it does not call the formResetCallback
hook (detailed below).
The third case also does not execute the formResetCallback
hook, the conditions for its execution are unachievable (due with form-associated custom elements).
As a small test, I made this example for the create an element for a token case:
<script>
customElements.define("my-input", class extends HTMLElement {
static formAssociated = true;
connectedCallback() {
console.log("my-input connected");
}
formResetCallback() {
console.log("my-input performed formResetCallback");
}
});
</script>
<form>
<my-input></my-input>
</form>
And if you run such html file with a custom element that has the reset algorithm:
The reset algorithm for form-associated custom elements is to enqueue a custom element callback reaction with the element, callback name "formResetCallback", and an empty argument list.
Then we will not see the called formResetCallback
hook, but this should work (yes, we are talking about the second case, when the HTML parser creates an element for the token and after run reset algorithm in step 13).
I checked this in the latest Chrome and Firefox, the hook is not called. What's wrong?
Maybe problem is in this note, why implementations don't correspond the step 13:
A custom element possesses the ability to respond to certain occurrences by running author code:
- When the form owner of a form-associated custom element is reset, its formResetCallback is called.
By the way, that wpt test is too old, it does not check what I am talking about.
What do you say editors?