@@ -378,43 +378,36 @@ function doWatch(
378
378
379
379
function traverse (
380
380
value : unknown ,
381
- depth ?: number ,
382
- currentDepth = 0 ,
381
+ depth = Number . POSITIVE_INFINITY ,
383
382
seen ?: Set < unknown > ,
384
383
) : unknown {
385
- if ( ! isObject ( value ) || ( value as any ) [ ReactiveFlags . SKIP ] ) {
384
+ if ( depth <= 0 || ! isObject ( value ) || ( value as any ) [ ReactiveFlags . SKIP ] ) {
386
385
return value
387
386
}
388
387
389
- if ( depth && depth > 0 ) {
390
- if ( currentDepth >= depth ) {
391
- return value
392
- }
393
-
394
- currentDepth ++
395
- }
396
-
397
388
seen = seen || new Set ( )
398
389
if ( seen . has ( value ) ) {
399
390
return value
400
391
}
401
392
402
393
seen . add ( value )
394
+ depth --
395
+
403
396
/* istanbul ignore else -- @preserve */
404
397
if ( isRef ( value ) ) {
405
- traverse ( value . value , depth , currentDepth , seen )
398
+ traverse ( value . value , depth , seen )
406
399
} else if ( isArray ( value ) ) {
407
400
for ( let i = 0 ; i < value . length ; i ++ ) {
408
- traverse ( value [ i ] , depth , currentDepth , seen )
401
+ traverse ( value [ i ] , depth , seen )
409
402
}
410
403
} else if ( isSet ( value ) || isMap ( value ) ) {
411
404
value . forEach ( ( v : any ) => {
412
- traverse ( v , depth , currentDepth , seen )
405
+ traverse ( v , depth , seen )
413
406
} )
414
407
} else if ( isPlainObject ( value ) ) {
415
408
// eslint-disable-next-line guard-for-in
416
409
for ( const key in value ) {
417
- traverse ( value [ key ] , depth , currentDepth , seen )
410
+ traverse ( value [ key ] , depth , seen )
418
411
}
419
412
}
420
413
0 commit comments