Skip to content

fix(runtime-core): preserve once event listener name#8341

Merged
edison1105 merged 5 commits into
vuejs:mainfrom
baiwusanyu-c:bwsy/fix/onOnceError
Jun 25, 2026
Merged

fix(runtime-core): preserve once event listener name#8341
edison1105 merged 5 commits into
vuejs:mainfrom
baiwusanyu-c:bwsy/fix/onOnceError

Conversation

@baiwusanyu-c

@baiwusanyu-c baiwusanyu-c commented May 17, 2023

Copy link
Copy Markdown
Member

close: #8342
relate: #8334

Issue exposed by #8334 and doesn't seem to be fixed by 7cc31a5

Summary by CodeRabbit

  • Bug Fixes

    • Improved handling of .once event listeners so event names are recognized correctly in more cases.
    • Fixed listener detection for names like onOnce and onOnceOnce.
  • Tests

    • Expanded test coverage to verify .once listener behavior.

@baiwusanyu-c baiwusanyu-c changed the title feat(runtime-core): fix onOnce error fix(runtime-core): fix onOnce error May 17, 2023
@Alfred-Skyblue

Copy link
Copy Markdown
Member

Hi, I have fixed this in #8338 , I think the regex used in parse Name should be modified to fix this.

@baiwusanyu-c

Copy link
Copy Markdown
Member Author

@Alfred-Skyblue

Copy link
Copy Markdown
Member

I only observed the problem of event modifier replacement, thank you for your addition.

# Conflicts:
#	packages/runtime-core/__tests__/componentEmits.spec.ts
@github-actions

github-actions Bot commented Jan 3, 2024

Copy link
Copy Markdown

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 106 kB (+17 B) 40.2 kB (+5 B) 36.1 kB (-8 B)
vue.global.prod.js 164 kB (+17 B) 60.2 kB (+7 B) 53.5 kB (+14 B)

Usages

Name Size Gzip Brotli
createApp (CAPI only) 48.8 kB (+17 B) 19 kB (+8 B) 17.4 kB (+8 B)
createApp 56.9 kB (+17 B) 22 kB (+8 B) 20.1 kB (+7 B)
createSSRApp 61.2 kB (+17 B) 23.8 kB (+6 B) 21.7 kB (+6 B)
defineCustomElement 63.1 kB (+17 B) 23.9 kB (+7 B) 21.8 kB (+9 B)
overall 71.7 kB (+17 B) 27.4 kB (+8 B) 25 kB (+46 B)

Comment thread packages/runtime-core/src/componentEmits.ts Outdated
@edison1105 edison1105 added 🔩 p2-edge-case ready for review This PR requires more reviews labels Aug 21, 2024
@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: a9ce67cf-3087-4af8-935f-9be092221b0f

📥 Commits

Reviewing files that changed from the base of the PR and between 05685a9 and 74fc29b.

📒 Files selected for processing (2)
  • packages/runtime-core/__tests__/componentEmits.spec.ts
  • packages/runtime-core/src/componentEmits.ts

📝 Walkthrough

Walkthrough

isEmitListener now preserves the once event name while still handling .once listener props correctly. The component emits spec adds coverage for once, onOnce, and onOnceOnce.

Changes

Once listener handling

Layer / File(s) Summary
Listener key normalization
packages/runtime-core/src/componentEmits.ts
isEmitListener changes how it strips the on prefix and trailing Once suffix so the once event name remains intact.
Once listener assertions
packages/runtime-core/__tests__/componentEmits.spec.ts
The isEmitListener spec adds an once emit option and asserts onOnce and onOnceOnce are recognized as emit listeners.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 I hopped through once and found the way,
No suffix gobbled the name away.
onOnce now sings, onOnceOnce too,
Hooray for tests that check it through!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main fix: preserving the once event listener name in runtime-core.
Linked Issues check ✅ Passed The change addresses #8342 by handling the once event name correctly and adding coverage for once listeners.
Out of Scope Changes check ✅ Passed The PR only changes the relevant runtime-core logic and its test coverage for the once listener bug.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ 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(runtime-core): fix onOnce error fix(runtime-core): preserve once event listener name Jun 25, 2026
@pkg-pr-new

pkg-pr-new Bot commented Jun 25, 2026

Copy link
Copy Markdown

Open in StackBlitz

@vue/compiler-core

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

@vue/compiler-dom

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

@vue/compiler-sfc

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

@vue/compiler-ssr

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

@vue/reactivity

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

@vue/runtime-core

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

@vue/runtime-dom

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

@vue/server-renderer

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

@vue/shared

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

vue

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

@vue/compat

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

commit: 74fc29b

@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
@edison1105

Copy link
Copy Markdown
Member

/ecosystem-ci run

@vue-bot

vue-bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

📝 Ran ecosystem CI: Open

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

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

Labels

🔩 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.

Report an error when the component event name is once

5 participants