Skip to content

[Platform-provided behaviors for CE] Address feedback, add alternative to main proposal#1340

Open
anaskim wants to merge 2 commits into
MicrosoftEdge:mainfrom
anaskim:platform-provided-behaviors-mutability-lifecycle
Open

[Platform-provided behaviors for CE] Address feedback, add alternative to main proposal#1340
anaskim wants to merge 2 commits into
MicrosoftEdge:mainfrom
anaskim:platform-provided-behaviors-mutability-lifecycle

Conversation

@anaskim

@anaskim anaskim commented Jun 9, 2026

Copy link
Copy Markdown
Member

Updates

Main explainer

  • User-facing problem: Promote the form-control pseudo-class set and the native focusability algorithm into the reimplementation bullet.
  • User research: Reframe the closing paragraph around <button type="submit"> as a single-element conformance target that exercises every part of the framework.
  • Dynamic behaviors: Add set / state / participation at the start of the section.
  • attachInternals() lifecycle: attachInternals() can be called from the constructor, connectedCallback, or attributeChangedCallback, depending on whether attributes are set before or after construction.
  • Alt API design 3: Open questions resolved; the recomputation table collapsed into a single sentence pair.
  • Behavior composition and conflict resolution: Moved out of the main proposal area into Future work (only HTMLSubmitButtonBehavior ships initially; composition becomes relevant once additional behaviors land).
  • HTMLSubmitButtonBehavior properties: Added title with a note that it surfaces through the user agent's default tooltip UI. Removed the attributeChangedCallback example.
  • Trimming and fixes: Cut duplicate examples in Accessing behavior state, API design, Conflicting behaviors, and Other considerations. Folded "Why start with form submission?" into the Introduction. Converted the Behavior lifecycle table to a paragraph. Fixed an invalid optional-chaining assignment in the opening Proposed approach example.

New alternative

New file: PlatformProvidedBehaviors/htmlbuttonbehavior-with-type-attribute.md. Side document exploring an alternative:

  1. Collapses the three button modes (submit, reset, generic-button) into a single HTMLButtonBehavior whose type property mirrors the type attribute of native <button> and toggles the active mode at runtime.
  2. Declares behaviors via a static behaviors class property. The platform instantiates each declared behavior at element creation; authors look up the instance through internals.behaviors.get(HTMLButtonBehavior).

Apply feedback from WHATWG #12150 and from multiple internal review
rounds across the main explainer's User-facing problem, User research,
Dynamic behaviors, Alt API design 3, and HTMLSubmitButtonBehavior
Properties sections. Add Alt API design 5 (standard-defined strings)
covering the shapes raised in WHATWG #12150. Move Behavior composition
and conflict resolution into Future work. Replace prescriptive
attachInternals() lifecycle guidance with neutral language. Cut
duplicate examples and convert the Behavior lifecycle table to prose.

Add htmlbuttonbehavior-with-type-attribute.md, a side document
exploring an alternative direction that collapses the three button
modes (submit, reset, generic-button) into a single HTMLButtonBehavior
whose type property mirrors native <button>'s type attribute, and
declares behaviors via a static class property (symmetric with
static formAssociated) with platform-owned instantiation. Authors
look up the platform-created instance through
internals.behaviors.get(HTMLButtonBehavior).

Net contribution vs. upstream/main: 2 files, +358 / -236.
@anaskim anaskim force-pushed the platform-provided-behaviors-mutability-lifecycle branch from dcf7800 to 9708740 Compare June 9, 2026 17:59
@anaskim anaskim requested a review from dandclark June 9, 2026 18:12
@anaskim anaskim marked this pull request as ready for review June 9, 2026 18:12
@anaskim anaskim requested a review from leotlee June 9, 2026 18:12
`HTMLButtonElement`'s IDL adds form-control properties on top of
`HTMLElement` but does not override `title`, `tabIndex`, `hidden`,
`lang`, `dir`, `accessKey`, or `draggable`. All of these are pure
`HTMLElement` surface that custom elements already inherit. Including
`title` in the behavior interface would be redundant and would imply
the behavior is involved in tooltip surfacing when it is not.

Drop `title` from the Properties lists in both the main explainer
(`HTMLSubmitButtonBehavior`) and the type-attribute alternative
(`HTMLButtonBehavior`). Add a short note after each list pointing
out that `HTMLElement`-inherited properties work directly on the
host without behavior involvement.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant