-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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(reactivity): fix track hasOwnProperty
#2621
Conversation
Correct me if I'm wrong but doesn't this fix assume that If someone did something equivalent to this: Object.prototype.hasOwnProperty.call(obj, 'a') then the reactivity still wouldn't be tracked? While it's unlikely that someone would do that directly in a template, it's pretty common for libraries to do something like this internally (like Vue's |
This will not be tracked and I am not sure that this PR is the best solution. |
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 you add a test?
Done. |
According to these specs:
In step 3 function getOwnPropertyDescriptor(target: object, key: string | number | symbol) {
track(target, TrackOpTypes.GET, key)
return Reflect.getOwnPropertyDescriptor(target, key)
} This makes Edit: Did some research, some basic semantics, such as |
@HcySunYang Do I read your last comment correctly: Are we stuck here? |
Except for the solution given by this PR, I can't think of a better way. |
Removing my change request as this need some guidance from Evan I think
❌ Deploy Preview for vuejs-coverage failed.
|
I noticed this fix is not granular: i.e. it would trigger even when unrelated keys are added or deleted. More precise tracking can be achieved by returning an instrumented version of |
Avoid circular referencing the `hasOwnProperty` method in reactive proxy. > vuejs/core#2621 (comment) > More precise tracking can be achieved by returning an instrumented > version of `hasOwnProperty` on reactive objects, as implemented in > vuejs/core@588bd44
Avoid circular referencing the `hasOwnProperty` method in reactive proxy. > vuejs/core#2621 (comment) > More precise tracking can be achieved by returning an instrumented > version of `hasOwnProperty` on reactive objects, as implemented in > vuejs/core@588bd44
close #2619