-
-
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
fix #4041, warn overriding Vue's internal methods #4111
Conversation
`method "${key}" has an undefined value in the component definition. ` + | ||
`Did you reference the function correctly?`, | ||
vm | ||
) | ||
hasOwn(BuiltinVue.prototype, key) && warn( | ||
`You're overriding Vue's internal method "${key}". ` + | ||
`Beware of misbehaviors.`, |
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.
Let rephrase this to "Avoid overriding Vue's internaml method ..." and can remove the second line.
@yyx990803 As discussed on Slack, this commit only solves half of the problem, as it doesn't cover the properties, which can be more tricky. |
`method "${key}" has an undefined value in the component definition. ` + | ||
`Did you reference the function correctly?`, | ||
vm | ||
) | ||
hasOwn(BuiltinVue.prototype, key) && warn( |
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't we just use vm
instead of importing Vue 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.
Hi, I also considered that approach when coding this. But if we use vm
or vm.constructor.prototype
, it will break constructor style instance because $emit
or so isn't their own properties.
Doesn't a simple On Saturday, November 5, 2016, (´・ω・`) [email protected] wrote:
|
I'm sorry that this change introduced more problems than it resolved. I have reconsidered this. We want to only warn against overriding built-in method. And using
@phanan Could you tell me the tricky part of properties? I'm not on slack. |
@HerringtonDarkholme: @yyx990803 should have a better answer because he knows best about the framework's internal obviously, but from what I can tell, not all properties have been registered by the time methods are collected (examples are |
Yes, I just tried to fix this again and found warning is particularly tricky thing. More importantly, a |
I'll just revert this for now - I think this is a very rare case anyway. Or, we can simply change it to warn against any method that starts with |
Agreed. This "improvement" has only been costing us time with no particular benefits to start with :) |
No description provided.