Skip to content

Commit 74fa244

Browse files
committed
error on empty css declarations - fixes #3801
1 parent e55bf40 commit 74fa244

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

src/compiler/parse/read/style.ts

+7
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@ 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+
parser.error({
52+
code: `invalid-declaration`,
53+
message: `Declaration cannot be empty`
54+
}, node.start);
55+
}
56+
5057
if (node.loc) {
5158
node.start = node.loc.start.offset;
5259
node.end = node.loc.end.offset;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[{
2+
"code": "invalid-declaration",
3+
"message": "Declaration cannot be empty",
4+
"start": {
5+
"line": 11, "column": 0, "character": 93
6+
},
7+
"end": {
8+
"line": 11, "column": 0, "character": 93
9+
},
10+
"pos": 93,
11+
"frame": " 9: color: blue;\n10: }\n11: </style>\n ^"
12+
}]
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)