always add raw property to text nodes

pull/2876/head
Richard Harris 5 years ago
parent f08964286d
commit b7f9c9c954

@ -476,35 +476,28 @@ function read_sequence(parser: Parser, done: () => boolean): Node[] {
start: parser.index,
end: null,
type: 'Text',
data: '',
raw: '',
data: null
};
function flush() {
if (current_chunk.raw) {
current_chunk.data = decode_character_references(current_chunk.raw);
current_chunk.end = parser.index;
chunks.push(current_chunk);
}
}
const chunks: Node[] = [];
while (parser.index < parser.template.length) {
const index = parser.index;
if (done()) {
current_chunk.end = parser.index;
if (current_chunk.data) chunks.push(current_chunk);
chunks.forEach(chunk => {
if (chunk.type === 'Text') {
let decoded = decode_character_references(chunk.data);
if (chunk.data != decoded) {
chunk.raw = chunk.data;
chunk.data = decoded;
}
}
});
flush();
return chunks;
} else if (parser.eat('{')) {
if (current_chunk.data) {
current_chunk.end = index;
chunks.push(current_chunk);
}
flush();
parser.allow_whitespace();
const expression = read_expression(parser);
@ -522,10 +515,11 @@ function read_sequence(parser: Parser, done: () => boolean): Node[] {
start: parser.index,
end: null,
type: 'Text',
data: '',
raw: '',
data: null
};
} else {
current_chunk.data += parser.template[parser.index++];
current_chunk.raw += parser.template[parser.index++];
}
}

@ -18,11 +18,9 @@ export default function text(parser: Parser) {
start,
end: parser.index,
type: 'Text',
raw: data,
data: decode_character_references(data),
};
if (node.data != data)
node.raw = data;
parser.current().children.push(node);
}

@ -41,8 +41,5 @@
"children": []
}
]
},
"css": null,
"instance": null,
"module": null
}
}

@ -27,8 +27,5 @@
"children": []
}
]
},
"css": null,
"instance": null,
"module": null
}
}

@ -28,8 +28,5 @@
"children": []
}
]
},
"css": null,
"instance": null,
"module": null
}
}

@ -22,8 +22,5 @@
"children": []
}
]
},
"css": null,
"instance": null,
"module": null
}
}

@ -35,6 +35,7 @@
"start": 51,
"end": 56,
"type": "Text",
"raw": "flips",
"data": "flips"
}
]
@ -54,8 +55,5 @@
}
}
]
},
"css": null,
"instance": null,
"module": null
}
}

@ -20,6 +20,7 @@
"start": 8,
"end": 30,
"type": "Text",
"raw": "https://www.google.com",
"data": "https://www.google.com"
}
]
@ -30,13 +31,11 @@
"start": 31,
"end": 37,
"type": "Text",
"raw": "Google",
"data": "Google"
}
]
}
]
},
"css": null,
"instance": null,
"module": null
}
}

@ -33,8 +33,5 @@
"children": []
}
]
},
"css": null,
"instance": null,
"module": null
}
}

@ -33,8 +33,5 @@
"children": []
}
]
},
"css": null,
"instance": null,
"module": null
}
}

@ -18,8 +18,9 @@
"value": [
{
"start": 12,
"end": 19,
"end": 20,
"type": "Text",
"raw": "color: ",
"data": "color: "
},
{
@ -37,6 +38,7 @@
"start": 26,
"end": 27,
"type": "Text",
"raw": ";",
"data": ";"
}
]
@ -57,8 +59,5 @@
]
}
]
},
"css": null,
"instance": null,
"module": null
}
}

@ -20,8 +20,8 @@
"start": 15,
"end": 33,
"type": "Text",
"data": "\"quoted\"",
"raw": "&quot;quoted&quot;"
"raw": "&quot;quoted&quot;",
"data": "\"quoted\""
}
]
}
@ -29,8 +29,5 @@
"children": []
}
]
},
"css": null,
"instance": null,
"module": null
}
}

@ -20,6 +20,7 @@
"start": 9,
"end": 10,
"type": "Text",
"raw": "x",
"data": "x"
}
]
@ -34,6 +35,7 @@
"start": 19,
"end": 20,
"type": "Text",
"raw": "y",
"data": "y"
}
]
@ -42,8 +44,5 @@
"children": []
}
]
},
"css": null,
"instance": null,
"module": null
}
}

@ -33,8 +33,5 @@
"children": []
}
]
},
"css": null,
"instance": null,
"module": null
}
}

@ -21,8 +21,5 @@
"children": []
}
]
},
"css": null,
"instance": null,
"module": null
}
}

