mirror of https://github.com/sveltejs/svelte
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>pull/14457/head
parent
4f318e6ad6
commit
19d80ad63c
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'svelte': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: correctly remove unused selectors in middle of selector lists
|
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
h1.svelte-xyz,
|
h1.svelte-xyz,
|
||||||
h2.svelte-xyz,
|
h2.svelte-xyz,
|
||||||
h3.svelte-xyz, /* (unused) h4*/
|
h3.svelte-xyz /* (unused) h4*/,
|
||||||
p.svelte-xyz {
|
p.svelte-xyz {
|
||||||
color: red;
|
color: red;
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
/* (unused) .foo*/ .bar.svelte-xyz /* (unused) .baz*/ {
|
/* (unused) .foo,*/ .bar.svelte-xyz /* (unused) .baz*/ {
|
||||||
color: red;
|
color: red;
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
@ -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;
|
||||||
|
}
|
@ -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>
|
Loading…
Reference in new issue