-
-
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
Vue.set Api strange behavior if path is a numerical string #5884
Comments
I think maybe there should be an improvement, as we could access and assign array item via string type index. In fact, We could check the key, and try to convert it to a number type. vue/src/core/observer/index.js Line 192 in 1648adb
|
Probably just check if the string is an integer because it has to be an index. |
Thanks @Peter-WF |
Version
2.3.4
Reproduction link
https://jsfiddle.net/v0dbnvv0/1/
Steps to reproduce
Vue.set(array, "indexInTheArrayInString", value) is not working as expected compare to Vue.set(array, "indexInTheArrayInNumericForm", value)
What is expected?
Both version working the same i suppose?
What is actually happening?
Watcher on the value are not triggered even if the value is correctly changed in the model
My currently fixed in my code:
export function AdvVueSet(obj, path, value) {
if (!isNaN(path)) {
path = +path;
}
Vue.set(obj, path, value);
}
The text was updated successfully, but these errors were encountered: