Skip to content

Commit

Permalink
Check if length's PropSignal exists before updating its value
Browse files Browse the repository at this point in the history
  • Loading branch information
DAreRodz committed Jul 31, 2024
1 parent 80cf598 commit 28d329b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/interactivity/src/proxies/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,15 @@ const stateHandlers: ProxyHandler< object > = {
objToIterable.get( target )!.value++;
}

if ( Array.isArray( target ) ) {
/*
* Modify the `length` property value only if the related
* `PropSignal` exists, which means that there are subscriptions to
* this property.
*/
if (
Array.isArray( target ) &&
proxyToProps.get( receiver )?.has( 'length' )
) {
const length = getPropSignal( receiver, 'length' );
length.setValue( target.length );
}
Expand Down

0 comments on commit 28d329b

Please sign in to comment.