Skip to content

Commit b91392e

Browse files
authored
chore: tidy up (#10870)
* chore: simplify remove() * deduplicate
1 parent a339c28 commit b91392e

File tree

2 files changed

+7
-20
lines changed

2 files changed

+7
-20
lines changed

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

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,6 @@ export function if_block(anchor, get_condition, consequent_fn, alternate_fn, els
9090
consequent_fn(anchor);
9191
consequent_dom = block.d;
9292

93-
if (mismatch) {
94-
// Set fragment so that Svelte continues to operate in hydration mode
95-
set_current_hydration_fragment([]);
96-
}
97-
9893
return () => {
9994
// TODO make this unnecessary by linking the dom to the effect,
10095
// and removing automatically on teardown
@@ -124,11 +119,6 @@ export function if_block(anchor, get_condition, consequent_fn, alternate_fn, els
124119
alternate_fn(anchor);
125120
alternate_dom = block.d;
126121

127-
if (mismatch) {
128-
// Set fragment so that Svelte continues to operate in hydration mode
129-
set_current_hydration_fragment([]);
130-
}
131-
132122
return () => {
133123
// TODO make this unnecessary by linking the dom to the effect,
134124
// and removing automatically on teardown
@@ -150,6 +140,11 @@ export function if_block(anchor, get_condition, consequent_fn, alternate_fn, els
150140
});
151141
}
152142
}
143+
144+
if (mismatch) {
145+
// Set fragment so that Svelte continues to operate in hydration mode
146+
set_current_hydration_fragment([]);
147+
}
153148
}, block);
154149

155150
if (elseif) {

packages/svelte/src/internal/client/dom/reconciler.js

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,26 +50,18 @@ export function insert(current, sibling) {
5050

5151
/**
5252
* @param {Array<import('../types.js').TemplateNode> | import('../types.js').TemplateNode} current
53-
* @returns {Element | Comment | Text}
5453
*/
5554
export function remove(current) {
56-
var first_node = current;
5755
if (is_array(current)) {
58-
var i = 0;
59-
var node;
60-
for (; i < current.length; i++) {
61-
node = current[i];
62-
if (i === 0) {
63-
first_node = node;
64-
}
56+
for (var i = 0; i < current.length; i++) {
57+
var node = current[i];
6558
if (node.isConnected) {
6659
node.remove();
6760
}
6861
}
6962
} else if (current.isConnected) {
7063
current.remove();
7164
}
72-
return /** @type {Element | Comment | Text} */ (first_node);
7365
}
7466

7567
/**

0 commit comments

Comments
 (0)