Skip to content

fix(runtime-dom): preserve option modifier event names#8338

Merged
edison1105 merged 25 commits into
vuejs:mainfrom
Alfred-Skyblue:fix-events
Jun 25, 2026
Merged

fix(runtime-dom): preserve option modifier event names#8338
edison1105 merged 25 commits into
vuejs:mainfrom
Alfred-Skyblue:fix-events

Conversation

@Alfred-Skyblue

@Alfred-Skyblue Alfred-Skyblue commented May 16, 2023

Copy link
Copy Markdown
Member

fixed #8334

Summary by CodeRabbit

  • Bug Fixes
    • Improved parsing and handling of event listener modifiers so once, passive, and capture combinations behave consistently.
    • Preserved modifier-style event names (e.g., on:Once / on:Passive / on:Capture) more reliably, including for custom elements.
    • Ensured handlers fire the expected number of times (including correct once behavior).
  • Tests
    • Added coverage for modifier handling, once behavior, custom elements, and modifier name casing to prevent regressions.

@Alfred-Skyblue Alfred-Skyblue changed the title fix(events): fix custom element capture, once, passive events fix(events): fix DOM event options modifer handling May 16, 2023
Comment thread packages/runtime-dom/src/modules/events.ts Outdated
@Alfred-Skyblue

Copy link
Copy Markdown
Member Author

👀

@github-actions

github-actions Bot commented Aug 22, 2023

Copy link
Copy Markdown

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 106 kB (+36 B) 40.3 kB (+17 B) 36.2 kB (+38 B)
vue.global.prod.js 165 kB (+36 B) 60.3 kB (+23 B) 53.6 kB (+53 B)

Usages

Name Size Gzip Brotli
createApp (CAPI only) 48.9 kB (+36 B) 19 kB (+13 B) 17.4 kB (+24 B)
createApp 57.1 kB (+36 B) 22 kB (+12 B) 20.2 kB (+23 B)
createSSRApp 61.4 kB (+36 B) 23.9 kB (+13 B) 21.8 kB (+18 B)
defineCustomElement 63.3 kB (+36 B) 24 kB (+18 B) 21.9 kB (+42 B)
overall 71.9 kB (+36 B) 27.5 kB (+15 B) 25.1 kB (+20 B)

@codspeed-hq

codspeed-hq Bot commented Dec 20, 2023

Copy link
Copy Markdown

CodSpeed Performance Report

Merging #8338 will not alter performance

Comparing Alfred-Skyblue:fix-events (4bc6b1e) with main (9fa8241)

Summary

✅ 53 untouched benchmarks

Comment thread packages/runtime-dom/src/modules/events.ts Outdated
@netlify

netlify Bot commented Aug 12, 2024

Copy link
Copy Markdown

Deploy Preview for vue-next-template-explorer failed.

Name Link
🔨 Latest commit 9e99af1
🔍 Latest deploy log https://app.netlify.com/sites/vue-next-template-explorer/deploys/66b953958bcfc80008e7f63d

@edison1105 edison1105 added 🐞 bug Something isn't working 🔩 p2-edge-case labels Aug 16, 2024
@edison1105 edison1105 added the ready for review This PR requires more reviews label Aug 16, 2024
@pkg-pr-new

pkg-pr-new Bot commented Aug 20, 2024

Copy link
Copy Markdown

Open in StackBlitz

@vue/compiler-core

pnpm add https://pkg.pr.new/@vue/compiler-core@8338
npm i https://pkg.pr.new/@vue/compiler-core@8338
yarn add https://pkg.pr.new/@vue/compiler-core@8338.tgz

@vue/compiler-dom

pnpm add https://pkg.pr.new/@vue/compiler-dom@8338
npm i https://pkg.pr.new/@vue/compiler-dom@8338
yarn add https://pkg.pr.new/@vue/compiler-dom@8338.tgz

@vue/compiler-sfc

pnpm add https://pkg.pr.new/@vue/compiler-sfc@8338
npm i https://pkg.pr.new/@vue/compiler-sfc@8338
yarn add https://pkg.pr.new/@vue/compiler-sfc@8338.tgz

@vue/compiler-ssr

pnpm add https://pkg.pr.new/@vue/compiler-ssr@8338
npm i https://pkg.pr.new/@vue/compiler-ssr@8338
yarn add https://pkg.pr.new/@vue/compiler-ssr@8338.tgz

@vue/reactivity

pnpm add https://pkg.pr.new/@vue/reactivity@8338
npm i https://pkg.pr.new/@vue/reactivity@8338
yarn add https://pkg.pr.new/@vue/reactivity@8338.tgz

@vue/runtime-core

pnpm add https://pkg.pr.new/@vue/runtime-core@8338
npm i https://pkg.pr.new/@vue/runtime-core@8338
yarn add https://pkg.pr.new/@vue/runtime-core@8338.tgz

@vue/runtime-dom

pnpm add https://pkg.pr.new/@vue/runtime-dom@8338
npm i https://pkg.pr.new/@vue/runtime-dom@8338
yarn add https://pkg.pr.new/@vue/runtime-dom@8338.tgz

