Skip to content

Commit

Permalink
fix: init store only once when no web-components
Browse files Browse the repository at this point in the history
  • Loading branch information
aralroca committed Nov 24, 2024
1 parent d59caa6 commit 1722b79
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ describe('extendStreamController', () => {
controller.transferStoreToClient();

expect(mockController.enqueue.mock.calls).toEqual([
[`<script>window._S=[["test","test"]]</script>`],
[`<script id="init-S">window._S=[["test","test"]]</script>`],
]);
});

Expand All @@ -317,7 +317,7 @@ describe('extendStreamController', () => {
controller.transferStoreToClient();

expect(mockController.enqueue.mock.calls).toEqual([
[`<script>window._S=[["test","test"]]</script>`],
[`<script id="init-S">window._S=[["test","test"]]</script>`],
]);
});

Expand Down Expand Up @@ -406,7 +406,7 @@ describe('extendStreamController', () => {
controller.transferStoreToClient();

expect(mockController.enqueue.mock.calls).toEqual([
[`<script>window._S=[["some","foo"]]</script>`],
[`<script id="init-S">window._S=[["some","foo"]]</script>`],
[`<script>for(let e of [["another","bar"]]) _S.push(e)</script>`],
]);
});
Expand All @@ -432,7 +432,7 @@ describe('extendStreamController', () => {
controller.transferStoreToClient();

expect(mockController.enqueue.mock.calls).toEqual([
[`<script>window._S=[["some","foo"]]</script>`],
[`<script id="init-S">window._S=[["some","foo"]]</script>`],
[
`<script>for(let [k, v] of [["another","bar"]]){ _s?.set?.(k, v); _S.push([k, v])}</script>`,
],
Expand Down
2 changes: 1 addition & 1 deletion packages/brisa/src/utils/extend-stream-controller/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export default function extendStreamController({
} else if (storeTransfered && !areSignalsInjected) {
script = `<script>for(let e of ${serializedStore}) _S.push(e)</script>`;
} else {
script = `<script>window._S=${serializedStore}</script>`;
script = `<script id="init-S">window._S=${serializedStore}</script>`;
}

this.enqueue(script, suspenseId);
Expand Down

0 comments on commit 1722b79

Please sign in to comment.