include checking for {@html} tags in invalid location

pull/7862/head
tanhauhau 4 years ago
parent 4e391263ae
commit 0e174fe38b

@ -111,6 +111,10 @@ export default {
code: 'invalid-logic-block-placement',
message: `{#${name}} logic block cannot be ${location}`
}),
invalid_tag_placement: (location: string, name: string) => ({
code: 'invalid-tag-placement',
message: `{@${name}} tag cannot be ${location}`
}),
invalid_ref_directive: (name: string) => ({
code: 'invalid-ref-directive',
message: `The ref directive is no longer supported — use \`bind:this={${name}}\` instead`

@ -527,6 +527,11 @@ function read_sequence(parser: Parser, done: () => boolean, location: string): T
parser.eat('#');
const name = parser.read_until(/[^a-z]/);
parser.error(parser_errors.invalid_logic_block_placement(location, name), index);
} else if (parser.match('@')) {
const index = parser.index - 1;
parser.eat('@');
const name = parser.read_until(/[^a-z]/);
parser.error(parser_errors.invalid_tag_placement(location, name), index);
}
flush(parser.index - 1);

@ -0,0 +1,9 @@
[
{
"code": "invalid-tag-placement",
"message": "{@html} tag cannot be in attribute value",
"start": { "line": 1, "column": 12, "character": 12 },
"end": { "line": 1, "column": 12, "character": 12 },
"pos": 12
}
]

@ -0,0 +1,9 @@
[
{
"code": "invalid-tag-placement",
"message": "{@html} tag cannot be inside <textarea>",
"start": { "line": 2, "column": 1, "character": 12 },
"end": { "line": 2, "column": 1, "character": 12 },
"pos": 12
}
]

@ -0,0 +1,3 @@
<textarea>
{@html fruit}
</textarea>
Loading…
Cancel
Save