Skip to content

fix(runtime-core): fix onOnce error #8341

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

baiwusanyu-c
Copy link
Member

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

close: #8342
relate: #8334

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

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

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

@Alfred-Skyblue
Copy link
Member

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

# Conflicts:
#	packages/runtime-core/__tests__/componentEmits.spec.ts
Copy link

github-actions bot commented Jan 3, 2024

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 89.5 kB (+31 B) 34 kB (+11 B) 30.7 kB (+14 B)
vue.global.prod.js 147 kB (+31 B) 53.3 kB (+14 B) 47.6 kB (-11 B)

Usages

Name Size Gzip Brotli
createApp 49.9 kB (+31 B) 19.5 kB (+12 B) 17.9 kB (+55 B)
createSSRApp 53.2 kB (+31 B) 20.8 kB (+13 B) 19 kB (+11 B)
defineCustomElement 52.1 kB (+31 B) 20.3 kB (+12 B) 18.5 kB (+7 B)
overall 63.3 kB (+31 B) 24.5 kB (+14 B) 22.2 kB (-41 B)

// #8342
// e.g. emits: { once: null } -> onOnce、ononce
// Does not require regular expression processing
key = key.toLowerCase() === 'once' ? key : key.replace(/Once$/, '')
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe this?

Suggested change
key = key.toLowerCase() === 'once' ? key : key.replace(/Once$/, '')
key = key.replace(/Once$/, '') || key

While it is less explicit, it avoids the toLowerCase() call.

@edison1105 edison1105 added 🔩 p2-edge-case ready for review This PR requires more reviews labels Aug 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔩 p2-edge-case ready for review This PR requires more reviews
Projects
Status: Needs Review
Development

Successfully merging this pull request may close these issues.

Report an error when the component event name is once
4 participants