Skip to content

Commit 278873c

Browse files
committed
better fix
1 parent 0159b11 commit 278873c

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

packages/svelte/src/reactivity/map.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/** @import { Source } from '#client' */
2+
import { DEV } from 'esm-env';
23
import { set, source } from '../internal/client/reactivity/sources.js';
34
import { get } from '../internal/client/runtime.js';
45
import { increment } from './utils.js';
@@ -20,6 +21,9 @@ export class SvelteMap extends Map {
2021
constructor(value) {
2122
super();
2223

24+
// If the value is invalid then the native exception will fire here
25+
if (DEV) value = new Map(value);
26+
2327
if (value) {
2428
for (var [key, v] of value) {
2529
super.set(key, v);

packages/svelte/src/reactivity/set.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/** @import { Source } from '#client' */
2+
import { DEV } from 'esm-env';
23
import { source, set } from '../internal/client/reactivity/sources.js';
34
import { get } from '../internal/client/runtime.js';
45
import { increment } from './utils.js';
@@ -24,6 +25,10 @@ export class SvelteSet extends Set {
2425
constructor(value) {
2526
super();
2627

28+
// If the value is invalid then the native exception will fire here
29+
// @ts-ignore
30+
if (DEV) value = new Set(Array.from(value));
31+
2732
if (value) {
2833
for (let element of value) {
2934
super.add(element);

0 commit comments

Comments
 (0)