Skip to content

Commit ca11ebd

Browse files
committed
fix
1 parent ce34c76 commit ca11ebd

File tree

1 file changed

+9
-5
lines changed
  • packages/svelte/src/internal/client/dom/blocks

1 file changed

+9
-5
lines changed

packages/svelte/src/internal/client/dom/blocks/if.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,12 @@ export function if_block(node, fn, elseif = false) {
5858
offscreen_fragment = null;
5959
}
6060

61-
if (condition) {
62-
consequent_effect = pending_effect;
63-
} else {
64-
alternate_effect = pending_effect;
61+
if (pending_effect) {
62+
if (condition) {
63+
consequent_effect = pending_effect;
64+
} else {
65+
alternate_effect = pending_effect;
66+
}
6567
}
6668

6769
var current_effect = condition ? consequent_effect : alternate_effect;
@@ -114,7 +116,9 @@ export function if_block(node, fn, elseif = false) {
114116
offscreen_fragment.append((target = document.createComment('')));
115117
}
116118

117-
pending_effect = fn && branch(() => fn(target));
119+
if (condition ? !consequent_effect : !alternate_effect) {
120+
pending_effect = fn && branch(() => fn(target));
121+
}
118122

119123
if (suspended) {
120124
add_boundary_callback(boundary, commit);

0 commit comments

Comments
 (0)