Merge pull request #3812 from tanhauhau/tanhauhau/remove-empty-value-declaration

remove empty value declaration from style tree
pull/3817/head
Rich Harris 5 years ago committed by GitHub
commit b6f4c23161
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

6
package-lock.json generated

@ -1180,9 +1180,9 @@
"dev": true
},
"estree-walker": {
"version": "0.8.1",
"resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-0.8.1.tgz",
"integrity": "sha512-H6cJORkqvrNziu0KX2hqOMAlA2CiuAxHeGJXSIoKA/KLv229Dw806J3II6mKTm5xiDX1At1EXCfsOQPB+tMB+g==",
"version": "0.9.0",
"resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-0.9.0.tgz",
"integrity": "sha512-12U47o7XHUX329+x3FzNVjCx3SHEzMF0nkDv7r/HnBzX/xNTKxajBk6gyygaxrAFtLj39219oMfbtxv4KpaOiA==",
"dev": true
},
"esutils": {

@ -69,7 +69,7 @@
"eslint": "^6.3.0",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-svelte3": "^2.7.3",
"estree-walker": "^0.8.1",
"estree-walker": "^0.9.0",
"is-reference": "^1.1.4",
"jsdom": "^15.1.1",
"kleur": "^3.0.3",

@ -31,7 +31,7 @@ export default function read_style(parser: Parser, start: number, attributes: No
// tidy up AST
walk(ast, {
enter: (node: any) => { // `any` because this isn't an ESTree node
enter(node: any) { // `any` because this isn't an ESTree node
// replace `ref:a` nodes
if (node.type === 'Selector') {
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
}
}
if (node.type === 'Declaration' && node.value.type === 'Value' && node.value.children.length === 0) {
this.remove();
}
if (node.loc) {
node.start = node.loc.start.offset;
node.end = node.loc.end.offset;

@ -0,0 +1 @@
.bar.svelte-xyz{color:blue}

@ -0,0 +1,11 @@
<div class='foo bar'></div>
<style>
.foo {
color:;
}
.bar {
font:;
color: blue;
}
</style>
Loading…
Cancel
Save