File tree Expand file tree Collapse file tree 1 file changed +19
-13
lines changed Expand file tree Collapse file tree 1 file changed +19
-13
lines changed Original file line number Diff line number Diff line change @@ -217,9 +217,8 @@ export function replaceEqualDeep<T>(prev: any, _next: T): T {
217
217
const next = _next as any
218
218
219
219
const array = isPlainArray ( prev ) && isPlainArray ( next )
220
- const object = ! array && isPlainObject ( prev ) && isPlainObject ( next )
221
220
222
- if ( ! array && ! object ) return next
221
+ if ( ! array && ! ( isPlainObject ( prev ) && isPlainObject ( next ) ) ) return next
223
222
224
223
const prevItems = array ? prev : getEnumerableOwnKeys ( prev )
225
224
if ( ! prevItems ) return next
@@ -234,20 +233,27 @@ export function replaceEqualDeep<T>(prev: any, _next: T): T {
234
233
for ( let i = 0 ; i < nextSize ; i ++ ) {
235
234
const key = array ? i : ( nextItems [ i ] as any )
236
235
const p = prev [ key ]
236
+ const n = next [ key ]
237
+
238
+ if ( p === n ) {
239
+ copy [ key ] = p
240
+ if ( array ? i < prevSize : prev . hasOwnProperty ( key ) ) equalItems ++
241
+ continue
242
+ }
243
+
237
244
if (
238
- ( array || prev . hasOwnProperty ( key ) ) &&
239
- p === undefined &&
240
- next [ key ] === undefined
245
+ p === null ||
246
+ n === null ||
247
+ typeof p !== 'object' ||
248
+ typeof n !== 'object'
241
249
) {
242
- copy [ key ] = undefined
243
- equalItems ++
244
- } else {
245
- const value = replaceEqualDeep ( p , next [ key ] )
246
- copy [ key ] = value
247
- if ( value === p && p !== undefined ) {
248
- equalItems ++
249
- }
250
+ copy [ key ] = n
251
+ continue
250
252
}
253
+
254
+ const v = replaceEqualDeep ( p , n )
255
+ copy [ key ] = v
256
+ if ( v === p ) equalItems ++
251
257
}
252
258
253
259
return prevSize === nextSize && equalItems === prevSize ? prev : copy
You can’t perform that action at this time.
0 commit comments