diff --git a/src/compiler/parse/errors.ts b/src/compiler/parse/errors.ts index 63bd5b0919..26f03c0cb1 100644 --- a/src/compiler/parse/errors.ts +++ b/src/compiler/parse/errors.ts @@ -107,6 +107,14 @@ export default { code: `invalid-${slug}-placement`, message: `<${name}> tags cannot be inside elements or blocks` }), + invalid_logic_block_placement: (location: string, name: string) => ({ + 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` diff --git a/src/compiler/parse/state/tag.ts b/src/compiler/parse/state/tag.ts index efce375b7e..4be47f25b0 100644 --- a/src/compiler/parse/state/tag.ts +++ b/src/compiler/parse/state/tag.ts @@ -219,7 +219,8 @@ export default function tag(parser: Parser) { element.children = read_sequence( parser, () => - /^<\/textarea(\s[^>]*)?>/i.test(parser.template.slice(parser.index)) + /^<\/textarea(\s[^>]*)?>/i.test(parser.template.slice(parser.index)), + 'inside \ No newline at end of file diff --git a/test/validator/samples/logic-block-in-attribute/errors.json b/test/validator/samples/logic-block-in-attribute/errors.json new file mode 100644 index 0000000000..ebf68938e7 --- /dev/null +++ b/test/validator/samples/logic-block-in-attribute/errors.json @@ -0,0 +1,9 @@ +[ + { + "code": "invalid-logic-block-placement", + "message": "{#if} logic block cannot be in attribute value", + "start": { "line": 1, "column": 12, "character": 12 }, + "end": { "line": 1, "column": 12, "character": 12 }, + "pos": 12 + } +] diff --git a/test/validator/samples/logic-block-in-attribute/input.svelte b/test/validator/samples/logic-block-in-attribute/input.svelte new file mode 100644 index 0000000000..241529527c --- /dev/null +++ b/test/validator/samples/logic-block-in-attribute/input.svelte @@ -0,0 +1 @@ +
\ No newline at end of file diff --git a/test/validator/samples/logic-block-in-textarea/errors.json b/test/validator/samples/logic-block-in-textarea/errors.json new file mode 100644 index 0000000000..b1d73d4903 --- /dev/null +++ b/test/validator/samples/logic-block-in-textarea/errors.json @@ -0,0 +1,9 @@ +[ + { + "code": "invalid-logic-block-placement", + "message": "{#each} logic block cannot be inside \ No newline at end of file