Skip to content
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

fix(runtime-core): use camelized prop key to check if it is absent #12034

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

Conversation

yangliguo7
Copy link

fix #12011

@yangliguo7
Copy link
Author

I can't modify the regex hyphenateRE because I can't evaluate whether changes to the regex will have other effects.

Copy link

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 101 kB 38 kB 34.2 kB
vue.global.prod.js 160 kB 58 kB 51.5 kB

Usages

Name Size Gzip Brotli
createApp (CAPI only) 49 kB 18.9 kB 17.2 kB
createApp 55.6 kB 21.4 kB 19.6 kB
createSSRApp 59.6 kB 23.1 kB 21 kB
defineCustomElement 60.4 kB 22.9 kB 20.9 kB
overall 69.3 kB 26.5 kB 24 kB

Copy link

pkg-pr-new bot commented Sep 26, 2024

Open in Stackblitz

@vue/compiler-core

pnpm add https://pkg.pr.new/@vue/compiler-core@12034

@vue/compiler-dom

pnpm add https://pkg.pr.new/@vue/compiler-dom@12034

@vue/compiler-sfc

pnpm add https://pkg.pr.new/@vue/compiler-sfc@12034

@vue/compiler-ssr

pnpm add https://pkg.pr.new/@vue/compiler-ssr@12034

@vue/reactivity

pnpm add https://pkg.pr.new/@vue/reactivity@12034

@vue/runtime-core

pnpm add https://pkg.pr.new/@vue/runtime-core@12034

@vue/runtime-dom

pnpm add https://pkg.pr.new/@vue/runtime-dom@12034

@vue/server-renderer

pnpm add https://pkg.pr.new/@vue/server-renderer@12034

@vue/shared

pnpm add https://pkg.pr.new/@vue/shared@12034

@vue/compat

pnpm add https://pkg.pr.new/@vue/compat@12034

vue

pnpm add https://pkg.pr.new/vue@12034

commit: d613766

@@ -662,7 +663,7 @@ function validateProps(
resolvedValues[key],
opt,
__DEV__ ? shallowReadonly(resolvedValues) : resolvedValues,
!hasOwn(rawProps, key) && !hasOwn(rawProps, hyphenate(key)),
!hasOwn(rawProps, key) && !camelizePropsKey.includes(key),
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
!hasOwn(rawProps, key) && !camelizePropsKey.includes(key),
!camelizePropsKey.includes(key),

!hasOwn(rawProps, key) seems no longer needed due to the prop key is always camelized.

Copy link
Author

Choose a reason for hiding this comment

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

You're right, I'm writing this because I'm not sure if the performance of includes will be worse than hasOwn, so I only do the following operations when hasOwn (rawProps, key) is not met

Copy link
Author

Choose a reason for hiding this comment

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

So do you think I should remove the previous judgment

Copy link
Member

Choose a reason for hiding this comment

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

I think it is fine because this check only happens in DEV.

Copy link
Author

Choose a reason for hiding this comment

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

ok. I'll fix it

Copy link
Author

Choose a reason for hiding this comment

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

@edison1105 edison1105 changed the title fix(runtime-core): replace camelize with hyphenate to handle props key fix(runtime-core): use camelized prop key to check if it is absent Sep 26, 2024
@edison1105 edison1105 added ready to merge The PR is ready to be merged. 🍰 p2-nice-to-have Priority 2: this is not breaking anything but nice to have it addressed. labels Sep 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍰 p2-nice-to-have Priority 2: this is not breaking anything but nice to have it addressed. ready to merge The PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

False positive missing required prop due to the hyphanate function
2 participants