diff --git a/src/compiler/parse/state/tag.ts b/src/compiler/parse/state/tag.ts index 799124b2bdf7..1a18bd31150c 100644 --- a/src/compiler/parse/state/tag.ts +++ b/src/compiler/parse/state/tag.ts @@ -330,6 +330,13 @@ function read_attribute(parser: Parser, unique_names: Set) { 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 { diff --git a/test/parser/samples/error-empty-attribute-shorthand/error.json b/test/parser/samples/error-empty-attribute-shorthand/error.json new file mode 100644 index 000000000000..f465b3468ae2 --- /dev/null +++ b/test/parser/samples/error-empty-attribute-shorthand/error.json @@ -0,0 +1,10 @@ +{ + "code": "empty-attribute-shorthand", + "message": "Attribute shorthand cannot be empty", + "start": { + "line": 1, + "column": 6, + "character": 6 + }, + "pos": 6 +} \ No newline at end of file diff --git a/test/parser/samples/error-empty-attribute-shorthand/input.svelte b/test/parser/samples/error-empty-attribute-shorthand/input.svelte new file mode 100644 index 000000000000..2e137c8c6d1b --- /dev/null +++ b/test/parser/samples/error-empty-attribute-shorthand/input.svelte @@ -0,0 +1 @@ + \ No newline at end of file