diff --git a/lib/template/template-tokenize.js b/lib/template/template-tokenize.js index ba01adb..f61ac47 100644 --- a/lib/template/template-tokenize.js +++ b/lib/template/template-tokenize.js @@ -7,7 +7,7 @@ function templateTokenize(...args) { function nextToken(...args) { const returned = []; - let token, line, column; + let token, lastPos; let depth = 0; while ((token = tokenizer.nextToken.apply(tokenizer, args))) { @@ -19,8 +19,7 @@ function templateTokenize(...args) { } } if (depth || returned.length) { - line = token[4] || token[2] || line; - column = token[5] || token[3] || column; + lastPos = token[3] || token[2] || lastPos; returned.push(token); } if (!depth) { @@ -32,9 +31,7 @@ function templateTokenize(...args) { "word", returned.map((token) => token[1]).join(""), returned[0][2], - returned[0][3], - line, - column, + lastPos, ]; } return token; diff --git a/test-fixtures/ast/test.svelte b/test-fixtures/ast/test.svelte new file mode 100644 index 0000000..b12ed7e --- /dev/null +++ b/test-fixtures/ast/test.svelte @@ -0,0 +1,6 @@ + +

This is a paragraph.

+

This is a paragraph.

diff --git a/test/__snapshots__/ast.js.snap b/test/__snapshots__/ast.js.snap index 9a19ba0..15936a2 100644 --- a/test/__snapshots__/ast.js.snap +++ b/test/__snapshots__/ast.js.snap @@ -929,6 +929,163 @@ Object { } `; +exports[`AST tests test.svelte ast 1`] = ` +Object { + "inputs": Array [ + Object { + "css": "color: {color}; --opacity: {bgOpacity};", + "file": "/test.svelte", + "hasBOM": false, + }, + Object { + "css": "color: {color}", + "file": "/test.svelte", + "hasBOM": false, + }, + Object { + "css": " +

This is a paragraph.

+

This is a paragraph.

+", + "file": "/test.svelte", + "hasBOM": false, + }, + ], + "nodes": Array [ + Object { + "document": "$document", + "indexes": Object {}, + "lastEach": 1, + "nodes": Array [ + Object { + "prop": "color", + "raws": Object { + "before": "", + "between": ": ", + }, + "source": Object { + "end": Object { + "column": 25, + "line": 5, + "offset": 112, + }, + "inputId": 0, + "start": Object { + "column": 11, + "line": 5, + "offset": 98, + }, + }, + "type": "decl", + "value": "{color}", + }, + Object { + "prop": "--opacity", + "raws": Object { + "before": " ", + "between": ": ", + }, + "source": Object { + "end": Object { + "column": 49, + "line": 5, + "offset": 136, + }, + "inputId": 0, + "start": Object { + "column": 27, + "line": 5, + "offset": 114, + }, + }, + "type": "decl", + "value": "{bgOpacity}", + }, + ], + "raws": Object { + "after": "", + "codeBefore": " +

This is a paragraph.

+", + "codeBefore": "\\">This is a paragraph.

+