@vue/server-renderer

pnpm add https://pkg.pr.new/@vue/server-renderer@8338
npm i https://pkg.pr.new/@vue/server-renderer@8338
yarn add https://pkg.pr.new/@vue/server-renderer@8338.tgz

@vue/shared

pnpm add https://pkg.pr.new/@vue/shared@8338
npm i https://pkg.pr.new/@vue/shared@8338
yarn add https://pkg.pr.new/@vue/shared@8338.tgz

vue

pnpm add https://pkg.pr.new/vue@8338
npm i https://pkg.pr.new/vue@8338
yarn add https://pkg.pr.new/vue@8338.tgz

@vue/compat

pnpm add https://pkg.pr.new/@vue/compat@8338
npm i https://pkg.pr.new/@vue/compat@8338
yarn add https://pkg.pr.new/@vue/compat@8338.tgz

commit: a78b063

@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 35344d51-c706-4d9c-96bf-7b8065565111

📥 Commits

Reviewing files that changed from the base of the PR and between 13cc856 and a78b063.

📒 Files selected for processing (2)
  • packages/runtime-dom/__tests__/patchEvents.spec.ts
  • packages/runtime-dom/src/modules/events.ts
💤 Files with no reviewable changes (2)
  • packages/runtime-dom/src/modules/events.ts
  • packages/runtime-dom/tests/patchEvents.spec.ts

📝 Walkthrough

Walkthrough

Event prop parsing now strips modifier suffixes in a loop while preserving on:-prefixed modifier event names. Added tests cover once, custom elements, and preserved-case modifier event names.

Changes

Custom element modifier events

Layer / File(s) Summary
Modifier parsing update
packages/runtime-dom/src/modules/events.ts
parseName now strips recognized modifier suffixes in a loop, uses a dedicated on: modifier-event regex, and slices by the captured modifier text.
Event option tests
packages/runtime-dom/__tests__/patchEvents.spec.ts
patchProp tests cover once with passive capture, custom elements, onOnceOnce, and on:Once/on:Passive/on:Capture handler invocation counts.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested labels

:hammer: p3-minor-bug

Poem

🐰 I hopped through modifiers, light and spry,
once and capture now pass by.
Custom elements twitch, then behave just so,
on:Passive and friends keep their glow.
A carrot for tests, and a tidy little fix below.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately describes the main runtime-dom event-name fix.
Linked Issues check ✅ Passed The parser change and new tests address custom element events named capture, once, and passive as required by #8334.
Out of Scope Changes check ✅ Passed The changes are limited to event parsing and targeted tests, with no明显 unrelated scope added.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@edison1105 edison1105 changed the title fix(events): fix DOM event options modifer handling fix(runtime-dom): preserve option modifier event names Jun 25, 2026
@edison1105 edison1105 added ready to merge The PR is ready to be merged. and removed ready for review This PR requires more reviews labels Jun 25, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/runtime-dom/__tests__/patchEvents.spec.ts`:
- Line 228: The custom element registration in patchEvents.spec.ts can collide
with prior test runs because hello-world may already be defined. Update the
TestCustomElement registration near customElements.define to guard against
re-definition, e.g. only define it when the tag is not already present or use a
setup helper that safely registers once. Keep the change localized to the test
setup around TestCustomElement so the suite remains order-independent.
- Around line 230-232: The custom element creation in patchEvents.spec.ts is
using the wrong creation form for an autonomous custom element. Update the test
to call document.createElement('hello-world') directly and remove the
unnecessary second-argument options object with is, since that form is only for
customized built-ins. Keep the change localized to the customElement setup in
the test.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 22cee3b8-f5a0-4f68-abca-e51f82bab4b5

📥 Commits

Reviewing files that changed from the base of the PR and between 05685a9 and 926d971.

📒 Files selected for processing (2)
  • packages/runtime-dom/__tests__/patchEvents.spec.ts
  • packages/runtime-dom/src/modules/events.ts

Comment thread packages/runtime-dom/__tests__/patchEvents.spec.ts Outdated
Comment thread packages/runtime-dom/__tests__/patchEvents.spec.ts Outdated
@vuejs vuejs deleted a comment from Alfred-Skyblue Jun 25, 2026
@edison1105

Copy link
Copy Markdown
Member

/ecosystem-ci run

@vuejs vuejs deleted a comment from edison1105 Jun 25, 2026
@vue-bot

vue-bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

📝 Ran ecosystem CI: Open

suite result latest scheduled
vue-i18n success success
radix-vue failure failure
primevue success success
test-utils success success
vite-plugin-vue success failure
pinia success success
router success success
language-tools success success
vant success success
quasar success success
vueuse success success
vitepress success failure
vue-macros success success
nuxt success success
vuetify success failure
vue-simple-compiler success failure

@edison1105 edison1105 merged commit 4b659e6 into vuejs:main Jun 25, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 bug Something isn't working 🔩 p2-edge-case ready to merge The PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Vue 3 does not handle events with specific names (capture, once, passive) from custom element

5 participants