Ready for Developer Testing: Platform-provided behaviors

52 views
Skip to first unread message

Chromestatus

unread,
6:15 PM (2 hours ago) 6:15 PM
to blin...@chromium.org, alu...@microsoft.com, anso...@microsoft.com, dan...@microsoft.com, leo...@microsoft.com
Contact emails
anso...@microsoft.com, leo...@microsoft.com, dan...@microsoft.com, alu...@microsoft.com

Explainer
https://github.com/MicrosoftEdge/MSEdgeExplainers/blob/main/PlatformProvidedBehaviors/explainer.md

Specification
https://github.com/whatwg/html/pull/12409

Design docs

https://docs.google.com/document/d/1LA1hhzxmi4OmZoGtIdnwvL3g7y48YjXTOoUvFtxFugE/edit?usp=sharing

Summary
This feature introduces "Platform-Provided Behaviors" to ElementInternals, allowing custom elements to adopt native behaviors without extending native elements or reimplementing complex logic. It modifies attachInternals to accept a list of behaviors, starting with HTMLSubmitButtonBehavior, which wires up form submission on activation.

Blink component
Blink>DOM

Web Feature ID
Missing feature

Goals for experimentation
None

Risks


Interoperability and Compatibility
This is a new API surface (new global constructors and a new option on attachInternals), so there is no backward compatibility risk. The main interop risk is that other engines' positions are still pending. The API can be polyfillable: authors can feature-detect HTMLSubmitButtonBehavior and fall back to manual event handling (form.requestSubmit) if unavailable. The behaviors option on attachInternals is additive; calling attachInternals() without it works exactly as before.

Gecko: No signal (https://github.com/mozilla/standards-positions/issues/1380)

WebKit: No signal (https://github.com/WebKit/standards-positions/issues/642)

Web developers: Positive (https://docs.google.com/document/d/1eU_c4_fQ1yVSm8mjjfuqd1wWN9T8z2N6dr4XIwMv9uM/edit?usp=sharing)

Other signals:

Ergonomics
The API requires authors to manually forward HTML attributes to behavior properties (e.g., observing the "disabled" attribute and setting behavior.disabled in attributeChangedCallback). This keeps the platform layer minimal and gives authors full control. The pattern to instantiate and then attach behaviors (new HTMLSubmitButtonBehavior() + attachInternals({ behaviors: [...] })) is consistent with existing web platform patterns and W3C design principles for constructable objects.

Activation
The feature can be immediately adopted by custom element experienced with ElementInternals and form associated elements without much overhead. Polyfilling is feasible since the behavior's capabilities (click/keyboard activation, form submission) can be approximated with existing APIs. Framework authors who currently work around the manual event wiring are the primary early adopters and can benefit immediately.

Security
This feature exposes existing platform capabilities (form submission, activation, focusability) to custom elements. Form submission triggered by HTMLSubmitButtonBehavior uses the same FormSubmission infrastructure as native <button type="submit">, subject to the same CSP, CORS, navigation, and validation checks. No new data is exposed, no new script execution mechanisms are introduced, and no cross-origin information is leaked.

WebView application risks

Does this intent deprecate or change behavior of existing APIs, such that it has potentially high risk for Android WebView-based applications?

Low, new API.


Debuggability
Element behaviors are inspectable via the ElementInternals object. In DevTools, developers can access the stored reference to inspect the array of attached behaviors and their properties (disabled, formAction, form, name, value, etc.). The element's computed accessibility role is visible in the DevTools Accessibility pane. A console warning is emitted if behaviors are attached to a non-form-associated custom element.

Will this feature be supported on all six Blink platforms (Windows, Mac, Linux, ChromeOS, Android, and Android WebView)?
Yes
This feature operates entirely at the DOM/rendering layer with no platform-specific dependencies. It wires up event handling, form submission, accessibility roles, and focus management using existing cross-platform Blink infrastructure.

Is this feature fully tested by web-platform-tests?
Yes
https://wpt.fyi/results/custom-elements/form-associated?label=master&label=experimental&aligned&q=form-associated%20is%3Atentative, https://wpt.fyi/results/custom-elements?label=master&label=experimental&aligned&q=is%3Atentative

DevTrial instructions
https://github.com/MicrosoftEdge/MSEdgeExplainers/blob/main/PlatformProvidedBehaviors/HOWTO.md

Flag name on about://flags
enable-experimental-web-platform-features

Finch feature name
ElementInternalsBehaviors

Requires code in //chrome?
False

Tracking bug
https://issues.chromium.org/issues/486928684

Measurement
Three UseCounters track adoption: 1. ElementInternalsWithBehaviors: attachInternals() is called with the behaviors option https://chromestatus.com/metrics/feature/timeline/popularity/5878 2. HTMLSubmitButtonBehaviorUsage: new HTMLSubmitButtonBehavior() https://chromestatus.com/metrics/feature/timeline/popularity/5879 3. ElementInternalsBehaviorsAccess: ElementInternals.behaviors property is accessed https://chromestatus.com/metrics/feature/timeline/popularity/5880

Estimated milestones
DevTrial on desktop149
DevTrial on Android149


Link to entry on the Chrome Platform Status
https://chromestatus.com/feature/6035800057839616

Links to previous Intent discussions
Intent to Prototype: https://groups.google.com/a/chromium.org/g/blink-dev/c/ETKzYhB6BbI/m/0jQaazNHAQAJ


This intent message was generated by Chrome Platform Status.
Reply all
Reply to author
Forward
0 new messages