Skip to content

Commit

Permalink
chore(compat): remove this.$set usage in vue3 version of cache
Browse files Browse the repository at this point in the history
  • Loading branch information
xanf committed Jan 28, 2022
1 parent f0a31a4 commit 3808529
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/utils/cache.js
@@ -1,4 +1,4 @@
import { Vue } from '../vue'
import { Vue, isVue3 } from '../vue'
import { cloneDeep } from './clone-deep'
import { looseEqual } from './loose-equal'
import { hasOwnProperty, keys } from './object'
Expand All @@ -16,11 +16,19 @@ export const makePropWatcher = propName => ({
}
for (const key in oldValue) {
if (!hasOwnProperty(newValue, key)) {
this.$delete(this.$data[propName], key)
if (isVue3) {
delete this.$data[propName][key]
} else {
this.$delete(this.$data[propName], key)
}
}
}
for (const key in newValue) {
this.$set(this.$data[propName], key, newValue[key])
if (isVue3) {
this.$data[propName][key] = newValue[key]
} else {
this.$set(this.$data[propName], key, newValue[key])
}
}
}
})
Expand Down

0 comments on commit 3808529

Please sign in to comment.