@@ -466,39 +466,32 @@ export function createPathGetter(ctx: any, path: string) {
466
466
467
467
export function traverse (
468
468
value : unknown ,
469
- depth ?: number ,
470
- currentDepth = 0 ,
469
+ depth = Infinity ,
471
470
seen ?: Set < unknown > ,
472
471
) {
473
- if ( ! isObject ( value ) || ( value as any ) [ ReactiveFlags . SKIP ] ) {
472
+ if ( depth <= 0 || ! isObject ( value ) || ( value as any ) [ ReactiveFlags . SKIP ] ) {
474
473
return value
475
474
}
476
475
477
- if ( depth && depth > 0 ) {
478
- if ( currentDepth >= depth ) {
479
- return value
480
- }
481
- currentDepth ++
482
- }
483
-
484
476
seen = seen || new Set ( )
485
477
if ( seen . has ( value ) ) {
486
478
return value
487
479
}
488
480
seen . add ( value )
481
+ depth --
489
482
if ( isRef ( value ) ) {
490
- traverse ( value . value , depth , currentDepth , seen )
483
+ traverse ( value . value , depth , seen )
491
484
} else if ( isArray ( value ) ) {
492
485
for ( let i = 0 ; i < value . length ; i ++ ) {
493
- traverse ( value [ i ] , depth , currentDepth , seen )
486
+ traverse ( value [ i ] , depth , seen )
494
487
}
495
488
} else if ( isSet ( value ) || isMap ( value ) ) {
496
489
value . forEach ( ( v : any ) => {
497
- traverse ( v , depth , currentDepth , seen )
490
+ traverse ( v , depth , seen )
498
491
} )
499
492
} else if ( isPlainObject ( value ) ) {
500
493
for ( const key in value ) {
501
- traverse ( value [ key ] , depth , currentDepth , seen )
494
+ traverse ( value [ key ] , depth , seen )
502
495
}
503
496
}
504
497
return value
0 commit comments