fix AST .end index for expressions in attributes ()

pull/6560/head
Yuichiro Yamashita 4 years ago committed by GitHub
parent 8b09e6181a
commit d9da22ac04
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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);

@ -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": []
}
]
}
}

@ -18,7 +18,7 @@
"value": [
{
"start": 12,
"end": 20,
"end": 19,
"type": "Text",
"raw": "color: ",
"data": "color: "
@ -80,4 +80,4 @@
}
]
}
}
}

@ -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. "

@ -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 @@
}
]
}
}
}

Loading…
Cancel
Save