mirror of
https://github.com/vuejs/vue.git
synced 2024-11-21 20:28:54 +00:00
fix(shallowReactive): should track value if already reactive when set in shallowReactive
This commit is contained in:
parent
d30f6fd25f
commit
0ad8e8d94f
@ -110,10 +110,10 @@ function initProps(vm: Component, propsOptions: Object) {
|
||||
)
|
||||
}
|
||||
},
|
||||
true
|
||||
true /* shallow */
|
||||
)
|
||||
} else {
|
||||
defineReactive(props, key, value, undefined, true)
|
||||
defineReactive(props, key, value, undefined, true /* shallow */)
|
||||
}
|
||||
// static props are already proxied on the component's prototype
|
||||
// during Vue.extend(). We only need to proxy props defined at
|
||||
|
@ -131,7 +131,8 @@ export function defineReactive(
|
||||
val?: any,
|
||||
customSetter?: Function | null,
|
||||
shallow?: boolean,
|
||||
mock?: boolean
|
||||
mock?: boolean,
|
||||
observeEvenIfShallow = false
|
||||
) {
|
||||
const dep = new Dep()
|
||||
|
||||
@ -150,7 +151,7 @@ export function defineReactive(
|
||||
val = obj[key]
|
||||
}
|
||||
|
||||
let childOb = !shallow && observe(val, false, mock)
|
||||
let childOb = shallow ? val && val.__ob__ : observe(val, false, mock)
|
||||
Object.defineProperty(obj, key, {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
@ -194,7 +195,7 @@ export function defineReactive(
|
||||
} else {
|
||||
val = newVal
|
||||
}
|
||||
childOb = !shallow && observe(newVal, false, mock)
|
||||
childOb = shallow ? newVal && newVal.__ob__ : observe(newVal, false, mock)
|
||||
if (__DEV__) {
|
||||
dep.notify({
|
||||
type: TriggerOpTypes.SET,
|
||||
|
Loading…
Reference in New Issue
Block a user