Skip to content

Commit 8d899fa

Browse files
committed
fix: don't consider used rules with atrules in the block
1 parent 276443f commit 8d899fa

File tree

5 files changed

+39
-4
lines changed

5 files changed

+39
-4
lines changed

.changeset/lazy-queens-agree.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: don't consider used rules with atrules in the block

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -348,10 +348,6 @@ function is_used(rule) {
348348

349349
for (const child of rule.block.children) {
350350
if (child.type === 'Rule' && is_used(child)) return true;
351-
352-
if (child.type === 'Atrule') {
353-
return true; // TODO
354-
}
355351
}
356352

357353
return false;
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { test } from '../../test';
2+
3+
export default test({
4+
warnings: [
5+
{
6+
filename: 'SvelteComponent.svelte',
7+
code: 'css_unused_selector',
8+
message: 'Unused CSS selector ".unused"',
9+
start: {
10+
line: 2,
11+
column: 1,
12+
character: 9
13+
},
14+
end: {
15+
line: 2,
16+
column: 8,
17+
character: 16
18+
}
19+
}
20+
]
21+
});
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
/* (unused) .unused {
3+
@media (min-width: 400px) {
4+
color: red;
5+
}
6+
}*/
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<style>
2+
.unused {
3+
@media (min-width: 400px) {
4+
color: red;
5+
}
6+
}
7+
</style>

0 commit comments

Comments
 (0)