Skip to content

Commit

Permalink
fix delete store property
Browse files Browse the repository at this point in the history
  • Loading branch information
Varixo committed Sep 17, 2024
1 parent 7600594 commit 98e9e08
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/qwik/src/core/v2/signal/v2-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ export class StoreHandler implements ProxyHandler<TargetType> {
if (typeof prop != 'string' || !delete target[prop]) {
return false;
}
triggerEffects(this.$container$, this, getEffects(target, prop, this.$effects$));
return true;
}

Expand Down
24 changes: 24 additions & 0 deletions packages/qwik/src/core/v2/tests/use-store.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,30 @@ describe.each([
expect((global as any).logs).toEqual([false, true]);
});

it('should trigger effects on property delete', async () => {
const Cmp = component$(() => {
const store = useStore<{ delete?: string }>({ delete: 'test' });
return <div onClick$={() => delete store.delete}>{store.delete}</div>;
});

const { vNode, document } = await render(<Cmp />, { debug });
expect(vNode).toMatchVDOM(
<Component>
<div>
<Signal>{'test'}</Signal>
</div>
</Component>
);
await trigger(document.body, 'div', 'click');
expect(vNode).toMatchVDOM(
<Component>
<div>
<Signal></Signal>
</div>
</Component>
);
});

describe('regression', () => {
it('#5597 - should update value', async () => {
(globalThis as any).clicks = 0;
Expand Down

0 comments on commit 98e9e08

Please sign in to comment.