From af114db60896a3b07bc3d2198725498c6347b19c Mon Sep 17 00:00:00 2001
From: Ana Sollano Kim If map[" If element has a behavior of type
+ Return no role. Because the internal content attribute map is checked first, setting
+ Similarly, for a custom element element, the default ARIA state and
property semantics, for a state or property named stateOrProperty, are determined as
@@ -48178,6 +48185,10 @@ interface HTMLTableCellElement : HTMLElement {
attributes, buttons. The prose below defines when an element
is a button. Some buttons are specifically submit buttons. A form-associated custom element that has a
+ behavior of type The action of an element is the value of the element's
- The action of an element is: the value of the element's
+ The method of an element is one of those states. If the
- element is a submit button and has a The enctype of an element is one of those three states.
- If the element is a submit button and has a The no-validate state of an element is true if the
- element is a submit button and the element's If the user agent supports letting the user submit a form implicitly (for example, on some
platforms hitting the "enter" key while a text control is focused implicitly submits
the form), then doing so for a form, whose default button has activation
- behavior and is not disabled, must cause the user
- agent to fire a There are pages on the web that are only usable if there is a way to implicitly
@@ -63847,8 +63882,11 @@ fur
Otherwise, if submitter is a submit
- button, then set result to submitter's optional value. Close the dialog subject with result and
null. Let formTarget be null. If the submitter element is a submit
- button and it has a If submitter has a behavior of type
+ Let target be the result of getting an
element's target given submitter's form owner and
@@ -64269,9 +64314,37 @@ fur
If the field is a form-associated custom element, then perform
- the entry construction algorithm given
- field and entry list, then continue. If the field is a form-associated custom element: If field has a behavior of type
+ If field is submitter: Let submitBehavior be the behavior of
+ type If submitBehavior's name is not the
+ empty string, create an entry with submitBehavior's name and submitBehavior's value, and append it to
+ entry list. Otherwise, perform the entry construction
+ algorithm given field and entry list. Continue. If either the field element does not have a
Returns an The If options is given and options[" Let behaviorList be options[" For each behavior of
+ behaviorList: If behavior's associated element is
+ not null, then throw a If behaviorList contains another item that is the same object as
+ behavior, or another item that is an instance of the same interface as
+ behavior, then throw a Set this's attached internals to a new
If options is given and options[" Let behaviorList be options[" For each behavior of
+ behaviorList: Set behavior's associated element
+ to this. Set behavior's associated
+ internals to this's attached internals. Set this's attached internals's behaviors to the result of
+ creating a frozen array from behaviorList. Return this's attached internals. Each Each A platform-provided behavior is an object that
+ gives a custom element built-in semantics and functionality, such as acting as a submit
+ button. Platform-provided behaviors are associated with a custom element through
+ Each Each Creates a new A boolean indicating whether the element is disabled. Defaults to false. When true, the
+ element is disabled due to a
+ behavior. Returns the The URL to use for form submission, overriding the form's own The encoding type to use for form submission, overriding the form's own The HTTP method to use for form submission, overriding the form's own A boolean that, when true, bypasses form validation during submission. Defaults to
+ false. The browsing context name or keyword for form submission, overriding the form's own Returns the list of The name to use when the element is the submitter for form submission. Defaults to the
+ empty string. The value to use when the element is the submitter for form submission. Defaults to the
+ empty string. Each disabled, a boolean, initially false. formAction, a scalar value string,
+ initially the empty string. formEnctype, a string, initially the empty
+ string. formMethod, a string, initially the empty
+ string. formNoValidate, a boolean, initially
+ false. formTarget, a string, initially the empty
+ string. name, a string, initially the empty string. value, a string, initially the empty string. The Return. The The The If this's associated element is null,
+ return null. If this's associated element is not a
+ form-associated custom element, return null. Return this's associated element's
+ form owner. The The The The The The The The The The The If this's associated internals is
+ null, return null. Return this's associated
+ internals's target element's The The The The The A custom element element has a
+ behavior of a given type if element's attached internals is not null
+ and element's attached internals's behaviors contains an
+ instance of that type. To get the behavior of a given type for a custom
+ element element: if element's attached internals is
+ null, return null. Otherwise, return the item in element's attached
+ internals's behaviors that is an instance of
+ that type, or null if no such item exists. Since duplicate behavior types are rejected during attachment, the above algorithm
+ returns at most one item. Other algorithms invoke it as, e.g., "the behavior of type An element is disabled due to a
+ behavior if it is a custom element that has a
+ behavior of type The element's The element is a form-associated custom element and is disabled. The element has an ancestor A custom element element that has a
+ behavior of type If element is disabled due to a behavior, then
+ return. If element's node document is not fully active, then
+ return. If element is not a form-associated custom element, then
+ return. If element does not have a form owner, then return. Submit element's form
+ owner from element with userInvolvement set to event's user navigation involvement. The following example shows a basic custom submit button using
+ Since To override the implicit role, set Authors can expose the behavior's properties through getters and setters, and forward relevant
+ attribute values using The form-submission-attribute properties on the behavior ( If this element is a form control that is disabled, then return. If this element is disabled due to a behavior, then
+ return. If this element's click in progress flag is set, then return. Set this element's click in progress flag.role"] exists,
then return it.HTMLSubmitButtonBehavior, then return "button".internals.role always takes precedence over the implicit "button" role provided by HTMLSubmitButtonBehavior.HTMLSubmitButtonBehavior is a submit button.formaction attribute, if the element is a submit button and has such an attribute, or the value of its
- form owner's action attribute, if it has
- one, or else the empty string.HTMLSubmitButtonBehavior's formAction, if the element has a
+ behavior of type HTMLSubmitButtonBehavior and that value is not the empty
+ string; or the value of the element's formaction
+ attribute, if the element is a submit button that does
+ not have a behavior of type
+ HTMLSubmitButtonBehavior and has such an attribute; or the value of its form
+ owner's action attribute, if it has one, or
+ else the empty string.
@@ -60483,10 +60499,17 @@ form.method === input; // => true
has a behavior of type
+ HTMLSubmitButtonBehavior and the behavior's formMethod is not the empty string, then the element's method is the state corresponding to that value, interpreted as
+ if it were the value of the formmethod attribute;
+ otherwise, if the element is a submit button that does
+ not have a behavior of type
+ HTMLSubmitButtonBehavior and has a formmethod attribute, then the element's method is that attribute's state; otherwise, it is the form
- owner's method attribute's state.method attribute's state.
formenctype attribute, then the element's has a behavior of type
+ HTMLSubmitButtonBehavior and the behavior's formEnctype is not the empty string, then the element's
+ enctype is the state corresponding to that value,
+ interpreted as if it were the value of the formenctype attribute; otherwise, if the element is a submit button that does not have a behavior of type HTMLSubmitButtonBehavior and has
+ a formenctype attribute, then the element's enctype is that attribute's state; otherwise, it is the
form owner's enctype attribute's state.formnovalidate attribute is present, or if the element's
- form owner's novalidate attribute is present,
- and false otherwise.HTMLSubmitButtonBehavior and the behavior's formNoValidate is true, or if the element is a submit button that does not have a behavior of type HTMLSubmitButtonBehavior and the
+ element's formnovalidate attribute is present, or if
+ the element's form owner's novalidate
+ attribute is present, and false otherwise.
click event at that default
- button.click event at that
+ default button.
HTMLSubmitButtonBehavior, then set result to that behavior's value; otherwise, set result to
+ submitter's optional
+ value.
formtarget attribute, then
- set formTarget to the formtarget attribute
- value.HTMLSubmitButtonBehavior and the behavior's formTarget is not the empty string, then set
+ formTarget to that value. Otherwise, if the submitter element is a submit button that does not have a behavior of type HTMLSubmitButtonBehavior and
+ it has a formtarget attribute, then set
+ formTarget to the formtarget attribute
+ value.
+
+
+ HTMLSubmitButtonBehavior:
+
+
+
+ HTMLSubmitButtonBehavior for field.name attribute specified, or its
@@ -78685,12 +78758,15 @@ customElements.define("x-foo", class extends HTMLElement {
control over internal features which the user agent provides to all elements.
-
element.attachInternals()element.attachInternals(options)ElementInternals object targeting the custom element
element. Throws an exception if element is not a custom
element, if the "internals" feature was disabled as part of the
- element definition, or if it is called twice on the same element.behaviors member,
+ the specified platform-provided behaviors are
+ associated with the element.
attachInternals() method steps are:
@@ -78728,10 +78804,63 @@ customElements.define("x-foo", class extends HTMLElement {
data-x="">precustomized" or "
custom", then throw a
"NotSupportedError" DOMException.
+ behaviors"] exists:
+
+ behaviors"].
+
+ TypeError.TypeError.ElementInternals instance whose target
element is this.behaviors"] exists:
+
+ behaviors"].
+
+ ElementInternals has a target element,
which is a custom element.ElementInternals has behaviors, a FrozenArray of
+ ElementBehavior objects, initially an empty FrozenArray.Shadow root access
@@ -79183,6 +79323,401 @@ this._internals.states.delete("interactive");
this._internals.states.add("complete");
Platform-provided behaviors
+
+ attachInternals().
+
+ [Exposed=Window]
+interface ElementBehavior {
+};
+
+[Exposed=Window]
+interface HTMLSubmitButtonBehavior : ElementBehavior {
+ constructor();
+
+ attribute boolean disabled;
+ readonly attribute HTMLFormElement? form;
+ attribute USVString formAction;
+ attribute DOMString formEnctype;
+ attribute DOMString formMethod;
+ attribute boolean formNoValidate;
+ attribute DOMString formTarget;
+ readonly attribute NodeList? labels;
+ attribute DOMString name;
+ attribute DOMString value;
+};ElementBehavior has an associated
+ element (null or an Element), initially null.ElementBehavior has associated
+ internals (null or an ElementInternals), initially null.
+
+
+ new HTMLSubmitButtonBehavior()HTMLSubmitButtonBehavior instance. The instance has to be passed
+ to attachInternals() via the behaviors option to take effect.submitBehavior.disabledsubmitBehavior.formform element associated with the behavior's associated element, or null if the element is not a
+ form-associated custom element. This delegates to the element's form property.submitBehavior.formActionaction attribute. Defaults to the empty string.submitBehavior.formEnctypeenctype attribute. Defaults to the empty string.submitBehavior.formMethodmethod attribute. Defaults to the empty string.submitBehavior.formNoValidatesubmitBehavior.formTargettarget attribute. Defaults to the empty string.submitBehavior.labelslabel elements associated with the behavior's associated element, or null. This delegates to the element's
+ labels property via the associated internals.submitBehavior.namesubmitBehavior.valueHTMLSubmitButtonBehavior has the following internal state:
+
+
+ HTMLSubmitButtonBehavior() constructor steps
+ are:
+
+ disabled getter steps are to return
+ this's disabled.disabled setter steps are to
+ set this's disabled to the given
+ value.form getter steps are:
+
+ formAction getter steps are to
+ return this's formAction.formAction setter steps are
+ to set this's formAction to the given
+ value.formEnctype getter steps are to
+ return this's formEnctype.formEnctype setter steps are
+ to set this's formEnctype to the given
+ value.formMethod getter steps are to
+ return this's formMethod.formMethod setter steps are
+ to set this's formMethod to the given
+ value.formNoValidate getter steps are
+ to return this's formNoValidate.formNoValidate setter
+ steps are to set this's formNoValidate to the given value.formTarget getter steps are to
+ return this's formTarget.formTarget setter steps are
+ to set this's formTarget to the given
+ value.labels getter steps are:
+
+ labels.name getter steps are to return
+ this's name.name setter steps are to set
+ this's name to the given value.value getter steps are to return
+ this's value.value setter steps are to set
+ this's value to the given value.behaviors getter steps are to return
+ this's behaviors.HTMLSubmitButtonBehavior for
+ element".HTMLSubmitButtonBehavior and any of the following conditions
+ are true:
+
+
+ HTMLSubmitButtonBehavior's disabled is true.fieldset that is disabled, and the element is not a descendant of that
+ fieldset element's first legend element child, if any.HTMLSubmitButtonBehavior has the following activation
+ behavior given event:
+
+ HTMLSubmitButtonBehavior:
+
+ class MySubmitButton extends HTMLElement {
+ static formAssociated = true;
+
+ constructor() {
+ super();
+ this._behavior = new HTMLSubmitButtonBehavior();
+ this._internals = this.attachInternals({ behaviors: [this._behavior] });
+ }
+}
+customElements.define('my-submit-button', MySubmitButton);formAssociated is true, the element participates in form
+ submission. The HTMLSubmitButtonBehavior makes it act as a submit button: it gets an
+ implicit button ARIA role, it becomes focusable, and clicking it submits
+ the form.
+
+ <form action="/submit">
+ <label>Name: <input type=text name=username></label>
+ <my-submit-button>Submit</my-submit-button>
+</form>internals.role:
+ // Override the implicit "button" role:
+this._internals.role = 'menuitem';attributeChangedCallback:
+
+ class FancySubmit extends HTMLElement {
+ static formAssociated = true;
+ static observedAttributes = ['disabled', 'formaction', 'name', 'value'];
+
+ constructor() {
+ super();
+ this._behavior = new HTMLSubmitButtonBehavior();
+ this._internals = this.attachInternals({ behaviors: [this._behavior] });
+ }
+
+ get disabled() { return this._behavior.disabled; }
+ set disabled(v) { this._behavior.disabled = v; }
+
+ get name() { return this._behavior.name; }
+ set name(v) { this._behavior.name = v; }
+
+ get value() { return this._behavior.value; }
+ set value(v) { this._behavior.value = v; }
+
+ attributeChangedCallback(name, oldValue, newValue) {
+ switch (name) {
+ case 'disabled':
+ this._behavior.disabled = newValue !== null;
+ break;
+ case 'formaction':
+ this._behavior.formAction = newValue ?? '';
+ break;
+ case 'name':
+ this._behavior.name = newValue ?? '';
+ break;
+ case 'value':
+ this._behavior.value = newValue ?? '';
+ break;
+ }
+ }
+}formAction, formEnctype, formMethod, formNoValidate, formTarget) are read from the behavior
+ instance, not from the element's content attributes. This means authors must explicitly forward
+ attribute values in attributeChangedCallback if they want
+ declarative attribute control.Common idioms without dedicated elements
Breadcrumb navigation
@@ -79572,6 +80107,9 @@ contradict people?
HTMLSubmitButtonBehavior and are not disabled due to a behavior
Return.
If NewTarget is not HTMLSubmitButtonBehavior, then throw a
+ TypeError.
Platform-provided behaviors are not designed to be subclassed. The duplicate-type
+ check during attachment uses instanceof, so subclasses of
+ HTMLSubmitButtonBehavior would conflict with each other in unintuitive ways.
The disabled getter steps are to return
From 149f5086625b7896a73d0ed739064ae6f7ceadd4 Mon Sep 17 00:00:00 2001
From: Ana Sollano Kim attachInternals().
Platform-provided behaviors are not designed to be subclassed. To enforce this, each
+ platform-provided behavior interface is annotated with the [NotSubclassable] extended attribute, defined below.
[Exposed=Window]
interface ElementBehavior {
};
-[Exposed=Window]
+[Exposed=Window, NotSubclassable]
interface HTMLSubmitButtonBehavior : ElementBehavior {
constructor();
@@ -79428,20 +79432,30 @@ interface HTMLSubmitButtonBehavior : ElementBehavior<
value, a string, initially the empty string.
+ The [NotSubclassable] IDL extended attribute
+ indicates that the annotated interface cannot be subclassed: invoking any of its constructor
+ operations from a subclass throws a TypeError.
+
+ The [NotSubclassable] extended attribute must take no
+ arguments, and must only appear on interfaces. It must appear only once on an interface.
+
- The HTMLSubmitButtonBehavior() constructor steps
- are:
+ Every constructor operation of an interface annotated with the [NotSubclassable] extended attribute has the following additional
+ constructor step, performed before that constructor's other constructor steps:
- If NewTarget is not HTMLSubmitButtonBehavior, then throw a
- TypeError.
+ If NewTarget is not equal to the active function object, then
+ throw a TypeError.
- Platform-provided behaviors are not designed to be subclassed. The duplicate-type
- check during attachment uses instanceof, so subclasses of
- HTMLSubmitButtonBehavior would conflict with each other in unintuitive ways.
+
+ The HTMLSubmitButtonBehavior() constructor steps
+ are to do nothing.
+
The