diff --git a/src/core/instance/state.ts b/src/core/instance/state.ts index 7ac84c6ba..f59dda13d 100644 --- a/src/core/instance/state.ts +++ b/src/core/instance/state.ts @@ -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 diff --git a/src/core/observer/index.ts b/src/core/observer/index.ts index 9988fb868..dc6efae4d 100644 --- a/src/core/observer/index.ts +++ b/src/core/observer/index.ts @@ -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,