Skip to content

Commit b6f4c23

Browse files
authored
Merge pull request #3812 from tanhauhau/tanhauhau/remove-empty-value-declaration
remove empty value declaration from style tree
2 parents 0588783 + a92aa89 commit b6f4c23

File tree

5 files changed

+21
-5
lines changed

5 files changed

+21
-5
lines changed

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
"eslint": "^6.3.0",
7070
"eslint-plugin-import": "^2.18.2",
7171
"eslint-plugin-svelte3": "^2.7.3",
72-
"estree-walker": "^0.8.1",
72+
"estree-walker": "^0.9.0",
7373
"is-reference": "^1.1.4",
7474
"jsdom": "^15.1.1",
7575
"kleur": "^3.0.3",

src/compiler/parse/read/style.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export default function read_style(parser: Parser, start: number, attributes: No
3131

3232
// tidy up AST
3333
walk(ast, {
34-
enter: (node: any) => { // `any` because this isn't an ESTree node
34+
enter(node: any) { // `any` because this isn't an ESTree node
3535
// replace `ref:a` nodes
3636
if (node.type === 'Selector') {
3737
for (let i = 0; i < node.children.length; i += 1) {
@@ -47,6 +47,10 @@ export default function read_style(parser: Parser, start: number, attributes: No
4747
}
4848
}
4949

50+
if (node.type === 'Declaration' && node.value.type === 'Value' && node.value.children.length === 0) {
51+
this.remove();
52+
}
53+
5054
if (node.loc) {
5155
node.start = node.loc.start.offset;
5256
node.end = node.loc.end.offset;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.bar.svelte-xyz{color:blue}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<div class='foo bar'></div>
2+
3+
<style>
4+
.foo {
5+
color:;
6+
}
7+
.bar {
8+
font:;
9+
color: blue;
10+
}
11+
</style>

0 commit comments

Comments
 (0)