Skip to content

Commit f41556c

Browse files
committed
oops
1 parent 57f50eb commit f41556c

File tree

2 files changed

+45
-42
lines changed

2 files changed

+45
-42
lines changed

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

Lines changed: 42 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -28,53 +28,56 @@ export function if_block(
2828
/** @type {boolean | null} */
2929
let condition = null;
3030

31-
block(() => {
32-
if (condition === (condition = !!get_condition())) return;
31+
block(
32+
() => {
33+
if (condition === (condition = !!get_condition())) return;
3334

34-
/** Whether or not there was a hydration mismatch. Needs to be a `let` or else it isn't treeshaken out */
35-
let mismatch = false;
35+
/** Whether or not there was a hydration mismatch. Needs to be a `let` or else it isn't treeshaken out */
36+
let mismatch = false;
3637

37-
if (hydrating) {
38-
const is_else = anchor.data === HYDRATION_END_ELSE;
38+
if (hydrating) {
39+
const is_else = anchor.data === HYDRATION_END_ELSE;
3940

40-
if (condition === is_else) {
41-
// Hydration mismatch: remove everything inside the anchor and start fresh.
42-
// This could happen with `{#if browser}...{/if}`, for example
43-
remove(hydrate_nodes);
44-
set_hydrating(false);
45-
mismatch = true;
41+
if (condition === is_else) {
42+
// Hydration mismatch: remove everything inside the anchor and start fresh.
43+
// This could happen with `{#if browser}...{/if}`, for example
44+
remove(hydrate_nodes);
45+
set_hydrating(false);
46+
mismatch = true;
47+
}
4648
}
47-
}
4849

49-
if (condition) {
50-
if (consequent_effect) {
51-
resume_effect(consequent_effect);
50+
if (condition) {
51+
if (consequent_effect) {
52+
resume_effect(consequent_effect);
53+
} else {
54+
consequent_effect = branch(() => consequent_fn(anchor));
55+
}
56+
57+
if (alternate_effect) {
58+
pause_effect(alternate_effect, () => {
59+
alternate_effect = null;
60+
});
61+
}
5262
} else {
53-
consequent_effect = branch(() => consequent_fn(anchor));
54-
}
63+
if (alternate_effect) {
64+
resume_effect(alternate_effect);
65+
} else if (alternate_fn) {
66+
alternate_effect = branch(() => alternate_fn(anchor));
67+
}
5568

56-
if (alternate_effect) {
57-
pause_effect(alternate_effect, () => {
58-
alternate_effect = null;
59-
});
60-
}
61-
} else {
62-
if (alternate_effect) {
63-
resume_effect(alternate_effect);
64-
} else if (alternate_fn) {
65-
alternate_effect = branch(() => alternate_fn(anchor));
69+
if (consequent_effect) {
70+
pause_effect(consequent_effect, () => {
71+
consequent_effect = null;
72+
});
73+
}
6674
}
6775

68-
if (consequent_effect) {
69-
pause_effect(consequent_effect, () => {
70-
consequent_effect = null;
71-
});
76+
if (mismatch) {
77+
// continue in hydration mode
78+
set_hydrating(true);
7279
}
73-
}
74-
75-
if (mismatch) {
76-
// continue in hydration mode
77-
set_hydrating(true);
78-
}
79-
}, EFFECT_TRANSPARENT);
80+
},
81+
elseif ? EFFECT_TRANSPARENT : 0
82+
);
8083
}

packages/svelte/src/internal/client/dom/elements/transitions.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,16 +248,16 @@ export function transition(flags, element, get_fn, get_params) {
248248
let run = is_global;
249249

250250
if (!run) {
251-
var block = /** @type {import('#client').Effect} */ (e.parent);
251+
var block = /** @type {import('#client').Effect | null} */ (e.parent);
252252

253253
// skip over transparent blocks (e.g. snippets, else-if blocks)
254254
while (block && (block.f & EFFECT_TRANSPARENT) !== 0) {
255-
while ((block = /** @type {import('#client').Effect} */ (block.parent))) {
255+
while ((block = block.parent)) {
256256
if ((block.f & BLOCK_EFFECT) !== 0) break;
257257
}
258258
}
259259

260-
run = (block.f & EFFECT_RAN) !== 0;
260+
run = !block || (block.f & EFFECT_RAN) !== 0;
261261
}
262262

263263
if (run) {

0 commit comments

Comments
 (0)