Skip to content

Commit 4e3bd94

Browse files
committed
fix
1 parent 9f6c4cf commit 4e3bd94

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/** @import { Effect } from '#client' */
2-
import { block, branch, destroy_effect } from '../../reactivity/effects.js';
2+
import { block, branch, effect, destroy_effect } from '../../reactivity/effects.js';
33

44
// TODO in 6.0 or 7.0, when we remove legacy mode, we can simplify this by
55
// getting rid of the block/branch stuff and just letting the effect rip.
@@ -14,17 +14,19 @@ export function attach(node, get_fn) {
1414
var fn = undefined;
1515

1616
/** @type {Effect | null} */
17-
var effect;
17+
var e;
1818

1919
block(() => {
2020
if (fn !== (fn = get_fn())) {
21-
if (effect) {
22-
destroy_effect(effect);
23-
effect = null;
21+
if (e) {
22+
destroy_effect(e);
23+
e = null;
2424
}
2525

2626
if (fn) {
27-
effect = branch(() => /** @type {(node: Element) => void} */ (fn)(node));
27+
e = branch(() => {
28+
effect(() => /** @type {(node: Element) => void} */ (fn)(node));
29+
});
2830
}
2931
}
3032
});

0 commit comments

Comments
 (0)