-
-
Notifications
You must be signed in to change notification settings - Fork 33.8k
Warn when not passing props in kebab-case #5161
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
Conversation
src/core/vdom/create-component.js
Outdated
@@ -287,6 +287,17 @@ function extractProps (data: VNodeData, Ctor: Class<Component>): ?Object { | |||
if (attrs || props || domProps) { | |||
for (const key in propOptions) { | |||
const altKey = hyphenate(key) | |||
const keyInLowerCase = key.toLowerCase() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we move this inside the NODE_ENV
conditional block as well? It's ok to use two nested ifs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, updated!
* 'dev' of https://github.com/vuejs/vue: (118 commits) [weex] Support unary and left open tags (vuejs#5052) [release] 2.2.4 [build] 2.2.4 fix perf measure regression for nested components of the same name (fix vuejs#5181) [release] 2.2.3 [build] 2.2.3 perf code coverage improve camelCase prop warning message warn when template contains text outside root element (vuejs#5164) Warn when not passing props in kebab-case (vuejs#5161) turn off perf timeline measuring by default + reduce its impact on dev time perf (fix vuejs#5174) v-bind object should have lower priority than explicit bindings (fix vuejs#5150) fix custom directive arg fall through (fix vuejs#5162) formatting tweaks refactor create-component fix wrong order of generate modifier code (vuejs#5147) fix v-on unit test (vuejs#5144) fix vuejs#5121: parse content in textarea as plaintext (vuejs#5143) [release] 2.2.2 [build] 2.2.2 ... # Conflicts: # dist/vue.runtime.common.js # src/core/vdom/helpers/update-listeners.js
What release should get this on board (2.2.6 seems to don't have it)? |
@yamsellem Already released in v2.2.3 |
@CodinCat sorry 'bout that. Webpack was lower casing our html attributes ( |
If you are using single file components then it's not a problem. camelCased props will be converted to kebab-case automatically. |
What kind of change does this PR introduce? (check at least one)
Does this PR introduce a breaking change? (check one)
Hi,
Please see #5145
This patch adds a warning when user is not passing props in kebab-case mistakenly, for example:
I know this is stated on the guide, but since it's a very common mistake (based on the questions on stackoverflow (see the issue above) and the forum), I think it is worth to add a warning and I believe this will save a lot of people's debugging time and provide a more friendly development experience.
And for the performance, this is not a complex algorithm. It only adds a fews operations (both
toLowerCase
andhasOwnProperty
are fast enough) in O(n) so I would say the impact on performance is negligible (almost no impact when running unit test on my machine).thanks!