Document the order of {{on}} listeners, ...attributes and classic handlers - #21653
Open
NullVoxPopuli wants to merge 2 commits into
Open
NullVoxPopuli wants to merge 2 commits into
NullVoxPopuli wants to merge 2 commits into
Conversation
…dlers
Adds a "Listener Order" section to the `{{on}}` docs covering:
- listeners passed in through `...attributes` run before the element's
own `{{on}}` listeners, wherever `...attributes` appears
- classic component event handler methods like `click()` run after
`{{on}}` listeners, and `stopPropagation()` in one of those listeners
prevents them
Both behaviors are pinned with tests so the docs stay accurate.
Closes emberjs#17877
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013JirFwqPVyTTFj5zPbonSh
Replace the classic component `click()` test with a @glimmer/component
that has a listener on a wrapping element, and drop the classic handler
section from the docs. Also document that changing an {{on}}'s
arguments re-adds the listener, which moves it after the others.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013JirFwqPVyTTFj5zPbonSh
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by NullVoxPopuli · project thread
Before: nothing documents which runs first when a caller passes
{{on}}through...attributesto an element that has its own{{on}}, or how{{on}}interacts with classic component methods likeclick().After: the
{{on}}API docs have a "Listener Order" section:{{on}}listeners, wherever...attributesappears on the elementclick()run after{{on}}listeners, andstopPropagation()in one of those listeners prevents themHow: the doc section in
packages/@glimmer/runtime/lib/modifiers/on.ts, plus two tests inon-test.jsthat pin both behaviors so the docs stay accurate. I first expected the order to follow the position of...attributes; the tests showed it doesn't, and the docs describe what actually happens.Closes #17877
🤖 Generated with Claude Code
https://claude.ai/code/session_013JirFwqPVyTTFj5zPbonSh