-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: css pruning producing invalid css (#14448)
* fix: css pruning producing invalid css * Update .changeset/big-hats-wonder.md --------- Co-authored-by: Rich Harris <rich.harris@vercel.com>
- Loading branch information
1 parent
4f318e6
commit 19d80ad
Showing
8 changed files
with
211 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'svelte': patch | ||
--- | ||
|
||
fix: correctly remove unused selectors in middle of selector lists |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/svelte/tests/css/samples/unused-selector-in-between/expected.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
|
||
h1.svelte-xyz, | ||
h2.svelte-xyz, | ||
h3.svelte-xyz, /* (unused) h4*/ | ||
h3.svelte-xyz /* (unused) h4*/, | ||
p.svelte-xyz { | ||
color: red; | ||
} |
2 changes: 1 addition & 1 deletion
2
packages/svelte/tests/css/samples/unused-selector-leading/expected.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
/* (unused) .foo*/ .bar.svelte-xyz /* (unused) .baz*/ { | ||
/* (unused) .foo,*/ .bar.svelte-xyz /* (unused) .baz*/ { | ||
color: red; | ||
} |
160 changes: 160 additions & 0 deletions
160
packages/svelte/tests/css/samples/unused-selector-multiple/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
import { test } from '../../test'; | ||
|
||
export default test({ | ||
warnings: [ | ||
{ | ||
code: 'a11y_missing_content', | ||
message: '`<h1>` element should contain text', | ||
start: { | ||
line: 1, | ||
column: 0, | ||
character: 0 | ||
}, | ||
end: { | ||
line: 1, | ||
column: 9, | ||
character: 9 | ||
} | ||
}, | ||
{ | ||
code: 'a11y_missing_content', | ||
message: '`<h4>` element should contain text', | ||
start: { | ||
line: 2, | ||
column: 0, | ||
character: 10 | ||
}, | ||
end: { | ||
line: 2, | ||
column: 9, | ||
character: 19 | ||
} | ||
}, | ||
{ | ||
code: 'css_unused_selector', | ||
message: 'Unused CSS selector "h2"', | ||
start: { | ||
line: 6, | ||
column: 5, | ||
character: 35 | ||
}, | ||
end: { | ||
line: 6, | ||
column: 7, | ||
character: 37 | ||
} | ||
}, | ||
{ | ||
code: 'css_unused_selector', | ||
message: 'Unused CSS selector "h3"', | ||
start: { | ||
line: 6, | ||
column: 9, | ||
character: 39 | ||
}, | ||
end: { | ||
line: 6, | ||
column: 11, | ||
character: 41 | ||
} | ||
}, | ||
{ | ||
code: 'css_unused_selector', | ||
message: 'Unused CSS selector "h2"', | ||
start: { | ||
line: 9, | ||
column: 5, | ||
character: 66 | ||
}, | ||
end: { | ||
line: 9, | ||
column: 7, | ||
character: 68 | ||
} | ||
}, | ||
{ | ||
code: 'css_unused_selector', | ||
message: 'Unused CSS selector "h2"', | ||
start: { | ||
line: 13, | ||
column: 5, | ||
character: 110 | ||
}, | ||
end: { | ||
line: 13, | ||
column: 7, | ||
character: 112 | ||
} | ||
}, | ||
{ | ||
code: 'css_unused_selector', | ||
message: 'Unused CSS selector "h3"', | ||
start: { | ||
line: 13, | ||
column: 9, | ||
character: 114 | ||
}, | ||
end: { | ||
line: 13, | ||
column: 11, | ||
character: 116 | ||
} | ||
}, | ||
{ | ||
code: 'css_unused_selector', | ||
message: 'Unused CSS selector "h2"', | ||
start: { | ||
line: 17, | ||
column: 5, | ||
character: 161 | ||
}, | ||
end: { | ||
line: 17, | ||
column: 7, | ||
character: 163 | ||
} | ||
}, | ||
{ | ||
code: 'css_unused_selector', | ||
message: 'Unused CSS selector "h3"', | ||
start: { | ||
line: 17, | ||
column: 9, | ||
character: 165 | ||
}, | ||
end: { | ||
line: 17, | ||
column: 11, | ||
character: 167 | ||
} | ||
}, | ||
{ | ||
code: 'css_unused_selector', | ||
message: 'Unused CSS selector "h5"', | ||
start: { | ||
line: 17, | ||
column: 17, | ||
character: 173 | ||
}, | ||
end: { | ||
line: 17, | ||
column: 19, | ||
character: 175 | ||
} | ||
}, | ||
{ | ||
code: 'css_unused_selector', | ||
message: 'Unused CSS selector "h6"', | ||
start: { | ||
line: 17, | ||
column: 21, | ||
character: 177 | ||
}, | ||
end: { | ||
line: 17, | ||
column: 23, | ||
character: 179 | ||
} | ||
} | ||
] | ||
}); |
15 changes: 15 additions & 0 deletions
15
packages/svelte/tests/css/samples/unused-selector-multiple/expected.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
|
||
h1.svelte-xyz /* (unused) h2, h3*/ { | ||
color: red; | ||
} | ||
h1.svelte-xyz /* (unused) h2*/ { | ||
text-decoration: underline; | ||
} | ||
|
||
h1.svelte-xyz /* (unused) h2, h3*/, h4.svelte-xyz { | ||
text-transform: uppercase; | ||
} | ||
|
||
h1.svelte-xyz /* (unused) h2, h3*/, h4.svelte-xyz /* (unused) h5, h6*/ { | ||
background-color: green; | ||
} |
20 changes: 20 additions & 0 deletions
20
packages/svelte/tests/css/samples/unused-selector-multiple/input.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<h1></h1> | ||
<h4></h4> | ||
|
||
|
||
<style> | ||
h1, h2, h3 { | ||
color: red; | ||
} | ||
h1, h2 { | ||
text-decoration: underline; | ||
} | ||
h1, h2, h3, h4 { | ||
text-transform: uppercase; | ||
} | ||
h1, h2, h3, h4, h5, h6 { | ||
background-color: green; | ||
} | ||
</style> |