Skip to content

Commit

Permalink
fix: ensure SvelteMap and SvelteSet work with generators in dev (#14103)
Browse files Browse the repository at this point in the history
* fix: ensure SvelteMap and SvelteSet work with generators in dev

* add test

* better fix

* better fix

* better fix

* better fix
  • Loading branch information
trueadm authored Nov 1, 2024
1 parent 535ea44 commit 9883e70
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/selfish-chicken-argue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: ensure SvelteMap and SvelteSet work with generators in dev
2 changes: 1 addition & 1 deletion packages/svelte/src/reactivity/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class SvelteMap extends Map {
super();

// If the value is invalid then the native exception will fire here
if (DEV) new Map(value);
if (DEV) value = new Map(value);

if (value) {
for (var [key, v] of value) {
Expand Down
2 changes: 1 addition & 1 deletion packages/svelte/src/reactivity/set.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class SvelteSet extends Set {
super();

// If the value is invalid then the native exception will fire here
if (DEV) new Set(value);
if (DEV) value = new Set(value);

if (value) {
for (var element of value) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { test } from '../../test';

export default test({
compileOptions: {
dev: true
},

html: `1`
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<script>
import { SvelteSet } from 'svelte/reactivity';
function *generator() {
yield 1;
}
let gen = new SvelteSet(generator());
</script>

{#each gen as item}
{item}
{/each}

0 comments on commit 9883e70

Please sign in to comment.