-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
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
Adds handler for kebab-case event for v-bind:sync; fix #6428 #8297
Conversation
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.
Thanks for tackling this @shortdiv!
@yyx990803 Is there anything more that should be done on this? Being able to universally recommend kebab-case event names will simplify a couple sections of the docs and allow us to add this rule to the ESLint plugin. 🙂 |
src/compiler/parser/index.js
Outdated
syncGen = genAssignmentCode(value, `$event`) | ||
addHandler( | ||
el, | ||
`update:${kebabize(name)}`, |
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.
The hyphenate
function might be a better fit here.
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.
Good point! 🙂 I forgot that one existed. @shortdiv, can you update to use hyphenate
instead?
src/shared/util.js
Outdated
export const kebabize = cached((str: string): string => { | ||
return str.replace(kebabizeRE, (m, p1, p2) => `${p1}-${p2}`).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.
Since we're no longer using this, can you delete it please?
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.
You got it!
// TODO revert changes in #8845 that will become unnecessary after merging this |
Thinking about this a little more, I wonder if |
@chrisvfritz that would significantly bloat the compiled output, not sure if it's worth it, especially when this is not an issue when using string templates. |
What kind of change does this PR introduce? (check at least one)
Does this PR introduce a breaking change? (check one)
If yes, please describe the impact and migration path for existing applications:
The PR fulfills these requirements:
dev
branch for v2.x (or to a previous version branch), not themaster
branchfix #xxx[,#xxx]
, where "xxx" is the issue number)Other information:
Addresses #6428 and vuejs/v2.vuejs.org#1648