Skip to content

chore: tidy up #10870

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions packages/svelte/src/internal/client/dom/blocks/if.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,6 @@ export function if_block(anchor, get_condition, consequent_fn, alternate_fn, els
consequent_fn(anchor);
consequent_dom = block.d;

if (mismatch) {
// Set fragment so that Svelte continues to operate in hydration mode
set_current_hydration_fragment([]);
}

return () => {
// TODO make this unnecessary by linking the dom to the effect,
// and removing automatically on teardown
Expand Down Expand Up @@ -124,11 +119,6 @@ export function if_block(anchor, get_condition, consequent_fn, alternate_fn, els
alternate_fn(anchor);
alternate_dom = block.d;

if (mismatch) {
// Set fragment so that Svelte continues to operate in hydration mode
set_current_hydration_fragment([]);
}

return () => {
// TODO make this unnecessary by linking the dom to the effect,
// and removing automatically on teardown
Expand All @@ -150,6 +140,11 @@ export function if_block(anchor, get_condition, consequent_fn, alternate_fn, els
});
}
}

if (mismatch) {
// Set fragment so that Svelte continues to operate in hydration mode
set_current_hydration_fragment([]);
}
}, block);

if (elseif) {
Expand Down
12 changes: 2 additions & 10 deletions packages/svelte/src/internal/client/dom/reconciler.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,26 +50,18 @@ export function insert(current, sibling) {

/**
* @param {Array<import('../types.js').TemplateNode> | import('../types.js').TemplateNode} current
* @returns {Element | Comment | Text}
*/
export function remove(current) {
var first_node = current;
if (is_array(current)) {
var i = 0;
var node;
for (; i < current.length; i++) {
node = current[i];
if (i === 0) {
first_node = node;
}
for (var i = 0; i < current.length; i++) {
var node = current[i];
if (node.isConnected) {
node.remove();
}
}
} else if (current.isConnected) {
current.remove();
}
return /** @type {Element | Comment | Text} */ (first_node);
}

/**
Expand Down