File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -264,12 +264,14 @@ const hasOwn = Object.prototype.hasOwnProperty
264264 * If not, it will replace any deeply equal children of `b` with those of `a`.
265265 * This can be used for structural sharing between JSON values for example.
266266 */
267- export function replaceEqualDeep < T > ( a : unknown , b : T ) : T
268- export function replaceEqualDeep ( a : any , b : any ) : any {
267+ export function replaceEqualDeep < T > ( a : unknown , b : T , depth ?: number ) : T
268+ export function replaceEqualDeep ( a : any , b : any , depth = 0 ) : any {
269269 if ( a === b ) {
270270 return a
271271 }
272272
273+ if ( depth > 500 ) return b
274+
273275 const array = isPlainArray ( a ) && isPlainArray ( b )
274276
275277 if ( ! array && ! ( isPlainObject ( a ) && isPlainObject ( b ) ) ) return b
@@ -303,7 +305,7 @@ export function replaceEqualDeep(a: any, b: any): any {
303305 continue
304306 }
305307
306- const v = replaceEqualDeep ( aItem , bItem )
308+ const v = replaceEqualDeep ( aItem , bItem , depth + 1 )
307309 copy [ key ] = v
308310 if ( v === aItem ) equalItems ++
309311 }
You can’t perform that action at this time.
0 commit comments