Skip to content

fix(runtime-core): properly change v-on object keys#1358

Merged
yyx990803 merged 1 commit intovuejs:masterfrom
cathrinevaage:fix/properly-change-v-on-object-keys
Jun 15, 2020
Merged

fix(runtime-core): properly change v-on object keys#1358
yyx990803 merged 1 commit intovuejs:masterfrom
cathrinevaage:fix/properly-change-v-on-object-keys

Conversation

@cathrinevaage
Copy link
Copy Markdown
Contributor

emit('eventName') will call a prop with the name onEventName.
@eventName="eventHandler" will be compiled into the prop onEventName: event => _ctx.eventHandler(event).
Both of those are completely fine, and event handlers are called as expected.

If you opt to use v-on with an object, it will probably not work as expected.
v-on="{ eventName: eventHandler }" is compiled to prop { oneventName: eventhandler }, and will thus never be called by emit('eventName').
Currently you'll have to capitalize the event name, v-on"{ EventName: eventHandler }".
This is clunky, and it breaks with the common pattern that event names are in camelCase.

This PR fixes this by capitalizing the object keys before they're prepended with 'on'.

@yyx990803 yyx990803 merged commit 250eb4a into vuejs:master Jun 15, 2020
@cathrinevaage cathrinevaage deleted the fix/properly-change-v-on-object-keys branch June 15, 2020 21:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants