Skip to content

fix(runtime): fire multi-word capture listeners - #7045

Merged
johnjenkins merged 1 commit into
stenciljs:mainfrom
marcomattes:fix/capture-listeners
Nov 26, 2026
Merged

johnjenkins merged 1 commit into
stenciljs:mainfrom
marcomattes:fix/capture-listeners

Conversation

@marcomattes

@marcomattes marcomattes commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

What is the current behavior?

Multi-word standard events with a Capture suffix (e.g. onKeyDownCapture, onMouseDownCapture, onPointerDownCapture) never fire. setAccessor only lowercases the event name when on<name> exists on window; onkeydowncapture does not, so the listener falls through to the custom-event branch and is registered for keyDown instead of keydown.

GitHub Issue Number: N/A

What is the new behavior?

If the member name ends in Capture and the name without that suffix is a standard event on window, the event name is lowercased and the capture suffix handled as usual, so onKeyDownCapture listens for keydown with capture: true.

  • Standard events that themselves end in "capture" (onGotPointerCapture) are still non-capture listeners.
  • Custom events with a Capture suffix (onMyCustomEventCapture) keep their case.

Documentation

N/A

Does this introduce a breaking change?

  • Yes
  • No

Testing

Added unit tests in src/runtime/vdom/test/set-accessor.spec.ts for onKeyDownCapture, onMouseDownCapture, onPointerDownCapture, onGotPointerCaptureCapture (add + remove), onGotPointerCapture (non-capture) and onMyCustomEventCapture (custom event case preserved). Run with npm run test.jest -- set-accessor.

Other information

N/A

@marcomattes
marcomattes requested a review from a team as a code owner November 26, 2026 08:51
@johnjenkins

Copy link
Copy Markdown
Contributor

Hey @marcomattes thanks for this but non v5-specific fixes like this should go into main / v4 still atm and come into v5 downstream 🙏

@marcomattes
marcomattes changed the base branch from v5 to main November 26, 2026 12:24
@marcomattes
marcomattes force-pushed the fix/capture-listeners branch from a2366ca to f605ddd Compare November 26, 2026 12:24
@marcomattes

Copy link
Copy Markdown
Contributor Author

Thanks @johnjenkins, makes sense! I've retargeted this to main and rebased the change onto v4.

@johnjenkins johnjenkins left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

@johnjenkins
johnjenkins enabled auto-merge (squash) November 26, 2026 23:16
@johnjenkins
johnjenkins merged commit 6be7dd8 into stenciljs:main Nov 26, 2026
31 checks passed
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.

2 participants