File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed
Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -86,6 +86,23 @@ describe('api: watch', () => {
8686 expect ( dummy ) . toMatchObject ( [ 2 , 1 ] )
8787 } )
8888
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+
89106 it ( 'watching multiple sources' , async ( ) => {
90107 const state = reactive ( { count : 1 } )
91108 const count = ref ( 1 )
Original file line number Diff line number Diff line change @@ -286,6 +286,9 @@ export function instanceWatch(
286286
287287function traverse ( value : unknown , seen : Set < unknown > = new Set ( ) ) {
288288 if ( ! isObject ( value ) || seen . has ( value ) ) {
289+ return value
290+ }
291+ if ( seen . has ( value ) ) {
289292 return
290293 }
291294 seen . add ( value )
You can’t perform that action at this time.
0 commit comments