Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a more descriptive message for the error generated by an empty shorthand attribute #6217

Merged
merged 7 commits into from
Jun 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>