Skip to content

Commit

Permalink
Add a more descriptive message for the error generated by an empty sh…
Browse files Browse the repository at this point in the history
…orthand attribute (#6217)

Added error message "empty-attribute-shorthand" for when the shorthand attribute is empty,
giving a more explicit error for #6086
  • Loading branch information
rster2002 authored Jun 22, 2021
1 parent 17c5402 commit de6d0c6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/compiler/parse/state/tag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,13 @@ function read_attribute(parser: Parser, unique_names: Set<string>) {
parser.allow_whitespace();
parser.eat('}', true);

if (name === null) {
parser.error({
code: 'empty-attribute-shorthand',
message: 'Attribute shorthand cannot be empty'
}, start);
}

check_unique(name);

return {
Expand Down
10 changes: 10 additions & 0 deletions test/parser/samples/error-empty-attribute-shorthand/error.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"code": "empty-attribute-shorthand",
"message": "Attribute shorthand cannot be empty",
"start": {
"line": 1,
"column": 6,
"character": 6
},
"pos": 6
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<span {}></span>

0 comments on commit de6d0c6

Please sign in to comment.