diff --git a/src/compiler/parse/state/tag.ts b/src/compiler/parse/state/tag.ts index bf3a6ab98a..7999c34f84 100644 --- a/src/compiler/parse/state/tag.ts +++ b/src/compiler/parse/state/tag.ts @@ -444,10 +444,10 @@ function read_sequence(parser: Parser, done: () => boolean): TemplateNode[] { data: null }; - function flush() { + function flush(end: number) { if (current_chunk.raw) { current_chunk.data = decode_character_references(current_chunk.raw); - current_chunk.end = parser.index; + current_chunk.end = end; chunks.push(current_chunk); } } @@ -458,10 +458,10 @@ function read_sequence(parser: Parser, done: () => boolean): TemplateNode[] { const index = parser.index; if (done()) { - flush(); + flush(parser.index); return chunks; } else if (parser.eat('{')) { - flush(); + flush(parser.index - 1); parser.allow_whitespace(); const expression = read_expression(parser); diff --git a/test/parser/samples/attribute-curly-bracket/input.svelte b/test/parser/samples/attribute-curly-bracket/input.svelte new file mode 100644 index 0000000000..4e40713771 --- /dev/null +++ b/test/parser/samples/attribute-curly-bracket/input.svelte @@ -0,0 +1 @@ +<input foo=a{1} /> diff --git a/test/parser/samples/attribute-curly-bracket/output.json b/test/parser/samples/attribute-curly-bracket/output.json new file mode 100644 index 0000000000..7fa04859f3 --- /dev/null +++ b/test/parser/samples/attribute-curly-bracket/output.json @@ -0,0 +1,55 @@ +{ + "html": { + "start": 0, + "end": 18, + "type": "Fragment", + "children": [ + { + "start": 0, + "end": 18, + "type": "Element", + "name": "input", + "attributes": [ + { + "start": 7, + "end": 15, + "type": "Attribute", + "name": "foo", + "value": [ + { + "start": 11, + "end": 12, + "type": "Text", + "raw": "a", + "data": "a" + }, + { + "start": 12, + "end": 15, + "type": "MustacheTag", + "expression": { + "type": "Literal", + "start": 13, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "value": 1, + "raw": "1" + } + } + ] + } + ], + "children": [] + } + ] + } +} diff --git a/test/parser/samples/attribute-dynamic/output.json b/test/parser/samples/attribute-dynamic/output.json index 28b9da1dea..4926b645ab 100644 --- a/test/parser/samples/attribute-dynamic/output.json +++ b/test/parser/samples/attribute-dynamic/output.json @@ -18,7 +18,7 @@ "value": [ { "start": 12, - "end": 20, + "end": 19, "type": "Text", "raw": "color: ", "data": "color: " @@ -80,4 +80,4 @@ } ] } -} \ No newline at end of file +} diff --git a/test/parser/samples/textarea-children/output.json b/test/parser/samples/textarea-children/output.json index 0ebbfd38fc..cdb4b885d1 100644 --- a/test/parser/samples/textarea-children/output.json +++ b/test/parser/samples/textarea-children/output.json @@ -13,7 +13,7 @@ "children": [ { "start": 10, - "end": 41, + "end": 40, "type": "Text", "raw": "\n\t<p>not actually an element. ", "data": "\n\t<p>not actually an element. " diff --git a/test/parser/samples/textarea-end-tag/output.json b/test/parser/samples/textarea-end-tag/output.json index d723169934..9693db2729 100644 --- a/test/parser/samples/textarea-end-tag/output.json +++ b/test/parser/samples/textarea-end-tag/output.json @@ -13,7 +13,7 @@ "children": [ { "start": 10, - "end": 51, + "end": 50, "type": "Text", "raw": "\n\t<p>not actu </textar ally an element. ", "data": "\n\t<p>not actu </textar ally an element. " @@ -50,4 +50,4 @@ } ] } -} \ No newline at end of file +}