Skip to content

Commit

Permalink
Prevent passing the state proxy as receiver
Browse files Browse the repository at this point in the history
  • Loading branch information
DAreRodz committed Feb 22, 2024
1 parent 3b338cc commit 648bd46
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/interactivity/src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,13 @@ const handlers = {
}
}

const result = Reflect.get( target, key, receiver );
const result = Reflect.get( target, key );

// Check if the proxy is the store root and no key with that name exist. In
// that case, return an empty object for the requested key.
if ( typeof result === 'undefined' && receiver === stores.get( ns ) ) {
const obj = {};
Reflect.set( target, key, obj, receiver );
Reflect.set( target, key, obj );
return proxify( obj, ns );
}

Expand Down Expand Up @@ -149,6 +149,9 @@ const handlers = {

return result;
},
set( target: any, key: string, value: any ) {
return Reflect.set( target, key, value );
},
};

/**
Expand Down

0 comments on commit 648bd46

Please sign in to comment.