From dd2f22d75bac9aa065f6828d31b3608ff68930ae Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Wed, 11 Mar 2026 10:24:37 -0400 Subject: [PATCH] fix, tidy up --- packages/svelte/src/reactivity/set.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/svelte/src/reactivity/set.js b/packages/svelte/src/reactivity/set.js index 0ce3f38d43..9b5889872e 100644 --- a/packages/svelte/src/reactivity/set.js +++ b/packages/svelte/src/reactivity/set.js @@ -1,8 +1,8 @@ /** @import { Source } from '#client' */ import { DEV } from 'esm-env'; -import { source, set, state, increment } from '../internal/client/reactivity/sources.js'; +import { source, set, state } from '../internal/client/reactivity/sources.js'; import { label, tag } from '../internal/client/dev/tracing.js'; -import { active_effect, active_reaction, get, untrack, update_version } from '../internal/client/runtime.js'; +import { get, update_version } from '../internal/client/runtime.js'; import { async_mode_flag } from '../internal/flags/index.js'; var read_methods = ['forEach', 'isDisjointFrom', 'isSubsetOf', 'isSupersetOf']; @@ -138,13 +138,6 @@ export class SvelteSet extends Set { /** @param {T} value */ add(value) { - if (!get(this.#items).has(value)) { - const clone = new Set(get(this.#items)); - clone.add(value); - - set(this.#items, clone); - } - var sources = this.#sources; var s = sources.get(value); @@ -154,6 +147,13 @@ export class SvelteSet extends Set { sources.set(value, this.#source(true)); } + if (!get(this.#items).has(value)) { + const clone = new Set(get(this.#items)); + clone.add(value); + + set(this.#items, clone); + } + return this; }