Skip to content

Commit b43132e

Browse files
committed
update
1 parent 9284e4a commit b43132e

File tree

1 file changed

+7
-17
lines changed
  • packages/svelte/src/compiler/phases/2-analyze/css

1 file changed

+7
-17
lines changed

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

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -172,30 +172,20 @@ function apply_selector(relative_selectors, rule, element, stylesheet) {
172172
case '~': {
173173
const siblings = get_possible_element_siblings(element, name === '+');
174174

175-
let has_match = false;
176-
// NOTE: if we have :global(), we couldn't figure out what is selected within `:global` due to the
177-
// css-tree limitation that does not parse the inner selector of :global
178-
// so unless we are sure there will be no sibling to match, we will consider it as matched
179-
const has_global = parent_selectors.some(
180-
(relative_selector) => relative_selector.metadata.is_global
181-
);
182-
183-
if (has_global) {
184-
if (siblings.size === 0 && get_element_parent(element) !== null) {
185-
return false;
186-
}
187-
mark(relative_selector, element);
188-
return true;
189-
}
175+
let sibling_matched = false;
190176

191177
for (const possible_sibling of siblings.keys()) {
192178
if (apply_selector(parent_selectors, rule, possible_sibling, stylesheet)) {
193179
mark(relative_selector, element);
194-
has_match = true;
180+
sibling_matched = true;
195181
}
196182
}
197183

198-
return has_match;
184+
return (
185+
sibling_matched ||
186+
(get_element_parent(element) === null &&
187+
parent_selectors.every((selector) => is_global(selector, rule)))
188+
);
199189
}
200190

201191
default:

0 commit comments

Comments
 (0)