Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
/vuePublic

Commit0ad8e8d

Browse files
committed
fix(shallowReactive): should track value if already reactive when set in shallowReactive
1 parentd30f6fd commit0ad8e8d

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

‎src/core/instance/state.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,10 @@ function initProps(vm: Component, propsOptions: Object) {
110110
)
111111
}
112112
},
113-
true
113+
true/* shallow */
114114
)
115115
}else{
116-
defineReactive(props,key,value,undefined,true)
116+
defineReactive(props,key,value,undefined,true/* shallow */)
117117
}
118118
// static props are already proxied on the component's prototype
119119
// during Vue.extend(). We only need to proxy props defined at

‎src/core/observer/index.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@ export function defineReactive(
131131
val?:any,
132132
customSetter?:Function|null,
133133
shallow?:boolean,
134-
mock?:boolean
134+
mock?:boolean,
135+
observeEvenIfShallow=false
135136
){
136137
constdep=newDep()
137138

@@ -150,7 +151,7 @@ export function defineReactive(
150151
val=obj[key]
151152
}
152153

153-
letchildOb=!shallow&&observe(val,false,mock)
154+
letchildOb=shallow?val&&val.__ob__ :observe(val,false,mock)
154155
Object.defineProperty(obj,key,{
155156
enumerable:true,
156157
configurable:true,
@@ -194,7 +195,7 @@ export function defineReactive(
194195
}else{
195196
val=newVal
196197
}
197-
childOb=!shallow&&observe(newVal,false,mock)
198+
childOb=shallow?newVal&&newVal.__ob__ :observe(newVal,false,mock)
198199
if(__DEV__){
199200
dep.notify({
200201
type:TriggerOpTypes.SET,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp