Skip to content

Commit 6ff62a8

Browse files
committed
more correct (but apparently completely unnecessary) child check
1 parent 8d899fa commit 6ff62a8

File tree

1 file changed

+8
-6
lines changed
  • packages/svelte/src/compiler/phases/3-transform/css

1 file changed

+8
-6
lines changed

packages/svelte/src/compiler/phases/3-transform/css/index.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -333,21 +333,23 @@ function is_empty(rule) {
333333
}
334334

335335
if (child.type === 'Atrule') {
336-
return false; // TODO
336+
if (child.block === null || child.block.children.length > 0) return false;
337337
}
338338
}
339339

340340
return true;
341341
}
342342

343-
/** @param {Css.Rule} rule */
343+
/** @param {Css.Rule | Css.Atrule} rule */
344344
function is_used(rule) {
345-
for (const selector of rule.prelude.children) {
346-
if (selector.metadata.used) return true;
345+
if (rule.type === 'Rule') {
346+
for (const selector of rule.prelude.children) {
347+
if (selector.metadata.used) return true;
348+
}
347349
}
348350

349-
for (const child of rule.block.children) {
350-
if (child.type === 'Rule' && is_used(child)) return true;
351+
for (const child of rule.block?.children || []) {
352+
if ((child.type === 'Rule' || child.type === 'Atrule') && is_used(child)) return true;
351353
}
352354

353355
return false;

0 commit comments

Comments
 (0)