Skip to content

Commit acf60d8

Browse files
authored
error on empty name in class: directive (#5939)
1 parent b3431f9 commit acf60d8

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

src/compiler/parse/state/tag.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,13 @@ function read_attribute(parser: Parser, unique_names: Set<string>) {
387387
}, start);
388388
}
389389

390+
if (type === 'Class' && directive_name === '') {
391+
parser.error({
392+
code: 'invalid-class-directive',
393+
message: 'Class binding name cannot be empty'
394+
}, start + colon_index + 1);
395+
}
396+
390397
if (value[0]) {
391398
if ((value as any[]).length > 1 || value[0].type === 'Text') {
392399
parser.error({
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"code": "invalid-class-directive",
3+
"message": "Class binding name cannot be empty",
4+
"start": {
5+
"line": 1,
6+
"column": 10,
7+
"character": 10
8+
},
9+
"pos": 10
10+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<h1 class:={true}>Hello</h1>

0 commit comments

Comments
 (0)