File tree 2 files changed +20
-0
lines changed
2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -86,6 +86,23 @@ describe('api: watch', () => {
86
86
expect ( dummy ) . toMatchObject ( [ 2 , 1 ] )
87
87
} )
88
88
89
+ it ( 'watching primitive with deep: true' , async ( ) => {
90
+ const count = ref ( 0 )
91
+ let dummy
92
+ watch (
93
+ count ,
94
+ ( c , prevCount ) => {
95
+ dummy = [ c , prevCount ]
96
+ } ,
97
+ {
98
+ deep : true
99
+ }
100
+ )
101
+ count . value ++
102
+ await nextTick ( )
103
+ expect ( dummy ) . toMatchObject ( [ 1 , 0 ] )
104
+ } )
105
+
89
106
it ( 'watching multiple sources' , async ( ) => {
90
107
const state = reactive ( { count : 1 } )
91
108
const count = ref ( 1 )
Original file line number Diff line number Diff line change @@ -286,6 +286,9 @@ export function instanceWatch(
286
286
287
287
function traverse ( value : unknown , seen : Set < unknown > = new Set ( ) ) {
288
288
if ( ! isObject ( value ) || seen . has ( value ) ) {
289
+ return value
290
+ }
291
+ if ( seen . has ( value ) ) {
289
292
return
290
293
}
291
294
seen . add ( value )
You can’t perform that action at this time.
0 commit comments