@ -20,6 +20,7 @@
"start": 12,
"end": 15,
"type": "Text",
"raw": "foo",
"data": "foo"
}
]
@ -28,8 +29,5 @@
"children": []
}
]
},
"css": null,
"instance": null,
"module": null
}
}

@ -20,6 +20,7 @@
"start": 11,
"end": 14,
"type": "Text",
"raw": "foo",
"data": "foo"
}
]
@ -28,8 +29,5 @@
"children": []
}
]
},
"css": null,
"instance": null,
"module": null
}
}

@ -19,13 +19,13 @@
"pending": {
"start": 19,
"end": 39,
"skip": false,
"type": "PendingBlock",
"children": [
{
"start": 19,
"end": 21,
"type": "Text",
"raw": "\n\t",
"data": "\n\t"
},
{
@ -39,6 +39,7 @@
"start": 24,
"end": 34,
"type": "Text",
"raw": "loading...",
"data": "loading..."
}
]
@ -47,20 +48,22 @@
"start": 38,
"end": 39,
"type": "Text",
"raw": "\n",
"data": "\n"
}
]
],
"skip": false
},
"then": {
"start": 39,
"end": 88,
"skip": false,
"type": "ThenBlock",
"children": [
{
"start": 55,
"end": 57,
"type": "Text",
"raw": "\n\t",
"data": "\n\t"
},
{
@ -74,6 +77,7 @@
"start": 60,
"end": 73,
"type": "Text",
"raw": "the value is ",
"data": "the value is "
},
{
@ -93,20 +97,22 @@
"start": 87,
"end": 88,
"type": "Text",
"raw": "\n",
"data": "\n"
}
]
],
"skip": false
},
"catch": {
"start": 88,
"end": 140,
"skip": false,
"type": "CatchBlock",
"children": [
{
"start": 105,
"end": 107,
"type": "Text",
"raw": "\n\t",
"data": "\n\t"
},
{
@ -120,6 +126,7 @@
"start": 110,
"end": 117,
"type": "Text",
"raw": "oh no! ",
"data": "oh no! "
},
{
@ -151,14 +158,13 @@
"start": 139,
"end": 140,
"type": "Text",
"raw": "\n",
"data": "\n"
}
]
],
"skip": false
}
}
]
},
"css": null,
"instance": null,
"module": null
}
}
}

@ -8,6 +8,7 @@
"start": 28,
"end": 30,
"type": "Text",
"raw": "\n\n",
"data": "\n\n"
},
{

@ -8,6 +8,7 @@
"start": 29,
"end": 31,
"type": "Text",
"raw": "\n\n",
"data": "\n\n"
},
{

@ -11,8 +11,5 @@
"data": " a comment "
}
]
},
"css": null,
"instance": null,
"module": null
}
}

@ -36,8 +36,5 @@
}
}
]
},
"css": null,
"instance": null,
"module": null
}
}

@ -15,14 +15,11 @@
"start": 3,
"end": 20,
"type": "Text",
"data": "Hello & World",
"raw": "Hello &amp; World"
"raw": "Hello &amp; World",
"data": "Hello & World"
}
]
}
]
},
"css": null,
"instance": null,
"module": null
}
}

@ -8,12 +8,9 @@
"start": 0,
"end": 17,
"type": "Text",
"data": "Hello & World",
"raw": "Hello &amp; World"
"raw": "Hello &amp; World",
"data": "Hello & World"
}
]
},
"css": null,
"instance": null,
"module": null
}
}

@ -15,6 +15,7 @@
"start": 5,
"end": 8,
"type": "Text",
"raw": "foo",
"data": "foo"
}
]
@ -23,6 +24,7 @@
"start": 14,
"end": 16,
"type": "Text",
"raw": "\n\n",
"data": "\n\n"
}
]
@ -90,7 +92,5 @@
"end": 48,
"styles": "\n\tdiv {\n\t\tcolor: red;\n\t}\n"
}
},
"instance": null,
"module": null
}
}

@ -5,7 +5,6 @@
"type": "Fragment",
"children": []
},
"css": null,
"instance": {
"start": 0,
"end": 146,
@ -66,8 +65,8 @@
"start": 54,
"end": 134,
"id": null,
"generator": false,
"expression": false,
"generator": false,
"async": false,
"params": [],
"body": {
@ -120,8 +119,8 @@
"start": 88,
"end": 129,
"id": null,
"generator": false,
"expression": false,
"generator": false,
"async": false,
"params": [
{

@ -37,6 +37,7 @@
"start": 50,
"end": 52,
"type": "Text",
"raw": ": ",
"data": ": "
},
{
@ -80,8 +81,5 @@
}
}
]
},
"css": null,
"instance": null,
"module": null
}
}
}

