Skip to content

Commit

Permalink
Move iterable signal updating outside for...in loop
Browse files Browse the repository at this point in the history
  • Loading branch information
DAreRodz committed Sep 9, 2024
1 parent 7b7e0cf commit d516c42
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions packages/interactivity/src/proxies/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,11 @@ const deepMergeRecursive = (
override: boolean = true
) => {
if ( isPlainObject( target ) && isPlainObject( source ) ) {
let hasNewKeys = false;
for ( const key in source ) {
const isNew = ! ( key in target );
hasNewKeys = hasNewKeys || isNew;

const desc = Object.getOwnPropertyDescriptor( source, key );
if (
typeof desc?.get === 'function' ||
Expand Down Expand Up @@ -311,10 +314,10 @@ const deepMergeRecursive = (
propSignal.setValue( desc.value );
}
}
}

if ( isNew && objToIterable.has( target ) ) {
objToIterable.get( target )!.value++;
}
if ( hasNewKeys && objToIterable.has( target ) ) {
objToIterable.get( target )!.value++;
}
}
};
Expand Down

0 comments on commit d516c42

Please sign in to comment.