File tree 3 files changed +47
-1
lines changed
3 files changed +47
-1
lines changed Original file line number Diff line number Diff line change @@ -190,7 +190,7 @@ export function mixin(Vue: VueConstructor) {
190
190
return true
191
191
}
192
192
193
- if ( ! isPlainObject ( target ) || isRaw ( target ) ) {
193
+ if ( ! isPlainObject ( target ) || isRaw ( target ) || isRef ( target ) ) {
194
194
return false
195
195
}
196
196
return Object . keys ( target ) . some ( ( x ) =>
Original file line number Diff line number Diff line change @@ -1219,4 +1219,27 @@ describe('setup', () => {
1219
1219
} ,
1220
1220
} ) . $mount ( )
1221
1221
} )
1222
+
1223
+ // #794
1224
+ it ( 'should not trigger getter w/ object computed nested' , ( ) => {
1225
+ const spy = jest . fn ( )
1226
+ new Vue ( {
1227
+ setup ( ) {
1228
+ new Vue ( {
1229
+ setup ( ) {
1230
+ const person = {
1231
+ name : computed ( ( ) => {
1232
+ spy ( )
1233
+ return 1
1234
+ } ) ,
1235
+ }
1236
+ return {
1237
+ person,
1238
+ }
1239
+ } ,
1240
+ } )
1241
+ } ,
1242
+ } )
1243
+ expect ( spy ) . toHaveBeenCalledTimes ( 0 )
1244
+ } )
1222
1245
} )
Original file line number Diff line number Diff line change 3
3
defineComponent ,
4
4
createApp ,
5
5
ref ,
6
+ computed ,
6
7
nextTick ,
7
8
SetupContext ,
8
9
getCurrentInstance ,
@@ -225,4 +226,26 @@ describe('setupContext', () => {
225
226
`"RangeError: Maximum call stack size exceeded"`
226
227
) . not . toHaveBeenWarned ( )
227
228
} )
229
+
230
+ // #794
231
+ it ( 'should not trigger getter w/ object computed nested' , async ( ) => {
232
+ const spy = jest . fn ( )
233
+ createApp (
234
+ defineComponent ( {
235
+ template : `<div/>` ,
236
+ setup ( ) {
237
+ const person = {
238
+ name : computed < number > ( ( ) => {
239
+ spy ( )
240
+ return 1
241
+ } ) ,
242
+ }
243
+ return {
244
+ person,
245
+ }
246
+ } ,
247
+ } )
248
+ ) . mount ( )
249
+ expect ( spy ) . toHaveBeenCalledTimes ( 0 )
250
+ } )
228
251
} )
You can’t perform that action at this time.
0 commit comments