Skip to content

Commit 1dd8772

Browse files
committed
more accurate pruning
1 parent 344c132 commit 1dd8772

File tree

1 file changed

+9
-4
lines changed
  • packages/svelte/src/compiler/phases/2-analyze/css

1 file changed

+9
-4
lines changed

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,10 +231,15 @@ function apply_combinator(combinator, relative_selector, parent_selectors, rule,
231231
}
232232

233233
if (parent.type === 'SnippetBlock') {
234-
// We assume the snippet might be rendered in a place where the parent selectors match.
235-
// (We could do more static analysis and check the render tag reference to see if this snippet block continues
236-
// with elements that actually match the selector, but that would be a lot of work for little gain)
237-
return true;
234+
for (const site of parent.metadata.sites) {
235+
if (
236+
apply_combinator(combinator, relative_selector, parent_selectors, rule, site, state)
237+
) {
238+
return true;
239+
}
240+
}
241+
242+
return false;
238243
}
239244

240245
if (parent.type === 'RegularElement' || parent.type === 'SvelteElement') {

0 commit comments

Comments
 (0)