Skip to content

Commit 91ba203

Browse files
committed
simplify
1 parent 5ce7013 commit 91ba203

File tree

1 file changed

+5
-11
lines changed
  • packages/svelte/src/compiler/phases/2-analyze/css

1 file changed

+5
-11
lines changed

packages/svelte/src/compiler/phases/2-analyze/css/css-prune.js

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -895,7 +895,7 @@ function get_possible_element_siblings(element, adjacent_only) {
895895
let i = path.length;
896896

897897
while (i--) {
898-
let current = node;
898+
let fragment = /** @type {Compiler.AST.Fragment} */ (path[i--]);
899899

900900
// @ts-expect-error
901901
while ((node = node.prev)) {
@@ -928,20 +928,14 @@ function get_possible_element_siblings(element, adjacent_only) {
928928
}
929929
}
930930

931-
let parent = path[i];
931+
node = path[i];
932932

933-
if (parent.type === 'Fragment') {
934-
parent = path[--i];
935-
}
936-
937-
if (!parent || !is_block(parent)) break;
933+
if (!node || !is_block(node)) break;
938934

939-
if (parent.type === 'EachBlock' && !parent.fallback?.nodes.includes(current)) {
935+
if (node.type === 'EachBlock' && fragment === node.body) {
940936
// `{#each ...}<a /><b />{/each}` — `<b>` can be previous sibling of `<a />`
941-
add_to_map(get_possible_last_child(parent, adjacent_only), result);
937+
add_to_map(get_possible_last_child(node, adjacent_only), result);
942938
}
943-
944-
node = parent;
945939
}
946940

947941
return result;

0 commit comments

Comments
 (0)