@ -58,6 +58,7 @@
"start": 55,
"end": 65,
"type": "Text",
"raw": "no animals",
"data": "no animals"
}
]
@ -66,8 +67,5 @@
}
}
]
},
"css": null,
"instance": null,
"module": null
}
}

@ -37,6 +37,7 @@
"start": 36,
"end": 38,
"type": "Text",
"raw": ": ",
"data": ": "
},
{
@ -62,8 +63,5 @@
"index": "i"
}
]
},
"css": null,
"instance": null,
"module": null
}
}

@ -62,8 +62,5 @@
}
}
]
},
"css": null,
"instance": null,
"module": null
}
}

@ -44,8 +44,5 @@
}
}
]
},
"css": null,
"instance": null,
"module": null
}
}

@ -15,6 +15,7 @@
"start": 4,
"end": 10,
"type": "Text",
"raw": "hello ",
"data": "hello "
},
{
@ -32,13 +33,11 @@
"start": 16,
"end": 17,
"type": "Text",
"raw": "!",
"data": "!"
}
]
}
]
},
"css": null,
"instance": null,
"module": null
}
}

@ -15,13 +15,11 @@
"start": 6,
"end": 10,
"type": "Text",
"raw": "test",
"data": "test"
}
]
}
]
},
"css": null,
"instance": null,
"module": null
}
}

@ -21,8 +21,5 @@
"children": []
}
]
},
"css": null,
"instance": null,
"module": null
}
}

@ -21,8 +21,8 @@
"start": 19,
"end": 43,
"id": null,
"generator": false,
"expression": true,
"generator": false,
"async": false,
"params": [],
"body": {
@ -58,6 +58,7 @@
"start": 46,
"end": 52,
"type": "Text",
"raw": "toggle",
"data": "toggle"
}
]
@ -66,6 +67,7 @@
"start": 61,
"end": 63,
"type": "Text",
"raw": "\n\n",
"data": "\n\n"
},
{
@ -90,6 +92,7 @@
"start": 81,
"end": 87,
"type": "Text",
"raw": "hello!",
"data": "hello!"
}
]
@ -97,8 +100,5 @@
]
}
]
},
"css": null,
"instance": null,
"module": null
}
}

@ -26,6 +26,7 @@
"start": 14,
"end": 17,
"type": "Text",
"raw": "foo",
"data": "foo"
}
]
@ -47,6 +48,7 @@
"start": 34,
"end": 41,
"type": "Text",
"raw": "not foo",
"data": "not foo"
}
]
@ -55,8 +57,5 @@
}
}
]
},
"css": null,
"instance": null,
"module": null
}
}

@ -39,6 +39,7 @@
"start": 17,
"end": 37,
"type": "Text",
"raw": "x is greater than 10",
"data": "x is greater than 10"
}
]
@ -85,6 +86,7 @@
"start": 63,
"end": 79,
"type": "Text",
"raw": "x is less than 5",
"data": "x is less than 5"
}
]

@ -19,13 +19,11 @@
"start": 9,
"end": 12,
"type": "Text",
"raw": "bar",
"data": "bar"
}
]
}
]
},
"css": null,
"instance": null,
"module": null
}
}

@ -15,6 +15,7 @@
"start": 4,
"end": 6,
"type": "Text",
"raw": "\n\t",
"data": "\n\t"
},
{
@ -28,6 +29,7 @@
"start": 10,
"end": 13,
"type": "Text",
"raw": "a\n\t",
"data": "a\n\t"
}
]
@ -43,6 +45,7 @@
"start": 17,
"end": 20,
"type": "Text",
"raw": "b\n\t",
"data": "b\n\t"
}
]
@ -58,6 +61,7 @@
"start": 24,
"end": 26,
"type": "Text",
"raw": "c\n",
"data": "c\n"
}
]
@ -65,8 +69,5 @@
]
}
]
},
"css": null,
"instance": null,
"module": null
}
}

@ -15,14 +15,11 @@
"start": 6,
"end": 12,
"type": "Text",
"data": " ",
"raw": "&nbsp;"
"raw": "&nbsp;",
"data": " "
}
]
}
]
},
"css": null,
"instance": null,
"module": null
}
}

@ -15,6 +15,7 @@
"start": 3,
"end": 4,
"type": "Text",
"raw": " ",
"data": " "
},
{
@ -32,6 +33,7 @@
"start": 16,
"end": 17,
"type": "Text",
"raw": " ",
"data": " "
},
{
@ -49,13 +51,11 @@
"start": 29,
"end": 30,
"type": "Text",
"raw": " ",
"data": " "
}
]
}
]
},
"css": null,
"instance": null,
"module": null
}
}

