-
-
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
v-bind.sync
listens for camelCase event
#6428
Comments
Unfortunately, that would be a breaking change, because there are probably a lot of component packages that expose .sync props and were compiled with vue-loader. So using those packages with a new version of Vue that contains this changer would break those packages - they would emit |
I agree with @LinusBorg , we should revisit this for v3 |
I personally find it more consistent to reference all props in camelCase in JavaScript. But as said, this cannot be changed in v2 because it's going to be breaking. |
Please do revisit this issue for v3, as I think listening to such camel case events in DOM templates is impossible (as talked about here: #2669), and I wish I could be more consistent with my components by default: auto-complete(v-model="movie" :text-value.sync="movieText"
@update:textValue="updateMovies" :item-text="({ title }) => title") I "solved" the problem by implementing a helper function which issues events on both versions: vue.prototype.$emitCase = function (name, ...args) {
const camelCaseName = name.toLowerCase().replace(/-(.)/g,
(_, g) => g.toUpperCase())
this.$emit(name, ...args)
this.$emit(camelCaseName, ...args)
} Edit: It seems like Vue 2.3+ has introduced |
You definitely should add a note about that in the documentation. Today I spent half an hour trying to figure out why my The problem is that the documentation on Custom Events: Event Names states:
So it's not always: more like always unless you emit event for Also in the documentation Custom Events: |
Good suggestions to put in an issue in the vuejs.org repository. Here they will go unnoticed, the issue is old and closed. |
Done: #8244 :). |
The current behaviour goes directly against the docs, so it is a bug if you ask me. See the @shortdiv made a PR that could be released as 2.5.17. We're running into this bug with a large client. It would be great if we could remove these custom event patches before we go to production. |
What problem does this feature solve?
This markup:
Currently compiles to:
I've always written event handlers in kebab-case. It surprised me that the compiler created an event handler which is in camelCase.
What does the proposed API look like?
The compiler should output
.sync
event handlers in camelCase:The text was updated successfully, but these errors were encountered: