Add platform-provided behaviors for custom elements & submit behavior#12409
Add platform-provided behaviors for custom elements & submit behavior#12409anaskim wants to merge 2 commits intowhatwg:mainfrom
Conversation
0456d21 to
809a55a
Compare
d75a481 to
af114db
Compare
|
I have done an initial pass, just glossing over this. Things look generally good (though I will look a lot closer later this week). One question that stands out from a first pass: we use instanceof checks to check a behaviour, which prompts me to check subclasses. The behaviour is a little surprising... So for example in Chrome today: class Foo extends HTMLSubmitButtonBehavior { };
class Bar extends HTMLSubmitButtonBehavior { };
class MyEl extends HTMLElement {
constructor() {
super();
this.foo = new Foo();
this.bar = new Bar();
this.attachInternals({ behaviors: [this.foo, this.bar] });
}
}
customElements.define('my-el', MyEl);
document.createElement('my-el');This gives me an error of My assumption would have been we prevent users from extending behaviours; there are a lot of questions about what inheriting means, especially for a native behaviour. Might be worth some investigation. I think the plausible answers are "prevent inheritance" or "offer a lot more detail on what's possible/use cases for inheritance". |
Thanks for taking a look, @keithamus! My inclination is to say that subclassing platform-provided behaviors like HTMLSubmitButtonBehavior should not be allowed. The I’ve updated the spec text so |
#12150
This change introduces platform-provided behaviors, a mechanism that allows autonomous custom elements to adopt built-in HTML element capabilities via
attachInternals(). The initial element behavior isHTMLSubmitButtonBehavior, which gives a custom element submit button semantics including form submission, activation, focusability, and an implicit ARIA role.Explainer: https://github.com/MicrosoftEdge/MSEdgeExplainers/blob/main/PlatformProvidedBehaviors/explainer.md
(See WHATWG Working Mode: Changes for more details.)
/custom-elements.html ( diff )
/dom.html ( diff )
/form-control-infrastructure.html ( diff )
/forms.html ( diff )
/index.html ( diff )
/interaction.html ( diff )
/semantics-other.html ( diff )