Skip to content

Commit bed73ac

Browse files
committed
tidy
1 parent 891b54f commit bed73ac

File tree

3 files changed

+11
-22
lines changed

3 files changed

+11
-22
lines changed

packages/svelte/src/internal/client/reactivity/batch.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -607,24 +607,19 @@ function flush_queued_effects(effects) {
607607
/** @type {Effect[]} */
608608
const filtered_effects = [];
609609

610-
for (const e of eager_block_effects) {
610+
outer: for (const e of eager_block_effects) {
611611
// Skip eager effects that have already been unmounted
612612
if ((e.f & (DESTROYED | INERT)) !== 0) continue;
613613

614614
// Skip effects that have related parent effects in the current flush,
615615
// as the inner ones will be run if its parent triggers it (eg. in a guard).
616-
let skip = false;
617616
let ancestor = e.parent;
618-
while (!skip && ancestor !== null) {
617+
while (ancestor !== null) {
619618
if (eager_block_effects.has(ancestor)) {
620-
skip = true;
621-
break;
619+
continue outer;
622620
}
623621
ancestor = ancestor.parent;
624622
}
625-
if (skip) {
626-
continue;
627-
}
628623

629624
filtered_effects.push(e);
630625
}

packages/svelte/tests/runtime-runes/samples/guard-else-effect/main.svelte

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,16 @@
11
<script lang="ts">
2-
import {untrack} from 'svelte';
3-
4-
const {trackBranch}:{trackBranch: (branch:string)=>void} = $props();
2+
const { trackBranch }:{ trackBranch: (branch:string)=>void } = $props();
53
64
let b = $state(false);
75
let v = $state("two");
86
9-
107
$effect(() => {
118
v = b ? "one" : "two";
129
})
1310
</script>
1411

15-
1612
<button onclick={() => b = !b}>Trigger</button>
1713

18-
1914
{#if v === "one"}
2015
<div>if1 matched! {trackBranch('one')}</div>
2116
{:else if v === "two"}
Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
<script>
2-
let centerRow = $state({ nested: { optional: 2, required: 3 } },
3-
);
2+
let centerRow = $state({ nested: { optional: 2, required: 3 } });
43
54
let someChange = $state(false);
65
$effect(() => {
76
if (someChange) centerRow = undefined;
87
});
98
</script>
109

11-
{#if centerRow?.nested}
12-
{#if centerRow?.nested?.optional != undefined && centerRow.nested.optional > 0}
13-
op: {centerRow.nested.optional}<br />
14-
{:else}
15-
req: {centerRow.nested.required}<br />
16-
{/if}
10+
{#if centerRow?.nested}
11+
{#if centerRow?.nested?.optional != undefined && centerRow.nested.optional > 0}
12+
op: {centerRow.nested.optional}<br />
13+
{:else}
14+
req: {centerRow.nested.required}<br />
1715
{/if}
16+
{/if}
1817

1918
<button onclick={() => (someChange = true)}>Trigger</button>

0 commit comments

Comments
 (0)