Skip to content

Commit 862270f

Browse files
committed
fix test
1 parent 551b006 commit 862270f

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

packages/svelte/src/store/shared/index.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
import { noop, run_all } from '../../internal/shared/utils.js';
44
import { safe_not_equal } from '../../internal/client/reactivity/equality.js';
55
import { subscribe_to_store } from '../utils.js';
6-
import { queue_micro_task } from '../../internal/client/dom/task.js';
7-
import { active_effect } from '../../internal/client/runtime.js';
86

97
/**
108
* @type {Array<SubscribeInvalidateTuple<any> | any>}
@@ -170,11 +168,7 @@ export function derived(stores, fn, initial_value) {
170168
)
171169
);
172170
started = true;
173-
if (active_effect === null) {
174-
sync();
175-
} else {
176-
queue_micro_task(sync);
177-
}
171+
sync()
178172
return function stop() {
179173
run_all(unsubscribers);
180174
cleanup();

packages/svelte/tests/runtime-runes/samples/side-effect-template/main.svelte

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,7 @@
33
</script>
44

55
<button onclick={() => items.push(3, 2, 1)}>Add</button>
6-
{JSON.stringify(items.sort())}
6+
{#each items.sort() as item (item)}
7+
<p>{item}</p>
8+
{/each}
79

packages/svelte/tests/runtime-runes/samples/store-unsubscribe-not-referenced-after/main.svelte

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<script>
2+
import { untrack } from "svelte";
23
import { writable, derived } from "svelte/store";
34
45
const obj = writable({ a: 1 });
@@ -7,7 +8,9 @@
78
89
function watch (prop) {
910
return derived(obj, (o) => {
10-
count++;
11+
untrack(() => {
12+
count++;
13+
});
1114
return o[prop];
1215
});
1316
}

0 commit comments

Comments
 (0)