Skip to content

Commit b6c7956

Browse files
authored
chore: remove blocks (#10880)
* attach DOM to effects * null out effect.dom * remove some block.d references * another * drive-by fix * better comment * unused arg * another * another * another * more * finish renaming stuff * more * remove item.d * remove block.d * remove effect.block * remove current_block * delete delete delete * rename * remove some stuff we dont need * simplify
1 parent c47c571 commit b6c7956

File tree

18 files changed

+421
-574
lines changed

18 files changed

+421
-574
lines changed

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

Lines changed: 16 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ import {
99
set_current_reaction
1010
} from '../../runtime.js';
1111
import { destroy_effect, pause_effect, render_effect } from '../../reactivity/effects.js';
12-
import { DESTROYED, INERT } from '../../constants.js';
13-
import { create_block } from './utils.js';
12+
import { INERT } from '../../constants.js';
1413

1514
/**
1615
* @template V
@@ -22,8 +21,6 @@ import { create_block } from './utils.js';
2221
* @returns {void}
2322
*/
2423
export function await_block(anchor, get_input, pending_fn, then_fn, catch_fn) {
25-
const block = create_block();
26-
2724
const component_context = current_component_context;
2825

2926
hydrate_block_anchor(anchor);
@@ -48,7 +45,7 @@ export function await_block(anchor, get_input, pending_fn, then_fn, catch_fn) {
4845
set_current_effect(branch);
4946
set_current_reaction(branch); // TODO do we need both?
5047
set_current_component_context(component_context);
51-
var effect = render_effect(() => fn(anchor, value), {}, true);
48+
var effect = render_effect(() => fn(anchor, value), true);
5249
set_current_component_context(null);
5350
set_current_reaction(null);
5451
set_current_effect(null);
@@ -60,18 +57,6 @@ export function await_block(anchor, get_input, pending_fn, then_fn, catch_fn) {
6057
return effect;
6158
}
6259

63-
/** @param {import('#client').Effect} effect */
64-
function pause(effect) {
65-
if ((effect.f & DESTROYED) !== 0) return;
66-
const block = effect.block;
67-
68-
pause_effect(effect, () => {
69-
// TODO make this unnecessary
70-
const dom = block?.d;
71-
if (dom) remove(dom);
72-
});
73-
}
74-
7560
const branch = render_effect(() => {
7661
if (input === (input = get_input())) return;
7762

@@ -80,53 +65,53 @@ export function await_block(anchor, get_input, pending_fn, then_fn, catch_fn) {
8065

8166
if (pending_fn) {
8267
if (pending_effect && (pending_effect.f & INERT) === 0) {
83-
if (pending_effect.block?.d) remove(pending_effect.block.d);
68+
if (pending_effect.dom) remove(pending_effect.dom);
8469
destroy_effect(pending_effect);
8570
}
8671

87-
pending_effect = render_effect(() => pending_fn(anchor), {}, true);
72+
pending_effect = render_effect(() => pending_fn(anchor), true);
8873
}
8974

90-
if (then_effect) pause(then_effect);
91-
if (catch_effect) pause(catch_effect);
75+
if (then_effect) pause_effect(then_effect);
76+
if (catch_effect) pause_effect(catch_effect);
9277

9378
promise.then(
9479
(value) => {
9580
if (promise !== input) return;
96-
if (pending_effect) pause(pending_effect);
81+
if (pending_effect) pause_effect(pending_effect);
9782

9883
if (then_fn) {
9984
then_effect = create_effect(then_fn, value);
10085
}
10186
},
10287
(error) => {
10388
if (promise !== input) return;
104-
if (pending_effect) pause(pending_effect);
89+
if (pending_effect) pause_effect(pending_effect);
10590

10691
if (catch_fn) {
10792
catch_effect = create_effect(catch_fn, error);
10893
}
10994
}
11095
);
11196
} else {
112-
if (pending_effect) pause(pending_effect);
113-
if (catch_effect) pause(catch_effect);
97+
if (pending_effect) pause_effect(pending_effect);
98+
if (catch_effect) pause_effect(catch_effect);
11499

115100
if (then_fn) {
116101
if (then_effect) {
117-
if (then_effect.block?.d) remove(then_effect.block.d);
102+
if (then_effect.dom) remove(then_effect.dom);
118103
destroy_effect(then_effect);
119104
}
120105

121-
then_effect = render_effect(() => then_fn(anchor, input), {}, true);
106+
then_effect = render_effect(() => then_fn(anchor, input), true);
122107
}
123108
}
124-
}, block);
109+
});
125110

126111
branch.ondestroy = () => {
127112
// TODO this sucks, tidy it up
128-
if (pending_effect?.block?.d) remove(pending_effect.block.d);
129-
if (then_effect?.block?.d) remove(then_effect.block.d);
130-
if (catch_effect?.block?.d) remove(catch_effect.block.d);
113+
if (pending_effect?.dom) remove(pending_effect.dom);
114+
if (then_effect?.dom) remove(then_effect.dom);
115+
if (catch_effect?.dom) remove(catch_effect.dom);
131116
};
132117
}

0 commit comments

Comments
 (0)