diff --git a/src/parse/state/tag.ts b/src/parse/state/tag.ts index a3d909f402..2b4aeaba1d 100644 --- a/src/parse/state/tag.ts +++ b/src/parse/state/tag.ts @@ -390,6 +390,15 @@ function readAttribute(parser: Parser, uniqueNames: Set) { if (type) { const [directive_name, ...modifiers] = name.slice(colon_index + 1).split('|'); + if (value[0]) { + if (value.length > 1 || value[0].type === 'Text') { + parser.error({ + code: `invalid-directive-value`, + message: `Directive value must be a JavaScript expression enclosed in curly braces` + }, value[0].start); + } + } + const directive = { start, end, diff --git a/test/runtime/samples/class-boolean/main.html b/test/runtime/samples/class-boolean/main.html index 31df46dfe5..226476816b 100644 --- a/test/runtime/samples/class-boolean/main.html +++ b/test/runtime/samples/class-boolean/main.html @@ -1 +1 @@ -
\ No newline at end of file +
\ No newline at end of file diff --git a/test/validator/samples/directive-non-expression/errors.json b/test/validator/samples/directive-non-expression/errors.json new file mode 100644 index 0000000000..c606963b68 --- /dev/null +++ b/test/validator/samples/directive-non-expression/errors.json @@ -0,0 +1,15 @@ +[{ + "code": "invalid-directive-value", + "message": "Directive value must be a JavaScript expression enclosed in curly braces", + "pos": 15, + "start": { + "line": 1, + "column": 15, + "character": 15 + }, + "end": { + "line": 1, + "column": 15, + "character": 15 + } +}] \ No newline at end of file diff --git a/test/validator/samples/directive-non-expression/input.html b/test/validator/samples/directive-non-expression/input.html new file mode 100644 index 0000000000..815add35e4 --- /dev/null +++ b/test/validator/samples/directive-non-expression/input.html @@ -0,0 +1 @@ +
\ No newline at end of file diff --git a/test/validator/samples/event-modifiers-invalid-passive/errors.json b/test/validator/samples/event-modifiers-invalid-passive/errors.json index 90fce9eb44..93807d0a4e 100644 --- a/test/validator/samples/event-modifiers-invalid-passive/errors.json +++ b/test/validator/samples/event-modifiers-invalid-passive/errors.json @@ -8,8 +8,8 @@ }, "end": { "line": 1, - "column": 52, - "character": 52 + "column": 50, + "character": 50 }, "pos": 5 }] diff --git a/test/validator/samples/event-modifiers-invalid-passive/input.html b/test/validator/samples/event-modifiers-invalid-passive/input.html index e51cd57ae7..db9c9f8fb0 100644 --- a/test/validator/samples/event-modifiers-invalid-passive/input.html +++ b/test/validator/samples/event-modifiers-invalid-passive/input.html @@ -1,3 +1,3 @@ -
+
oops
\ No newline at end of file diff --git a/test/validator/samples/event-modifiers-invalid/errors.json b/test/validator/samples/event-modifiers-invalid/errors.json index 0de4e9aacf..0aac0e5327 100644 --- a/test/validator/samples/event-modifiers-invalid/errors.json +++ b/test/validator/samples/event-modifiers-invalid/errors.json @@ -8,8 +8,8 @@ }, "end": { "line": 1, - "column": 36, - "character": 36 + "column": 34, + "character": 34 }, "pos": 8 }] diff --git a/test/validator/samples/event-modifiers-invalid/input.html b/test/validator/samples/event-modifiers-invalid/input.html index 27dacdbc2d..e217186266 100644 --- a/test/validator/samples/event-modifiers-invalid/input.html +++ b/test/validator/samples/event-modifiers-invalid/input.html @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file