Merge pull request #3818 from sveltejs/gh-3801

error on empty css declarations
pull/3823/head
Rich Harris 5 years ago committed by GitHub
commit da824c0d5f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -47,6 +47,13 @@ export default function read_style(parser: Parser, start: number, attributes: No
}
}
if (node.type === 'Declaration' && node.value.type === 'Value' && node.value.children.length === 0) {
parser.error({
code: `invalid-declaration`,
message: `Declaration cannot be empty`
}, node.start);
}
if (node.loc) {
node.start = node.loc.start.offset;
node.end = node.loc.end.offset;

@ -0,0 +1,12 @@
[{
"code": "invalid-declaration",
"message": "Declaration cannot be empty",
"start": {
"line": 11, "column": 0, "character": 93
},
"end": {
"line": 11, "column": 0, "character": 93
},
"pos": 93,
"frame": " 9: color: blue;\n10: }\n11: </style>\n ^"
}]

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