@ -8,6 +8,7 @@
"start": 28,
"end": 30,
"type": "Text",
"raw": "\n\n",
"data": "\n\n"
},
{

@ -8,6 +8,7 @@
"start": 43,
"end": 45,
"type": "Text",
"raw": "\n\n",
"data": "\n\n"
},
{

@ -8,6 +8,7 @@
"start": 77,
"end": 79,
"type": "Text",
"raw": "\n\n",
"data": "\n\n"
},
{
@ -21,6 +22,7 @@
"start": 83,
"end": 89,
"type": "Text",
"raw": "Hello ",
"data": "Hello "
},
{
@ -38,6 +40,7 @@
"start": 95,
"end": 96,
"type": "Text",
"raw": "!",
"data": "!"
}
]

@ -8,6 +8,7 @@
"start": 66,
"end": 68,
"type": "Text",
"raw": "\n\n",
"data": "\n\n"
},
{
@ -21,6 +22,7 @@
"start": 72,
"end": 78,
"type": "Text",
"raw": "Hello ",
"data": "Hello "
},
{
@ -38,6 +40,7 @@
"start": 84,
"end": 85,
"type": "Text",
"raw": "!",
"data": "!"
}
]

@ -8,6 +8,7 @@
"start": 39,
"end": 41,
"type": "Text",
"raw": "\n\n",
"data": "\n\n"
},
{
@ -21,6 +22,7 @@
"start": 45,
"end": 51,
"type": "Text",
"raw": "Hello ",
"data": "Hello "
},
{
@ -38,6 +40,7 @@
"start": 57,
"end": 58,
"type": "Text",
"raw": "!",
"data": "!"
}
]

@ -13,8 +13,5 @@
"children": []
}
]
},
"css": null,
"instance": null,
"module": null
}
}

@ -72,8 +72,5 @@
]
}
]
},
"css": null,
"instance": null,
"module": null
}
}

@ -15,6 +15,7 @@
"start": 3,
"end": 4,
"type": "Text",
"raw": " ",
"data": " "
},
{
@ -32,6 +33,7 @@
"start": 7,
"end": 8,
"type": "Text",
"raw": " ",
"data": " "
},
{
@ -49,6 +51,7 @@
"start": 11,
"end": 14,
"type": "Text",
"raw": " : ",
"data": " : "
},
{
@ -66,13 +69,11 @@
"start": 17,
"end": 20,
"type": "Text",
"raw": " : ",
"data": " : "
}
]
}
]
},
"css": null,
"instance": null,
"module": null
}
}

@ -25,8 +25,5 @@
"children": []
}
]
},
"css": null,
"instance": null,
"module": null
}
}

@ -16,8 +16,9 @@
"value": [
{
"start": 10,
"end": 40,
"end": 41,
"type": "Text",
"raw": "\n\t<p>not actually an element. ",
"data": "\n\t<p>not actually an element. "
},
{
@ -35,6 +36,7 @@
"start": 45,
"end": 50,
"type": "Text",
"raw": "</p>\n",
"data": "</p>\n"
}
]
@ -43,8 +45,5 @@
"children": []
}
]
},
"css": null,
"instance": null,
"module": null
}
}

@ -26,13 +26,11 @@
"start": 13,
"end": 21,
"type": "Text",
"raw": "fades in",
"data": "fades in"
}
]
}
]
},
"css": null,
"instance": null,
"module": null
}
}

@ -54,13 +54,11 @@
"start": 31,
"end": 39,
"type": "Text",
"raw": "fades in",
"data": "fades in"
}
]
}
]
},
"css": null,
"instance": null,
"module": null
}
}

@ -44,8 +44,5 @@
}
}
]
},
"css": null,
"instance": null,
"module": null
}
}

@ -8,6 +8,7 @@
"start": 0,
"end": 6,
"type": "Text",
"raw": "\n\n\t\t\t\t",
"data": "\n\n\t\t\t\t"
},
{
@ -21,13 +22,11 @@
"start": 9,
"end": 32,
"type": "Text",
"raw": "just chillin' over here",
"data": "just chillin' over here"
}
]
}
]
},
"css": null,
"instance": null,
"module": null
}
}

@ -15,6 +15,7 @@
"start": 4,
"end": 10,
"type": "Text",
"raw": "Hello ",
"data": "Hello "
},
{
@ -39,6 +40,7 @@
"start": 24,
"end": 26,
"type": "Text",
"raw": "! ",
"data": "! "
}
]
@ -54,6 +56,7 @@
"start": 41,
"end": 53,
"type": "Text",
"raw": "How are you?",
"data": "How are you?"
}
]
@ -61,8 +64,5 @@
]
}
]
},
"css": null,
"instance": null,
"module": null
}
}

@ -16,8 +16,5 @@
}
}
]
},
"css": null,
"instance": null,
"module": null
}
}
Loading…
Cancel
Save