diff --git a/src/interfaces.ts b/src/interfaces.ts index d44c6a030c..dc3fb614c1 100644 --- a/src/interfaces.ts +++ b/src/interfaces.ts @@ -66,6 +66,8 @@ export interface CompileOptions { onerror?: (error: Error) => void; onwarn?: (warning: Warning) => void; + + parser?: 'v2'; } export interface GenerateOptions { diff --git a/src/parse/index.ts b/src/parse/index.ts index 3e78221477..b7656a426a 100644 --- a/src/parse/index.ts +++ b/src/parse/index.ts @@ -13,11 +13,13 @@ import error from '../utils/error'; interface ParserOptions { filename?: string; bind?: boolean; + parser?: 'v2'; } type ParserState = (parser: Parser) => (ParserState | void); export class Parser { + readonly v2: boolean; readonly template: string; readonly filename?: string; @@ -32,6 +34,8 @@ export class Parser { allowBindings: boolean; constructor(template: string, options: ParserOptions) { + this.v2 = options.parser === 'v2'; + if (typeof template !== 'string') { throw new TypeError('Template must be a string'); } diff --git a/src/parse/state/fragment.ts b/src/parse/state/fragment.ts index c82b3e2f8a..b2e6cb4c32 100644 --- a/src/parse/state/fragment.ts +++ b/src/parse/state/fragment.ts @@ -8,7 +8,7 @@ export default function fragment(parser: Parser) { return tag; } - if (parser.match('{{')) { + if (parser.match(parser.v2 ? '{' : '{{')) { return mustache; } diff --git a/src/parse/state/mustache.ts b/src/parse/state/mustache.ts index 0a255b1256..8da2560fb2 100644 --- a/src/parse/state/mustache.ts +++ b/src/parse/state/mustache.ts @@ -32,7 +32,7 @@ function trimWhitespace(block: Node, trimBefore: boolean, trimAfter: boolean) { export default function mustache(parser: Parser) { const start = parser.index; - parser.index += 2; + parser.index += parser.v2 ? 1 : 2; parser.allowWhitespace(); @@ -329,7 +329,7 @@ export default function mustache(parser: Parser) { const expression = readExpression(parser); parser.allowWhitespace(); - parser.eat('}}', true); + parser.eat(parser.v2 ? '}' : '}}', true); parser.current().children.push({ start, diff --git a/src/parse/state/text.ts b/src/parse/state/text.ts index bdd625569c..29da8f928a 100644 --- a/src/parse/state/text.ts +++ b/src/parse/state/text.ts @@ -9,7 +9,7 @@ export default function text(parser: Parser) { while ( parser.index < parser.template.length && !parser.match('<') && - !parser.match('{{') + !parser.match(parser.v2 ? '{' : '{{') ) { data += parser.template[parser.index++]; } diff --git a/test/parser/index.js b/test/parser/index.js index 7467e31b0c..d0417c8bfa 100644 --- a/test/parser/index.js +++ b/test/parser/index.js @@ -2,7 +2,7 @@ import assert from 'assert'; import fs from 'fs'; import { svelte, tryToLoadJson } from '../helpers.js'; -describe('parse', () => { +describe.only('parse', () => { fs.readdirSync('test/parser/samples').forEach(dir => { if (dir[0] === '.') return; @@ -20,19 +20,37 @@ describe('parse', () => { .readFileSync(`test/parser/samples/${dir}/input.html`, 'utf-8') .replace(/\s+$/, ''); + const input_v2 = fs + .readFileSync(`test/parser/samples/${dir}/input-v2.html`, 'utf-8') + .replace(/\s+$/, ''); + const options = tryToLoadJson(`test/parser/samples/${dir}/options.json`) || {}; try { const actual = svelte.parse(input, options); + const expected = require(`./samples/${dir}/output.json`); + fs.writeFileSync( `test/parser/samples/${dir}/_actual.json`, JSON.stringify(actual, null, '\t') ); - const expected = require(`./samples/${dir}/output.json`); assert.deepEqual(actual.html, expected.html); assert.deepEqual(actual.css, expected.css); assert.deepEqual(actual.js, expected.js); + + // TODO remove v1 tests + const actual_v2 = svelte.parse(input_v2, Object.assign({ parser: 'v2' }, options)); + const expected_v2 = require(`./samples/${dir}/output-v2.json`); + + fs.writeFileSync( + `test/parser/samples/${dir}/_actual-v2.json`, + JSON.stringify(actual_v2, null, '\t') + ); + + assert.deepEqual(actual_v2.html, expected_v2.html); + assert.deepEqual(actual_v2.css, expected_v2.css); + assert.deepEqual(actual_v2.js, expected_v2.js); } catch (err) { if (err.name !== 'ParseError') throw err; diff --git a/test/parser/samples/action-with-call/_actual-v2.json b/test/parser/samples/action-with-call/_actual-v2.json new file mode 100644 index 0000000000..b7bc908e24 --- /dev/null +++ b/test/parser/samples/action-with-call/_actual-v2.json @@ -0,0 +1,47 @@ +{ + "hash": "1eefngx", + "html": { + "start": 0, + "end": 38, + "type": "Fragment", + "children": [ + { + "start": 0, + "end": 38, + "type": "Element", + "name": "input", + "attributes": [ + { + "start": 7, + "end": 37, + "type": "Action", + "name": "tooltip", + "expression": { + "type": "CallExpression", + "start": 20, + "end": 36, + "callee": { + "type": "Identifier", + "start": 20, + "end": 21, + "name": "t" + }, + "arguments": [ + { + "type": "Literal", + "start": 22, + "end": 35, + "value": "tooltip msg", + "raw": "'tooltip msg'" + } + ] + } + } + ], + "children": [] + } + ] + }, + "css": null, + "js": null +} \ No newline at end of file diff --git a/test/parser/samples/action-with-call/input-v2.html b/test/parser/samples/action-with-call/input-v2.html new file mode 100644 index 0000000000..246bf02c59 --- /dev/null +++ b/test/parser/samples/action-with-call/input-v2.html @@ -0,0 +1 @@ + diff --git a/test/parser/samples/action-with-call/output-v2.json b/test/parser/samples/action-with-call/output-v2.json new file mode 100644 index 0000000000..f5cc6824f3 --- /dev/null +++ b/test/parser/samples/action-with-call/output-v2.json @@ -0,0 +1,47 @@ +{ + "hash": 1937205193, + "html": { + "start": 0, + "end": 38, + "type": "Fragment", + "children": [ + { + "start": 0, + "end": 38, + "type": "Element", + "name": "input", + "attributes": [ + { + "start": 7, + "end": 37, + "type": "Action", + "name": "tooltip", + "expression": { + "type": "CallExpression", + "start": 20, + "end": 36, + "callee": { + "type": "Identifier", + "start": 20, + "end": 21, + "name": "t" + }, + "arguments": [ + { + "type": "Literal", + "start": 22, + "end": 35, + "value": "tooltip msg", + "raw": "'tooltip msg'" + } + ] + } + } + ], + "children": [] + } + ] + }, + "css": null, + "js": null +} \ No newline at end of file diff --git a/test/parser/samples/action-with-identifier/_actual-v2.json b/test/parser/samples/action-with-identifier/_actual-v2.json new file mode 100644 index 0000000000..6c6daa34b2 --- /dev/null +++ b/test/parser/samples/action-with-identifier/_actual-v2.json @@ -0,0 +1,33 @@ +{ + "hash": "1vce0rr", + "html": { + "start": 0, + "end": 29, + "type": "Fragment", + "children": [ + { + "start": 0, + "end": 29, + "type": "Element", + "name": "input", + "attributes": [ + { + "start": 7, + "end": 28, + "type": "Action", + "name": "tooltip", + "expression": { + "type": "Identifier", + "start": 20, + "end": 27, + "name": "message" + } + } + ], + "children": [] + } + ] + }, + "css": null, + "js": null +} \ No newline at end of file diff --git a/test/parser/samples/action-with-identifier/input-v2.html b/test/parser/samples/action-with-identifier/input-v2.html new file mode 100644 index 0000000000..14a65e83ed --- /dev/null +++ b/test/parser/samples/action-with-identifier/input-v2.html @@ -0,0 +1 @@ + diff --git a/test/parser/samples/action-with-identifier/output-v2.json b/test/parser/samples/action-with-identifier/output-v2.json new file mode 100644 index 0000000000..6c39ed94bc --- /dev/null +++ b/test/parser/samples/action-with-identifier/output-v2.json @@ -0,0 +1,33 @@ +{ + "hash": 1937205193, + "html": { + "start": 0, + "end": 29, + "type": "Fragment", + "children": [ + { + "start": 0, + "end": 29, + "type": "Element", + "name": "input", + "attributes": [ + { + "start": 7, + "end": 28, + "type": "Action", + "name": "tooltip", + "expression": { + "type": "Identifier", + "start": 20, + "end": 27, + "name": "message" + } + } + ], + "children": [] + } + ] + }, + "css": null, + "js": null +} \ No newline at end of file diff --git a/test/parser/samples/action-with-literal/_actual-v2.json b/test/parser/samples/action-with-literal/_actual-v2.json new file mode 100644 index 0000000000..472b5a306d --- /dev/null +++ b/test/parser/samples/action-with-literal/_actual-v2.json @@ -0,0 +1,34 @@ +{ + "hash": "1pm9eh0", + "html": { + "start": 0, + "end": 35, + "type": "Fragment", + "children": [ + { + "start": 0, + "end": 35, + "type": "Element", + "name": "input", + "attributes": [ + { + "start": 7, + "end": 34, + "type": "Action", + "name": "tooltip", + "expression": { + "type": "Literal", + "start": 20, + "end": 33, + "value": "tooltip msg", + "raw": "'tooltip msg'" + } + } + ], + "children": [] + } + ] + }, + "css": null, + "js": null +} \ No newline at end of file diff --git a/test/parser/samples/action-with-literal/input-v2.html b/test/parser/samples/action-with-literal/input-v2.html new file mode 100644 index 0000000000..60e16eacfc --- /dev/null +++ b/test/parser/samples/action-with-literal/input-v2.html @@ -0,0 +1 @@ + diff --git a/test/parser/samples/action-with-literal/output-v2.json b/test/parser/samples/action-with-literal/output-v2.json new file mode 100644 index 0000000000..0da0318887 --- /dev/null +++ b/test/parser/samples/action-with-literal/output-v2.json @@ -0,0 +1,34 @@ +{ + "hash": 1937205193, + "html": { + "start": 0, + "end": 35, + "type": "Fragment", + "children": [ + { + "start": 0, + "end": 35, + "type": "Element", + "name": "input", + "attributes": [ + { + "start": 7, + "end": 34, + "type": "Action", + "name": "tooltip", + "expression": { + "type": "Literal", + "start": 20, + "end": 33, + "value": "tooltip msg", + "raw": "'tooltip msg'" + } + } + ], + "children": [] + } + ] + }, + "css": null, + "js": null +} \ No newline at end of file diff --git a/test/parser/samples/action/_actual-v2.json b/test/parser/samples/action/_actual-v2.json new file mode 100644 index 0000000000..0746bd601a --- /dev/null +++ b/test/parser/samples/action/_actual-v2.json @@ -0,0 +1,28 @@ +{ + "hash": "1e3ix5", + "html": { + "start": 0, + "end": 21, + "type": "Fragment", + "children": [ + { + "start": 0, + "end": 21, + "type": "Element", + "name": "input", + "attributes": [ + { + "start": 7, + "end": 20, + "type": "Action", + "name": "autofocus", + "expression": null + } + ], + "children": [] + } + ] + }, + "css": null, + "js": null +} \ No newline at end of file diff --git a/test/parser/samples/action/input-v2.html b/test/parser/samples/action/input-v2.html new file mode 100644 index 0000000000..64409c2a65 --- /dev/null +++ b/test/parser/samples/action/input-v2.html @@ -0,0 +1 @@ + diff --git a/test/parser/samples/action/output-v2.json b/test/parser/samples/action/output-v2.json new file mode 100644 index 0000000000..597ae297a5 --- /dev/null +++ b/test/parser/samples/action/output-v2.json @@ -0,0 +1,28 @@ +{ + "hash": 1937205193, + "html": { + "start": 0, + "end": 21, + "type": "Fragment", + "children": [ + { + "start": 0, + "end": 21, + "type": "Element", + "name": "input", + "attributes": [ + { + "start": 7, + "end": 20, + "type": "Action", + "name": "autofocus", + "expression": null + } + ], + "children": [] + } + ] + }, + "css": null, + "js": null +} \ No newline at end of file diff --git a/test/parser/samples/attribute-dynamic-boolean/_actual-v2.json b/test/parser/samples/attribute-dynamic-boolean/_actual-v2.json new file mode 100644 index 0000000000..c843275a4f --- /dev/null +++ b/test/parser/samples/attribute-dynamic-boolean/_actual-v2.json @@ -0,0 +1,35 @@ +{ + "hash": "7xolfv", + "html": { + "start": 0, + "end": 41, + "type": "Fragment", + "children": [ + { + "start": 0, + "end": 41, + "type": "Element", + "name": "textarea", + "attributes": [ + { + "start": 10, + "end": 29, + "type": "Attribute", + "name": "readonly", + "value": [ + { + "start": 19, + "end": 29, + "type": "Text", + "data": "{readonly}" + } + ] + } + ], + "children": [] + } + ] + }, + "css": null, + "js": null +} \ No newline at end of file diff --git a/test/parser/samples/attribute-dynamic-boolean/input-v2.html b/test/parser/samples/attribute-dynamic-boolean/input-v2.html new file mode 100644 index 0000000000..ba531f2f81 --- /dev/null +++ b/test/parser/samples/attribute-dynamic-boolean/input-v2.html @@ -0,0 +1 @@ + diff --git a/test/parser/samples/attribute-dynamic-boolean/output-v2.json b/test/parser/samples/attribute-dynamic-boolean/output-v2.json new file mode 100644 index 0000000000..af1635a55d --- /dev/null +++ b/test/parser/samples/attribute-dynamic-boolean/output-v2.json @@ -0,0 +1,40 @@ +{ + "hash": 3179574701, + "html": { + "start": 0, + "end": 45, + "type": "Fragment", + "children": [ + { + "start": 0, + "end": 45, + "type": "Element", + "name": "textarea", + "attributes": [ + { + "start": 10, + "end": 33, + "type": "Attribute", + "name": "readonly", + "value": [ + { + "start": 20, + "end": 32, + "type": "MustacheTag", + "expression": { + "type": "Identifier", + "start": 22, + "end": 30, + "name": "readonly" + } + } + ] + } + ], + "children": [] + } + ] + }, + "css": null, + "js": null +} \ No newline at end of file diff --git a/test/parser/samples/attribute-dynamic-reserved/_actual-v2.json b/test/parser/samples/attribute-dynamic-reserved/_actual-v2.json new file mode 100644 index 0000000000..76b70ef261 --- /dev/null +++ b/test/parser/samples/attribute-dynamic-reserved/_actual-v2.json @@ -0,0 +1,35 @@ +{ + "hash": "l0cddf", + "html": { + "start": 0, + "end": 25, + "type": "Fragment", + "children": [ + { + "start": 0, + "end": 25, + "type": "Element", + "name": "div", + "attributes": [ + { + "start": 5, + "end": 18, + "type": "Attribute", + "name": "class", + "value": [ + { + "start": 11, + "end": 18, + "type": "Text", + "data": "{class}" + } + ] + } + ], + "children": [] + } + ] + }, + "css": null, + "js": null +} \ No newline at end of file diff --git a/test/parser/samples/attribute-dynamic-reserved/input-v2.html b/test/parser/samples/attribute-dynamic-reserved/input-v2.html new file mode 100644 index 0000000000..d973a9dea0 --- /dev/null +++ b/test/parser/samples/attribute-dynamic-reserved/input-v2.html @@ -0,0 +1 @@ +
\ No newline at end of file diff --git a/test/parser/samples/attribute-dynamic-reserved/output-v2.json b/test/parser/samples/attribute-dynamic-reserved/output-v2.json new file mode 100644 index 0000000000..aef0e5cb63 --- /dev/null +++ b/test/parser/samples/attribute-dynamic-reserved/output-v2.json @@ -0,0 +1,40 @@ +{ + "hash": 2788845841, + "html": { + "start": 0, + "end": 29, + "type": "Fragment", + "children": [ + { + "start": 0, + "end": 29, + "type": "Element", + "name": "div", + "attributes": [ + { + "start": 5, + "end": 22, + "type": "Attribute", + "name": "class", + "value": [ + { + "start": 12, + "end": 21, + "type": "MustacheTag", + "expression": { + "type": "Identifier", + "start": 14, + "end": 19, + "name": "class" + } + } + ] + } + ], + "children": [] + } + ] + }, + "css": null, + "js": null +} \ No newline at end of file diff --git a/test/parser/samples/attribute-dynamic/_actual-v2.json b/test/parser/samples/attribute-dynamic/_actual-v2.json new file mode 100644 index 0000000000..06f82de54a --- /dev/null +++ b/test/parser/samples/attribute-dynamic/_actual-v2.json @@ -0,0 +1,42 @@ +{ + "hash": "ehtsx6", + "html": { + "start": 0, + "end": 42, + "type": "Fragment", + "children": [ + { + "start": 0, + "end": 42, + "type": "Element", + "name": "div", + "attributes": [ + { + "start": 5, + "end": 28, + "type": "Attribute", + "name": "style", + "value": [ + { + "start": 12, + "end": 27, + "type": "Text", + "data": "color: {color};" + } + ] + } + ], + "children": [ + { + "start": 29, + "end": 36, + "type": "Text", + "data": "{color}" + } + ] + } + ] + }, + "css": null, + "js": null +} \ No newline at end of file diff --git a/test/parser/samples/attribute-dynamic/input-v2.html b/test/parser/samples/attribute-dynamic/input-v2.html new file mode 100644 index 0000000000..9171ae22a7 --- /dev/null +++ b/test/parser/samples/attribute-dynamic/input-v2.html @@ -0,0 +1 @@ +
{color}
diff --git a/test/parser/samples/attribute-dynamic/output-v2.json b/test/parser/samples/attribute-dynamic/output-v2.json new file mode 100644 index 0000000000..79ef81065f --- /dev/null +++ b/test/parser/samples/attribute-dynamic/output-v2.json @@ -0,0 +1,64 @@ +{ + "hash": 804348386, + "html": { + "start": 0, + "end": 46, + "type": "Fragment", + "children": [ + { + "start": 0, + "end": 46, + "type": "Element", + "name": "div", + "attributes": [ + { + "start": 5, + "end": 30, + "type": "Attribute", + "name": "style", + "value": [ + { + "start": 12, + "end": 19, + "type": "Text", + "data": "color: " + }, + { + "start": 19, + "end": 28, + "type": "MustacheTag", + "expression": { + "type": "Identifier", + "start": 21, + "end": 26, + "name": "color" + } + }, + { + "start": 28, + "end": 29, + "type": "Text", + "data": ";" + } + ] + } + ], + "children": [ + { + "start": 31, + "end": 40, + "type": "MustacheTag", + "expression": { + "type": "Identifier", + "start": 33, + "end": 38, + "name": "color" + } + } + ] + } + ] + }, + "css": null, + "js": null +} \ No newline at end of file diff --git a/test/parser/samples/attribute-escaped/_actual-v2.json b/test/parser/samples/attribute-escaped/_actual-v2.json new file mode 100644 index 0000000000..d048a3d945 --- /dev/null +++ b/test/parser/samples/attribute-escaped/_actual-v2.json @@ -0,0 +1,35 @@ +{ + "hash": "pv50w6", + "html": { + "start": 0, + "end": 41, + "type": "Fragment", + "children": [ + { + "start": 0, + "end": 41, + "type": "Element", + "name": "div", + "attributes": [ + { + "start": 5, + "end": 34, + "type": "Attribute", + "name": "data-foo", + "value": [ + { + "start": 15, + "end": 33, + "type": "Text", + "data": "\"quoted\"" + } + ] + } + ], + "children": [] + } + ] + }, + "css": null, + "js": null +} \ No newline at end of file diff --git a/test/parser/samples/attribute-escaped/input-v2.html b/test/parser/samples/attribute-escaped/input-v2.html new file mode 100644 index 0000000000..82186dcee4 --- /dev/null +++ b/test/parser/samples/attribute-escaped/input-v2.html @@ -0,0 +1 @@ +
diff --git a/test/parser/samples/attribute-escaped/output-v2.json b/test/parser/samples/attribute-escaped/output-v2.json new file mode 100644 index 0000000000..974084bcdd --- /dev/null +++ b/test/parser/samples/attribute-escaped/output-v2.json @@ -0,0 +1,35 @@ +{ + "hash": 1563956934, + "html": { + "start": 0, + "end": 41, + "type": "Fragment", + "children": [ + { + "start": 0, + "end": 41, + "type": "Element", + "name": "div", + "attributes": [ + { + "start": 5, + "end": 34, + "type": "Attribute", + "name": "data-foo", + "value": [ + { + "start": 15, + "end": 33, + "type": "Text", + "data": "\"quoted\"" + } + ] + } + ], + "children": [] + } + ] + }, + "css": null, + "js": null +} \ No newline at end of file diff --git a/test/parser/samples/attribute-multiple/_actual-v2.json b/test/parser/samples/attribute-multiple/_actual-v2.json new file mode 100644 index 0000000000..b185127d56 --- /dev/null +++ b/test/parser/samples/attribute-multiple/_actual-v2.json @@ -0,0 +1,49 @@ +{ + "hash": "8dvm3u", + "html": { + "start": 0, + "end": 28, + "type": "Fragment", + "children": [ + { + "start": 0, + "end": 28, + "type": "Element", + "name": "div", + "attributes": [ + { + "start": 5, + "end": 11, + "type": "Attribute", + "name": "id", + "value": [ + { + "start": 9, + "end": 10, + "type": "Text", + "data": "x" + } + ] + }, + { + "start": 12, + "end": 21, + "type": "Attribute", + "name": "class", + "value": [ + { + "start": 19, + "end": 20, + "type": "Text", + "data": "y" + } + ] + } + ], + "children": [] + } + ] + }, + "css": null, + "js": null +} \ No newline at end of file diff --git a/test/parser/samples/attribute-multiple/input-v2.html b/test/parser/samples/attribute-multiple/input-v2.html new file mode 100644 index 0000000000..6f61bd6289 --- /dev/null +++ b/test/parser/samples/attribute-multiple/input-v2.html @@ -0,0 +1 @@ +
\ No newline at end of file diff --git a/test/parser/samples/attribute-multiple/output-v2.json b/test/parser/samples/attribute-multiple/output-v2.json new file mode 100644 index 0000000000..81af977b51 --- /dev/null +++ b/test/parser/samples/attribute-multiple/output-v2.json @@ -0,0 +1,49 @@ +{ + "hash": 507039402, + "html": { + "start": 0, + "end": 28, + "type": "Fragment", + "children": [ + { + "start": 0, + "end": 28, + "type": "Element", + "name": "div", + "attributes": [ + { + "start": 5, + "end": 11, + "type": "Attribute", + "name": "id", + "value": [ + { + "start": 9, + "end": 10, + "type": "Text", + "data": "x" + } + ] + }, + { + "start": 12, + "end": 21, + "type": "Attribute", + "name": "class", + "value": [ + { + "start": 19, + "end": 20, + "type": "Text", + "data": "y" + } + ] + } + ], + "children": [] + } + ] + }, + "css": null, + "js": null +} \ No newline at end of file diff --git a/test/parser/samples/attribute-shorthand/_actual-v2.json b/test/parser/samples/attribute-shorthand/_actual-v2.json new file mode 100644 index 0000000000..01b3ae38b2 --- /dev/null +++ b/test/parser/samples/attribute-shorthand/_actual-v2.json @@ -0,0 +1,40 @@ +{ + "hash": "s7nwuc", + "html": { + "start": 0, + "end": 10, + "type": "Fragment", + "children": [ + { + "start": 0, + "end": 10, + "type": "Element", + "name": "div", + "attributes": [ + { + "start": 5, + "end": 8, + "type": "Attribute", + "name": "id", + "value": [ + { + "type": "AttributeShorthand", + "start": 6, + "end": 8, + "expression": { + "type": "Identifier", + "start": 6, + "end": 8, + "name": "id" + } + } + ] + } + ], + "children": [] + } + ] + }, + "css": null, + "js": null +} \ No newline at end of file diff --git a/test/parser/samples/attribute-shorthand/input-v2.html b/test/parser/samples/attribute-shorthand/input-v2.html new file mode 100644 index 0000000000..e26deafb3a --- /dev/null +++ b/test/parser/samples/attribute-shorthand/input-v2.html @@ -0,0 +1 @@ +
\ No newline at end of file diff --git a/test/parser/samples/attribute-shorthand/output-v2.json b/test/parser/samples/attribute-shorthand/output-v2.json new file mode 100644 index 0000000000..b6578c13eb --- /dev/null +++ b/test/parser/samples/attribute-shorthand/output-v2.json @@ -0,0 +1,40 @@ +{ + "hash": 1705925892, + "html": { + "start": 0, + "end": 10, + "type": "Fragment", + "children": [ + { + "start": 0, + "end": 10, + "type": "Element", + "name": "div", + "attributes": [ + { + "start": 5, + "end": 8, + "type": "Attribute", + "name": "id", + "value": [ + { + "type": "AttributeShorthand", + "start": 6, + "end": 8, + "expression": { + "type": "Identifier", + "start": 6, + "end": 8, + "name": "id" + } + } + ] + } + ], + "children": [] + } + ] + }, + "css": null, + "js": null +} \ No newline at end of file diff --git a/test/parser/samples/attribute-static-boolean/_actual-v2.json b/test/parser/samples/attribute-static-boolean/_actual-v2.json new file mode 100644 index 0000000000..a70a135f2a --- /dev/null +++ b/test/parser/samples/attribute-static-boolean/_actual-v2.json @@ -0,0 +1,28 @@ +{ + "hash": "a1b7fo", + "html": { + "start": 0, + "end": 30, + "type": "Fragment", + "children": [ + { + "start": 0, + "end": 30, + "type": "Element", + "name": "textarea", + "attributes": [ + { + "start": 10, + "end": 18, + "type": "Attribute", + "name": "readonly", + "value": true + } + ], + "children": [] + } + ] + }, + "css": null, + "js": null +} \ No newline at end of file diff --git a/test/parser/samples/attribute-static-boolean/input-v2.html b/test/parser/samples/attribute-static-boolean/input-v2.html new file mode 100644 index 0000000000..1536f3e1e8 --- /dev/null +++ b/test/parser/samples/attribute-static-boolean/input-v2.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/parser/samples/attribute-static-boolean/output-v2.json b/test/parser/samples/attribute-static-boolean/output-v2.json new file mode 100644 index 0000000000..21429893fd --- /dev/null +++ b/test/parser/samples/attribute-static-boolean/output-v2.json @@ -0,0 +1,28 @@ +{ + "hash": 606864228, + "html": { + "start": 0, + "end": 30, + "type": "Fragment", + "children": [ + { + "start": 0, + "end": 30, + "type": "Element", + "name": "textarea", + "attributes": [ + { + "start": 10, + "end": 18, + "type": "Attribute", + "name": "readonly", + "value": true + } + ], + "children": [] + } + ] + }, + "css": null, + "js": null +} \ No newline at end of file diff --git a/test/parser/samples/attribute-static/_actual-v2.json b/test/parser/samples/attribute-static/_actual-v2.json new file mode 100644 index 0000000000..28dc91df40 --- /dev/null +++ b/test/parser/samples/attribute-static/_actual-v2.json @@ -0,0 +1,35 @@ +{ + "hash": "op11m5", + "html": { + "start": 0, + "end": 23, + "type": "Fragment", + "children": [ + { + "start": 0, + "end": 23, + "type": "Element", + "name": "div", + "attributes": [ + { + "start": 5, + "end": 16, + "type": "Attribute", + "name": "class", + "value": [ + { + "start": 12, + "end": 15, + "type": "Text", + "data": "foo" + } + ] + } + ], + "children": [] + } + ] + }, + "css": null, + "js": null +} \ No newline at end of file diff --git a/test/parser/samples/attribute-static/input-v2.html b/test/parser/samples/attribute-static/input-v2.html new file mode 100644 index 0000000000..c6a8a8c95d --- /dev/null +++ b/test/parser/samples/attribute-static/input-v2.html @@ -0,0 +1 @@ +
\ No newline at end of file diff --git a/test/parser/samples/attribute-static/output-v2.json b/test/parser/samples/attribute-static/output-v2.json new file mode 100644 index 0000000000..394f95f458 --- /dev/null +++ b/test/parser/samples/attribute-static/output-v2.json @@ -0,0 +1,35 @@ +{ + "hash": 1493227373, + "html": { + "start": 0, + "end": 23, + "type": "Fragment", + "children": [ + { + "start": 0, + "end": 23, + "type": "Element", + "name": "div", + "attributes": [ + { + "start": 5, + "end": 16, + "type": "Attribute", + "name": "class", + "value": [ + { + "start": 12, + "end": 15, + "type": "Text", + "data": "foo" + } + ] + } + ], + "children": [] + } + ] + }, + "css": null, + "js": null +} \ No newline at end of file diff --git a/test/parser/samples/attribute-unique-error/input-v2.html b/test/parser/samples/attribute-unique-error/input-v2.html new file mode 100644 index 0000000000..37fec733b3 --- /dev/null +++ b/test/parser/samples/attribute-unique-error/input-v2.html @@ -0,0 +1 @@ +
\ No newline at end of file diff --git a/test/parser/samples/attribute-unquoted/_actual-v2.json b/test/parser/samples/attribute-unquoted/_actual-v2.json new file mode 100644 index 0000000000..583e8814d6 --- /dev/null +++ b/test/parser/samples/attribute-unquoted/_actual-v2.json @@ -0,0 +1,35 @@ +{ + "hash": "1lozhxt", + "html": { + "start": 0, + "end": 21, + "type": "Fragment", + "children": [ + { + "start": 0, + "end": 21, + "type": "Element", + "name": "div", + "attributes": [ + { + "start": 5, + "end": 14, + "type": "Attribute", + "name": "class", + "value": [ + { + "start": 11, + "end": 14, + "type": "Text", + "data": "foo" + } + ] + } + ], + "children": [] + } + ] + }, + "css": null, + "js": null +} \ No newline at end of file diff --git a/test/parser/samples/attribute-unquoted/input-v2.html b/test/parser/samples/attribute-unquoted/input-v2.html new file mode 100644 index 0000000000..4bab0df72f --- /dev/null +++ b/test/parser/samples/attribute-unquoted/input-v2.html @@ -0,0 +1 @@ +
\ No newline at end of file diff --git a/test/parser/samples/attribute-unquoted/output-v2.json b/test/parser/samples/attribute-unquoted/output-v2.json new file mode 100644 index 0000000000..474d925b2e --- /dev/null +++ b/test/parser/samples/attribute-unquoted/output-v2.json @@ -0,0 +1,35 @@ +{ + "hash": 3488539025, + "html": { + "start": 0, + "end": 21, + "type": "Fragment", + "children": [ + { + "start": 0, + "end": 21, + "type": "Element", + "name": "div", + "attributes": [ + { + "start": 5, + "end": 14, + "type": "Attribute", + "name": "class", + "value": [ + { + "start": 11, + "end": 14, + "type": "Text", + "data": "foo" + } + ] + } + ], + "children": [] + } + ] + }, + "css": null, + "js": null +} \ No newline at end of file diff --git a/test/parser/samples/await-then-catch/_actual-v2.json b/test/parser/samples/await-then-catch/_actual-v2.json new file mode 100644 index 0000000000..cfe0ab8134 --- /dev/null +++ b/test/parser/samples/await-then-catch/_actual-v2.json @@ -0,0 +1,81 @@ +{ + "hash": "1rt0tho", + "html": { + "start": 0, + "end": 149, + "type": "Fragment", + "children": [ + { + "start": 0, + "end": 21, + "type": "Text", + "data": "{#await thePromise}\n\t" + }, + { + "start": 21, + "end": 38, + "type": "Element", + "name": "p", + "attributes": [], + "children": [ + { + "start": 24, + "end": 34, + "type": "Text", + "data": "loading..." + } + ] + }, + { + "start": 38, + "end": 57, + "type": "Text", + "data": "\n{:then theValue}\n\t" + }, + { + "start": 57, + "end": 87, + "type": "Element", + "name": "p", + "attributes": [], + "children": [ + { + "start": 60, + "end": 83, + "type": "Text", + "data": "the value is {theValue}" + } + ] + }, + { + "start": 87, + "end": 107, + "type": "Text", + "data": "\n{:catch theError}\n\t" + }, + { + "start": 107, + "end": 140, + "type": "Element", + "name": "p", + "attributes": [], + "children": [ + { + "start": 110, + "end": 136, + "type": "Text", + "data": "oh no! {theError.message}}" + } + ] + }, + { + "start": 140, + "end": 149, + "type": "Text", + "data": "\n{/await}" + } + ] + }, + "css": null, + "js": null +} \ No newline at end of file diff --git a/test/parser/samples/await-then-catch/input-v2.html b/test/parser/samples/await-then-catch/input-v2.html new file mode 100644 index 0000000000..b4038bec8c --- /dev/null +++ b/test/parser/samples/await-then-catch/input-v2.html @@ -0,0 +1,7 @@ +{#await thePromise} +

loading...

+{:then theValue} +

the value is {theValue}

+{:catch theError} +

oh no! {theError.message}}

+{/await} \ No newline at end of file diff --git a/test/parser/samples/await-then-catch/output-v2.json b/test/parser/samples/await-then-catch/output-v2.json new file mode 100644 index 0000000000..4f149e6a0c --- /dev/null +++ b/test/parser/samples/await-then-catch/output-v2.json @@ -0,0 +1,161 @@ +{ + "hash": 1040536517, + "html": { + "start": 0, + "end": 158, + "type": "Fragment", + "children": [ + { + "start": 0, + "end": 158, + "type": "AwaitBlock", + "expression": { + "type": "Identifier", + "start": 9, + "end": 19, + "name": "thePromise" + }, + "value": "theValue", + "error": "theError", + "pending": { + "start": 21, + "end": 41, + "type": "PendingBlock", + "children": [ + { + "start": 21, + "end": 23, + "type": "Text", + "data": "\n\t" + }, + { + "start": 23, + "end": 40, + "type": "Element", + "name": "p", + "attributes": [], + "children": [ + { + "start": 26, + "end": 36, + "type": "Text", + "data": "loading..." + } + ] + }, + { + "start": 40, + "end": 41, + "type": "Text", + "data": "\n" + } + ] + }, + "then": { + "start": 41, + "end": 93, + "type": "ThenBlock", + "children": [ + { + "start": 58, + "end": 60, + "type": "Text", + "data": "\n\t" + }, + { + "start": 60, + "end": 92, + "type": "Element", + "name": "p", + "attributes": [], + "children": [ + { + "start": 63, + "end": 76, + "type": "Text", + "data": "the value is " + }, + { + "start": 76, + "end": 88, + "type": "MustacheTag", + "expression": { + "type": "Identifier", + "start": 78, + "end": 86, + "name": "theValue" + } + } + ] + }, + { + "start": 92, + "end": 93, + "type": "Text", + "data": "\n" + } + ] + }, + "catch": { + "start": 93, + "end": 148, + "type": "CatchBlock", + "children": [ + { + "start": 111, + "end": 113, + "type": "Text", + "data": "\n\t" + }, + { + "start": 113, + "end": 147, + "type": "Element", + "name": "p", + "attributes": [], + "children": [ + { + "start": 116, + "end": 123, + "type": "Text", + "data": "oh no! " + }, + { + "start": 123, + "end": 143, + "type": "MustacheTag", + "expression": { + "type": "MemberExpression", + "start": 125, + "end": 141, + "object": { + "type": "Identifier", + "start": 125, + "end": 133, + "name": "theError" + }, + "property": { + "type": "Identifier", + "start": 134, + "end": 141, + "name": "message" + }, + "computed": false + } + } + ] + }, + { + "start": 147, + "end": 148, + "type": "Text", + "data": "\n" + } + ] + } + } + ] + }, + "css": null, + "js": null +} \ No newline at end of file diff --git a/test/parser/samples/binding-shorthand/_actual-v2.json b/test/parser/samples/binding-shorthand/_actual-v2.json new file mode 100644 index 0000000000..de159d6516 --- /dev/null +++ b/test/parser/samples/binding-shorthand/_actual-v2.json @@ -0,0 +1,33 @@ +{ + "hash": "1f31b7d", + "html": { + "start": 0, + "end": 18, + "type": "Fragment", + "children": [ + { + "start": 0, + "end": 18, + "type": "Element", + "name": "Widget", + "attributes": [ + { + "start": 8, + "end": 16, + "type": "Binding", + "name": "foo", + "value": { + "type": "Identifier", + "start": 13, + "end": 16, + "name": "foo" + } + } + ], + "children": [] + } + ] + }, + "css": null, + "js": null +} \ No newline at end of file diff --git a/test/parser/samples/binding-shorthand/input-v2.html b/test/parser/samples/binding-shorthand/input-v2.html new file mode 100644 index 0000000000..7f8116bdde --- /dev/null +++ b/test/parser/samples/binding-shorthand/input-v2.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/parser/samples/binding-shorthand/output-v2.json b/test/parser/samples/binding-shorthand/output-v2.json new file mode 100644 index 0000000000..8a7b615cf4 --- /dev/null +++ b/test/parser/samples/binding-shorthand/output-v2.json @@ -0,0 +1,33 @@ +{ + "hash": 3088875001, + "html": { + "start": 0, + "end": 18, + "type": "Fragment", + "children": [ + { + "start": 0, + "end": 18, + "type": "Element", + "name": "Widget", + "attributes": [ + { + "start": 8, + "end": 16, + "type": "Binding", + "name": "foo", + "value": { + "type": "Identifier", + "start": 13, + "end": 16, + "name": "foo" + } + } + ], + "children": [] + } + ] + }, + "css": null, + "js": null +} \ No newline at end of file diff --git a/test/parser/samples/binding/_actual-v2.json b/test/parser/samples/binding/_actual-v2.json new file mode 100644 index 0000000000..c124e9caf4 --- /dev/null +++ b/test/parser/samples/binding/_actual-v2.json @@ -0,0 +1,33 @@ +{ + "hash": "w1d13d", + "html": { + "start": 0, + "end": 25, + "type": "Fragment", + "children": [ + { + "start": 0, + "end": 25, + "type": "Element", + "name": "input", + "attributes": [ + { + "start": 7, + "end": 24, + "type": "Binding", + "name": "value", + "value": { + "type": "Identifier", + "start": 19, + "end": 23, + "name": "name" + } + } + ], + "children": [] + } + ] + }, + "css": null, + "js": null +} \ No newline at end of file diff --git a/test/parser/samples/binding/input-v2.html b/test/parser/samples/binding/input-v2.html new file mode 100644 index 0000000000..3af20a9ced --- /dev/null +++ b/test/parser/samples/binding/input-v2.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/parser/samples/binding/output-v2.json b/test/parser/samples/binding/output-v2.json new file mode 100644 index 0000000000..74f2059f59 --- /dev/null +++ b/test/parser/samples/binding/output-v2.json @@ -0,0 +1,33 @@ +{ + "hash": 1937205193, + "html": { + "start": 0, + "end": 25, + "type": "Fragment", + "children": [ + { + "start": 0, + "end": 25, + "type": "Element", + "name": "input", + "attributes": [ + { + "start": 7, + "end": 24, + "type": "Binding", + "name": "value", + "value": { + "type": "Identifier", + "start": 19, + "end": 23, + "name": "name" + } + } + ], + "children": [] + } + ] + }, + "css": null, + "js": null +} \ No newline at end of file diff --git a/test/parser/samples/comment/_actual-v2.json b/test/parser/samples/comment/_actual-v2.json new file mode 100644 index 0000000000..3dde7da39d --- /dev/null +++ b/test/parser/samples/comment/_actual-v2.json @@ -0,0 +1,18 @@ +{ + "hash": "1ihizni", + "html": { + "start": 0, + "end": 18, + "type": "Fragment", + "children": [ + { + "start": 0, + "end": 18, + "type": "Comment", + "data": " a comment " + } + ] + }, + "css": null, + "js": null +} \ No newline at end of file diff --git a/test/parser/samples/comment/input-v2.html b/test/parser/samples/comment/input-v2.html new file mode 100644 index 0000000000..3b3ffe3222 --- /dev/null +++ b/test/parser/samples/comment/input-v2.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/parser/samples/comment/output-v2.json b/test/parser/samples/comment/output-v2.json new file mode 100644 index 0000000000..e77c968b6b --- /dev/null +++ b/test/parser/samples/comment/output-v2.json @@ -0,0 +1,18 @@ +{ + "hash": 3294612990, + "html": { + "start": 0, + "end": 18, + "type": "Fragment", + "children": [ + { + "start": 0, + "end": 18, + "type": "Comment", + "data": " a comment " + } + ] + }, + "css": null, + "js": null +} \ No newline at end of file diff --git a/test/parser/samples/component-dynamic/_actual-v2.json b/test/parser/samples/component-dynamic/_actual-v2.json new file mode 100644 index 0000000000..9e6525a8ca --- /dev/null +++ b/test/parser/samples/component-dynamic/_actual-v2.json @@ -0,0 +1,68 @@ +{ + "hash": "7yh2k2", + "html": { + "start": 0, + "end": 55, + "type": "Fragment", + "children": [ + { + "start": 0, + "end": 55, + "type": "Element", + "name": "svelte:component", + "attributes": [ + { + "start": 18, + "end": 23, + "type": "Attribute", + "name": "{foo", + "value": true + }, + { + "start": 23, + "end": 25, + "type": "Attribute", + "name": "?", + "value": true + }, + { + "start": 25, + "end": 29, + "type": "Attribute", + "name": "Foo", + "value": true + }, + { + "start": 29, + "end": 30, + "type": "Attribute", + "name": "", + "value": [ + { + "type": "AttributeShorthand", + "start": 30, + "end": 30, + "expression": { + "type": "Identifier", + "start": 30, + "end": 30, + "name": "" + } + } + ] + }, + { + "start": 31, + "end": 35, + "type": "Attribute", + "name": "Bar}", + "value": true + } + ], + "children": [] + } + ] + }, + "css": null, + "js": null +} \ No newline at end of file diff --git a/test/parser/samples/component-dynamic/input-v2.html b/test/parser/samples/component-dynamic/input-v2.html new file mode 100644 index 0000000000..d692cce9b8 --- /dev/null +++ b/test/parser/samples/component-dynamic/input-v2.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/parser/samples/component-dynamic/output-v2.json b/test/parser/samples/component-dynamic/output-v2.json new file mode 100644 index 0000000000..614c28c0a9 --- /dev/null +++ b/test/parser/samples/component-dynamic/output-v2.json @@ -0,0 +1,43 @@ +{ + "hash": 410218696, + "html": { + "start": 0, + "end": 43, + "type": "Fragment", + "children": [ + { + "start": 0, + "end": 43, + "type": "Element", + "name": ":Component", + "attributes": [], + "children": [], + "expression": { + "type": "ConditionalExpression", + "start": 13, + "end": 28, + "test": { + "type": "Identifier", + "start": 13, + "end": 16, + "name": "foo" + }, + "consequent": { + "type": "Identifier", + "start": 19, + "end": 22, + "name": "Foo" + }, + "alternate": { + "type": "Identifier", + "start": 25, + "end": 28, + "name": "Bar" + } + } + } + ] + }, + "css": null, + "js": null +} \ No newline at end of file diff --git a/test/parser/samples/convert-entities-in-element/_actual-v2.json b/test/parser/samples/convert-entities-in-element/_actual-v2.json new file mode 100644 index 0000000000..4946333f3f --- /dev/null +++ b/test/parser/samples/convert-entities-in-element/_actual-v2.json @@ -0,0 +1,27 @@ +{ + "hash": "134kmw9", + "html": { + "start": 0, + "end": 24, + "type": "Fragment", + "children": [ + { + "start": 0, + "end": 24, + "type": "Element", + "name": "p", + "attributes": [], + "children": [ + { + "start": 3, + "end": 20, + "type": "Text", + "data": "Hello & World" + } + ] + } + ] + }, + "css": null, + "js": null +} \ No newline at end of file diff --git a/test/parser/samples/convert-entities-in-element/input-v2.html b/test/parser/samples/convert-entities-in-element/input-v2.html new file mode 100644 index 0000000000..f05dc391ad --- /dev/null +++ b/test/parser/samples/convert-entities-in-element/input-v2.html @@ -0,0 +1 @@ +

Hello & World

\ No newline at end of file diff --git a/test/parser/samples/convert-entities-in-element/output-v2.json b/test/parser/samples/convert-entities-in-element/output-v2.json new file mode 100644 index 0000000000..cb3e50ec3b --- /dev/null +++ b/test/parser/samples/convert-entities-in-element/output-v2.json @@ -0,0 +1,27 @@ +{ + "hash": 2365862121, + "html": { + "start": 0, + "end": 24, + "type": "Fragment", + "children": [ + { + "start": 0, + "end": 24, + "type": "Element", + "name": "p", + "attributes": [], + "children": [ + { + "start": 3, + "end": 20, + "type": "Text", + "data": "Hello & World" + } + ] + } + ] + }, + "css": null, + "js": null +} \ No newline at end of file diff --git a/test/parser/samples/convert-entities/_actual-v2.json b/test/parser/samples/convert-entities/_actual-v2.json new file mode 100644 index 0000000000..2a2deedc99 --- /dev/null +++ b/test/parser/samples/convert-entities/_actual-v2.json @@ -0,0 +1,18 @@ +{ + "hash": "2lbrq0", + "html": { + "start": 0, + "end": 17, + "type": "Fragment", + "children": [ + { + "start": 0, + "end": 17, + "type": "Text", + "data": "Hello & World" + } + ] + }, + "css": null, + "js": null +} \ No newline at end of file diff --git a/test/parser/samples/convert-entities/input-v2.html b/test/parser/samples/convert-entities/input-v2.html new file mode 100644 index 0000000000..161463ec58 --- /dev/null +++ b/test/parser/samples/convert-entities/input-v2.html @@ -0,0 +1 @@ +Hello & World \ No newline at end of file diff --git a/test/parser/samples/convert-entities/output-v2.json b/test/parser/samples/convert-entities/output-v2.json new file mode 100644 index 0000000000..479bae3064 --- /dev/null +++ b/test/parser/samples/convert-entities/output-v2.json @@ -0,0 +1,18 @@ +{ + "hash": 156753432, + "html": { + "start": 0, + "end": 17, + "type": "Fragment", + "children": [ + { + "start": 0, + "end": 17, + "type": "Text", + "data": "Hello & World" + } + ] + }, + "css": null, + "js": null +} \ No newline at end of file diff --git a/test/parser/samples/css-ref-selector/_actual-v2.json b/test/parser/samples/css-ref-selector/_actual-v2.json new file mode 100644 index 0000000000..5edf24cd19 --- /dev/null +++ b/test/parser/samples/css-ref-selector/_actual-v2.json @@ -0,0 +1,96 @@ +{ + "hash": "i9aush", + "html": { + "start": 0, + "end": 14, + "type": "Fragment", + "children": [ + { + "start": 0, + "end": 14, + "type": "Element", + "name": "div", + "attributes": [ + { + "start": 5, + "end": 12, + "type": "Ref", + "name": "foo" + } + ], + "children": [] + }, + { + "start": 14, + "end": 16, + "type": "Text", + "data": "\n\n" + } + ] + }, + "css": { + "start": 16, + "end": 60, + "attributes": [], + "children": [ + { + "type": "Rule", + "selector": { + "type": "SelectorList", + "children": [ + { + "type": "Selector", + "children": [ + { + "type": "RefSelector", + "start": 25, + "end": 32, + "name": "foo" + } + ], + "start": 25, + "end": 32 + } + ], + "start": 25, + "end": 32 + }, + "block": { + "type": "Block", + "children": [ + { + "type": "Declaration", + "important": false, + "property": "color", + "value": { + "type": "Value", + "children": [ + { + "type": "Identifier", + "name": "red", + "start": 44, + "end": 47 + } + ], + "start": 43, + "end": 47 + }, + "start": 37, + "end": 47 + } + ], + "start": 33, + "end": 51 + }, + "start": 25, + "end": 51 + } + ], + "content": { + "start": 23, + "end": 52, + "styles": "\n\tref:foo {\n\t\tcolor: red;\n\t}\n" + } + }, + "js": null +} \ No newline at end of file diff --git a/test/parser/samples/css-ref-selector/input-v2.html b/test/parser/samples/css-ref-selector/input-v2.html new file mode 100644 index 0000000000..696075f93f --- /dev/null +++ b/test/parser/samples/css-ref-selector/input-v2.html @@ -0,0 +1,7 @@ +
+ + \ No newline at end of file diff --git a/test/parser/samples/css-ref-selector/output-v2.json b/test/parser/samples/css-ref-selector/output-v2.json new file mode 100644 index 0000000000..2ddafc4aae --- /dev/null +++ b/test/parser/samples/css-ref-selector/output-v2.json @@ -0,0 +1,96 @@ +{ + "hash": 1104014177, + "html": { + "start": 0, + "end": 14, + "type": "Fragment", + "children": [ + { + "start": 0, + "end": 14, + "type": "Element", + "name": "div", + "attributes": [ + { + "start": 5, + "end": 12, + "type": "Ref", + "name": "foo" + } + ], + "children": [] + }, + { + "start": 14, + "end": 16, + "type": "Text", + "data": "\n\n" + } + ] + }, + "css": { + "start": 16, + "end": 60, + "attributes": [], + "children": [ + { + "type": "Rule", + "selector": { + "type": "SelectorList", + "children": [ + { + "type": "Selector", + "children": [ + { + "type": "RefSelector", + "start": 25, + "end": 32, + "name": "foo" + } + ], + "start": 25, + "end": 32 + } + ], + "start": 25, + "end": 32 + }, + "block": { + "type": "Block", + "children": [ + { + "type": "Declaration", + "important": false, + "property": "color", + "value": { + "type": "Value", + "children": [ + { + "type": "Identifier", + "name": "red", + "start": 44, + "end": 47 + } + ], + "start": 43, + "end": 47 + }, + "start": 37, + "end": 47 + } + ], + "start": 33, + "end": 51 + }, + "start": 25, + "end": 51 + } + ], + "content": { + "start": 23, + "end": 52, + "styles": "\n\tref:foo {\n\t\tcolor: red;\n\t}\n" + } + }, + "js": null +} \ No newline at end of file diff --git a/test/parser/samples/css/_actual-v2.json b/test/parser/samples/css/_actual-v2.json new file mode 100644 index 0000000000..316e6e72a5 --- /dev/null +++ b/test/parser/samples/css/_actual-v2.json @@ -0,0 +1,96 @@ +{ + "hash": "iz4x8b", + "html": { + "start": 0, + "end": 14, + "type": "Fragment", + "children": [ + { + "start": 0, + "end": 14, + "type": "Element", + "name": "div", + "attributes": [], + "children": [ + { + "start": 5, + "end": 8, + "type": "Text", + "data": "foo" + } + ] + }, + { + "start": 14, + "end": 16, + "type": "Text", + "data": "\n\n" + } + ] + }, + "css": { + "start": 16, + "end": 56, + "attributes": [], + "children": [ + { + "type": "Rule", + "selector": { + "type": "SelectorList", + "children": [ + { + "type": "Selector", + "children": [ + { + "type": "TypeSelector", + "name": "div", + "start": 25, + "end": 28 + } + ], + "start": 25, + "end": 28 + } + ], + "start": 25, + "end": 28 + }, + "block": { + "type": "Block", + "children": [ + { + "type": "Declaration", + "important": false, + "property": "color", + "value": { + "type": "Value", + "children": [ + { + "type": "Identifier", + "name": "red", + "start": 40, + "end": 43 + } + ], + "start": 39, + "end": 43 + }, + "start": 33, + "end": 43 + } + ], + "start": 29, + "end": 47 + }, + "start": 25, + "end": 47 + } + ], + "content": { + "start": 23, + "end": 48, + "styles": "\n\tdiv {\n\t\tcolor: red;\n\t}\n" + } + }, + "js": null +} \ No newline at end of file diff --git a/test/parser/samples/css/input-v2.html b/test/parser/samples/css/input-v2.html new file mode 100644 index 0000000000..a573bcf778 --- /dev/null +++ b/test/parser/samples/css/input-v2.html @@ -0,0 +1,7 @@ +
foo
+ + \ No newline at end of file diff --git a/test/parser/samples/css/output-v2.json b/test/parser/samples/css/output-v2.json new file mode 100644 index 0000000000..4650ccea46 --- /dev/null +++ b/test/parser/samples/css/output-v2.json @@ -0,0 +1,96 @@ +{ + "hash": 1147407419, + "html": { + "start": 0, + "end": 14, + "type": "Fragment", + "children": [ + { + "start": 0, + "end": 14, + "type": "Element", + "name": "div", + "attributes": [], + "children": [ + { + "start": 5, + "end": 8, + "type": "Text", + "data": "foo" + } + ] + }, + { + "start": 14, + "end": 16, + "type": "Text", + "data": "\n\n" + } + ] + }, + "css": { + "start": 16, + "end": 56, + "attributes": [], + "children": [ + { + "type": "Rule", + "selector": { + "type": "SelectorList", + "children": [ + { + "type": "Selector", + "children": [ + { + "type": "TypeSelector", + "name": "div", + "start": 25, + "end": 28 + } + ], + "start": 25, + "end": 28 + } + ], + "start": 25, + "end": 28 + }, + "block": { + "type": "Block", + "children": [ + { + "type": "Declaration", + "important": false, + "property": "color", + "value": { + "type": "Value", + "children": [ + { + "type": "Identifier", + "name": "red", + "start": 40, + "end": 43 + } + ], + "start": 39, + "end": 43 + }, + "start": 33, + "end": 43 + } + ], + "start": 29, + "end": 47 + }, + "start": 25, + "end": 47 + } + ], + "content": { + "start": 23, + "end": 48, + "styles": "\n\tdiv {\n\t\tcolor: red;\n\t}\n" + } + }, + "js": null +} \ No newline at end of file diff --git a/test/parser/samples/dynamic-import/_actual-v2.json b/test/parser/samples/dynamic-import/_actual-v2.json new file mode 100644 index 0000000000..5a1b7b0680 --- /dev/null +++ b/test/parser/samples/dynamic-import/_actual-v2.json @@ -0,0 +1,182 @@ +{ + "hash": "uvuf1h", + "html": { + "start": null, + "end": null, + "type": "Fragment", + "children": [] + }, + "css": null, + "js": { + "start": 0, + "end": 131, + "attributes": [], + "content": { + "type": "Program", + "start": 8, + "end": 122, + "body": [ + { + "type": "ExportDefaultDeclaration", + "start": 10, + "end": 121, + "declaration": { + "type": "ObjectExpression", + "start": 25, + "end": 121, + "properties": [ + { + "type": "Property", + "start": 29, + "end": 118, + "method": true, + "shorthand": false, + "computed": false, + "key": { + "type": "Identifier", + "start": 29, + "end": 37, + "name": "oncreate" + }, + "kind": "init", + "value": { + "type": "FunctionExpression", + "start": 37, + "end": 118, + "id": null, + "generator": false, + "expression": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 40, + "end": 118, + "body": [ + { + "type": "ExpressionStatement", + "start": 45, + "end": 114, + "expression": { + "type": "CallExpression", + "start": 45, + "end": 113, + "callee": { + "type": "MemberExpression", + "start": 45, + "end": 68, + "object": { + "type": "CallExpression", + "start": 45, + "end": 63, + "callee": { + "type": "Import", + "start": 45, + "end": 51 + }, + "arguments": [ + { + "type": "Literal", + "start": 52, + "end": 62, + "value": "./foo.js", + "raw": "'./foo.js'" + } + ] + }, + "property": { + "type": "Identifier", + "start": 64, + "end": 68, + "name": "then" + }, + "computed": false + }, + "arguments": [ + { + "type": "ArrowFunctionExpression", + "start": 69, + "end": 112, + "id": null, + "generator": false, + "expression": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 69, + "end": 72, + "name": "foo" + } + ], + "body": { + "type": "BlockStatement", + "start": 76, + "end": 112, + "body": [ + { + "type": "ExpressionStatement", + "start": 82, + "end": 107, + "expression": { + "type": "CallExpression", + "start": 82, + "end": 106, + "callee": { + "type": "MemberExpression", + "start": 82, + "end": 93, + "object": { + "type": "Identifier", + "start": 82, + "end": 89, + "name": "console" + }, + "property": { + "type": "Identifier", + "start": 90, + "end": 93, + "name": "log" + }, + "computed": false + }, + "arguments": [ + { + "type": "MemberExpression", + "start": 94, + "end": 105, + "object": { + "type": "Identifier", + "start": 94, + "end": 97, + "name": "foo" + }, + "property": { + "type": "Identifier", + "start": 98, + "end": 105, + "name": "default" + }, + "computed": false + } + ] + } + } + ] + } + } + ] + } + } + ] + } + } + } + ] + } + } + ], + "sourceType": "module" + } + } +} \ No newline at end of file diff --git a/test/parser/samples/dynamic-import/input-v2.html b/test/parser/samples/dynamic-import/input-v2.html new file mode 100644 index 0000000000..553ca6c38c --- /dev/null +++ b/test/parser/samples/dynamic-import/input-v2.html @@ -0,0 +1,9 @@ + \ No newline at end of file diff --git a/test/parser/samples/dynamic-import/output-v2.json b/test/parser/samples/dynamic-import/output-v2.json new file mode 100644 index 0000000000..b27a780a58 --- /dev/null +++ b/test/parser/samples/dynamic-import/output-v2.json @@ -0,0 +1,182 @@ +{ + "hash": 1867472549, + "html": { + "start": null, + "end": null, + "type": "Fragment", + "children": [] + }, + "css": null, + "js": { + "start": 0, + "end": 131, + "attributes": [], + "content": { + "type": "Program", + "start": 8, + "end": 122, + "body": [ + { + "type": "ExportDefaultDeclaration", + "start": 10, + "end": 121, + "declaration": { + "type": "ObjectExpression", + "start": 25, + "end": 121, + "properties": [ + { + "type": "Property", + "start": 29, + "end": 118, + "method": true, + "shorthand": false, + "computed": false, + "key": { + "type": "Identifier", + "start": 29, + "end": 37, + "name": "oncreate" + }, + "kind": "init", + "value": { + "type": "FunctionExpression", + "start": 37, + "end": 118, + "id": null, + "generator": false, + "expression": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 40, + "end": 118, + "body": [ + { + "type": "ExpressionStatement", + "start": 45, + "end": 114, + "expression": { + "type": "CallExpression", + "start": 45, + "end": 113, + "callee": { + "type": "MemberExpression", + "start": 45, + "end": 68, + "object": { + "type": "CallExpression", + "start": 45, + "end": 63, + "callee": { + "type": "Import", + "start": 45, + "end": 51 + }, + "arguments": [ + { + "type": "Literal", + "start": 52, + "end": 62, + "value": "./foo.js", + "raw": "'./foo.js'" + } + ] + }, + "property": { + "type": "Identifier", + "start": 64, + "end": 68, + "name": "then" + }, + "computed": false + }, + "arguments": [ + { + "type": "ArrowFunctionExpression", + "start": 69, + "end": 112, + "id": null, + "generator": false, + "expression": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 69, + "end": 72, + "name": "foo" + } + ], + "body": { + "type": "BlockStatement", + "start": 76, + "end": 112, + "body": [ + { + "type": "ExpressionStatement", + "start": 82, + "end": 107, + "expression": { + "type": "CallExpression", + "start": 82, + "end": 106, + "callee": { + "type": "MemberExpression", + "start": 82, + "end": 93, + "object": { + "type": "Identifier", + "start": 82, + "end": 89, + "name": "console" + }, + "property": { + "type": "Identifier", + "start": 90, + "end": 93, + "name": "log" + }, + "computed": false + }, + "arguments": [ + { + "type": "MemberExpression", + "start": 94, + "end": 105, + "object": { + "type": "Identifier", + "start": 94, + "end": 97, + "name": "foo" + }, + "property": { + "type": "Identifier", + "start": 98, + "end": 105, + "name": "default" + }, + "computed": false + } + ] + } + } + ] + } + } + ] + } + } + ] + } + } + } + ] + } + } + ], + "sourceType": "module" + } + } +} \ No newline at end of file diff --git a/test/parser/samples/each-block-destructured/_actual-v2.json b/test/parser/samples/each-block-destructured/_actual-v2.json new file mode 100644 index 0000000000..97b69a5730 --- /dev/null +++ b/test/parser/samples/each-block-destructured/_actual-v2.json @@ -0,0 +1,39 @@ +{ + "hash": "gtdm5e", + "html": { + "start": 0, + "end": 62, + "type": "Fragment", + "children": [ + { + "start": 0, + "end": 33, + "type": "Text", + "data": "{#each animals as [key, value]}\n\t" + }, + { + "start": 33, + "end": 54, + "type": "Element", + "name": "p", + "attributes": [], + "children": [ + { + "start": 36, + "end": 50, + "type": "Text", + "data": "{key}: {value}" + } + ] + }, + { + "start": 54, + "end": 62, + "type": "Text", + "data": "\n{/each}" + } + ] + }, + "css": null, + "js": null +} \ No newline at end of file diff --git a/test/parser/samples/each-block-destructured/input-v2.html b/test/parser/samples/each-block-destructured/input-v2.html new file mode 100644 index 0000000000..4ddf33ef85 --- /dev/null +++ b/test/parser/samples/each-block-destructured/input-v2.html @@ -0,0 +1,3 @@ +{#each animals as [key, value]} +

{key}: {value}

+{/each} diff --git a/test/parser/samples/each-block-destructured/output-v2.json b/test/parser/samples/each-block-destructured/output-v2.json new file mode 100644 index 0000000000..897fec88b8 --- /dev/null +++ b/test/parser/samples/each-block-destructured/output-v2.json @@ -0,0 +1,67 @@ +{ + "hash": 2621498076, + "html": { + "start": 0, + "end": 70, + "type": "Fragment", + "children": [ + { + "start": 0, + "end": 70, + "type": "EachBlock", + "expression": { + "type": "Identifier", + "start": 8, + "end": 15, + "name": "animals" + }, + "children": [ + { + "start": 35, + "end": 60, + "type": "Element", + "name": "p", + "attributes": [], + "children": [ + { + "start": 38, + "end": 45, + "type": "MustacheTag", + "expression": { + "type": "Identifier", + "start": 40, + "end": 43, + "name": "key" + } + }, + { + "start": 45, + "end": 47, + "type": "Text", + "data": ": " + }, + { + "start": 47, + "end": 56, + "type": "MustacheTag", + "expression": { + "type": "Identifier", + "start": 49, + "end": 54, + "name": "value" + } + } + ] + } + ], + "destructuredContexts": [ + "key", + "value" + ], + "context": "key_value" + } + ] + }, + "css": null, + "js": null +} \ No newline at end of file diff --git a/test/parser/samples/each-block-else/_actual-v2.json b/test/parser/samples/each-block-else/_actual-v2.json new file mode 100644 index 0000000000..af7b618bf8 --- /dev/null +++ b/test/parser/samples/each-block-else/_actual-v2.json @@ -0,0 +1,60 @@ +{ + "hash": "ljl07n", + "html": { + "start": 0, + "end": 77, + "type": "Fragment", + "children": [ + { + "start": 0, + "end": 27, + "type": "Text", + "data": "{#each animals as animal}\n\t" + }, + { + "start": 27, + "end": 42, + "type": "Element", + "name": "p", + "attributes": [], + "children": [ + { + "start": 30, + "end": 38, + "type": "Text", + "data": "{animal}" + } + ] + }, + { + "start": 42, + "end": 52, + "type": "Text", + "data": "\n{:else}\n\t" + }, + { + "start": 52, + "end": 69, + "type": "Element", + "name": "p", + "attributes": [], + "children": [ + { + "start": 55, + "end": 65, + "type": "Text", + "data": "no animals" + } + ] + }, + { + "start": 69, + "end": 77, + "type": "Text", + "data": "\n{/each}" + } + ] + }, + "css": null, + "js": null +} \ No newline at end of file diff --git a/test/parser/samples/each-block-else/input-v2.html b/test/parser/samples/each-block-else/input-v2.html new file mode 100644 index 0000000000..dc96d8b946 --- /dev/null +++ b/test/parser/samples/each-block-else/input-v2.html @@ -0,0 +1,5 @@ +{#each animals as animal} +

{animal}

+{:else} +

no animals

+{/each} diff --git a/test/parser/samples/each-block-else/output-v2.json b/test/parser/samples/each-block-else/output-v2.json new file mode 100644 index 0000000000..0dadad5f65 --- /dev/null +++ b/test/parser/samples/each-block-else/output-v2.json @@ -0,0 +1,68 @@ +{ + "hash": 3238289871, + "html": { + "start": 0, + "end": 84, + "type": "Fragment", + "children": [ + { + "start": 0, + "end": 84, + "type": "EachBlock", + "expression": { + "type": "Identifier", + "start": 8, + "end": 15, + "name": "animals" + }, + "children": [ + { + "start": 29, + "end": 46, + "type": "Element", + "name": "p", + "attributes": [], + "children": [ + { + "start": 32, + "end": 42, + "type": "MustacheTag", + "expression": { + "type": "Identifier", + "start": 34, + "end": 40, + "name": "animal" + } + } + ] + } + ], + "context": "animal", + "else": { + "start": 55, + "end": 75, + "type": "ElseBlock", + "children": [ + { + "start": 57, + "end": 74, + "type": "Element", + "name": "p", + "attributes": [], + "children": [ + { + "start": 60, + "end": 70, + "type": "Text", + "data": "no animals" + } + ] + } + ] + } + } + ] + }, + "css": null, + "js": null +} \ No newline at end of file diff --git a/test/parser/samples/each-block-indexed/_actual-v2.json b/test/parser/samples/each-block-indexed/_actual-v2.json new file mode 100644 index 0000000000..576bc53014 --- /dev/null +++ b/test/parser/samples/each-block-indexed/_actual-v2.json @@ -0,0 +1,39 @@ +{ + "hash": "1143n2g", + "html": { + "start": 0, + "end": 58, + "type": "Fragment", + "children": [ + { + "start": 0, + "end": 30, + "type": "Text", + "data": "{#each animals as animal, i}\n\t" + }, + { + "start": 30, + "end": 50, + "type": "Element", + "name": "p", + "attributes": [], + "children": [ + { + "start": 33, + "end": 46, + "type": "Text", + "data": "{i}: {animal}" + } + ] + }, + { + "start": 50, + "end": 58, + "type": "Text", + "data": "\n{/each}" + } + ] + }, + "css": null, + "js": null +} \ No newline at end of file diff --git a/test/parser/samples/each-block-indexed/input-v2.html b/test/parser/samples/each-block-indexed/input-v2.html new file mode 100644 index 0000000000..d5602ec82c --- /dev/null +++ b/test/parser/samples/each-block-indexed/input-v2.html @@ -0,0 +1,3 @@ +{#each animals as animal, i} +

{i}: {animal}

+{/each} diff --git a/test/parser/samples/each-block-indexed/output-v2.json b/test/parser/samples/each-block-indexed/output-v2.json new file mode 100644 index 0000000000..fc8954d6ad --- /dev/null +++ b/test/parser/samples/each-block-indexed/output-v2.json @@ -0,0 +1,64 @@ +{ + "hash": 2841674990, + "html": { + "start": 0, + "end": 66, + "type": "Fragment", + "children": [ + { + "start": 0, + "end": 66, + "type": "EachBlock", + "expression": { + "type": "Identifier", + "start": 8, + "end": 15, + "name": "animals" + }, + "children": [ + { + "start": 32, + "end": 56, + "type": "Element", + "name": "p", + "attributes": [], + "children": [ + { + "start": 35, + "end": 40, + "type": "MustacheTag", + "expression": { + "type": "Identifier", + "start": 37, + "end": 38, + "name": "i" + } + }, + { + "start": 40, + "end": 42, + "type": "Text", + "data": ": " + }, + { + "start": 42, + "end": 52, + "type": "MustacheTag", + "expression": { + "type": "Identifier", + "start": 44, + "end": 50, + "name": "animal" + } + } + ] + } + ], + "context": "animal", + "index": "i" + } + ] + }, + "css": null, + "js": null +} \ No newline at end of file diff --git a/test/parser/samples/each-block-keyed/_actual-v2.json b/test/parser/samples/each-block-keyed/_actual-v2.json new file mode 100644 index 0000000000..c039c98ce9 --- /dev/null +++ b/test/parser/samples/each-block-keyed/_actual-v2.json @@ -0,0 +1,39 @@ +{ + "hash": "3sm0ec", + "html": { + "start": 0, + "end": 56, + "type": "Fragment", + "children": [ + { + "start": 0, + "end": 35, + "type": "Text", + "data": "{#each todos as todo key todo.id}\n\t" + }, + { + "start": 35, + "end": 48, + "type": "Element", + "name": "p", + "attributes": [], + "children": [ + { + "start": 38, + "end": 44, + "type": "Text", + "data": "{todo}" + } + ] + }, + { + "start": 48, + "end": 56, + "type": "Text", + "data": "\n{/each}" + } + ] + }, + "css": null, + "js": null +} \ No newline at end of file diff --git a/test/parser/samples/each-block-keyed/input-v2.html b/test/parser/samples/each-block-keyed/input-v2.html new file mode 100644 index 0000000000..3cc00ce93e --- /dev/null +++ b/test/parser/samples/each-block-keyed/input-v2.html @@ -0,0 +1,3 @@ +{#each todos as todo key todo.id} +

{todo}

+{/each} diff --git a/test/parser/samples/each-block-keyed/output-v2.json b/test/parser/samples/each-block-keyed/output-v2.json new file mode 100644 index 0000000000..1a16afb82b --- /dev/null +++ b/test/parser/samples/each-block-keyed/output-v2.json @@ -0,0 +1,47 @@ +{ + "hash": 2025411181, + "html": { + "start": 0, + "end": 54, + "type": "Fragment", + "children": [ + { + "start": 0, + "end": 54, + "type": "EachBlock", + "expression": { + "type": "Identifier", + "start": 8, + "end": 13, + "name": "todos" + }, + "children": [ + { + "start": 29, + "end": 44, + "type": "Element", + "name": "p", + "attributes": [], + "children": [ + { + "start": 32, + "end": 40, + "type": "MustacheTag", + "expression": { + "type": "Identifier", + "start": 34, + "end": 38, + "name": "todo" + } + } + ] + } + ], + "context": "todo", + "key": "id" + } + ] + }, + "css": null, + "js": null +} \ No newline at end of file diff --git a/test/parser/samples/each-block/_actual-v2.json b/test/parser/samples/each-block/_actual-v2.json new file mode 100644 index 0000000000..314ef918a5 --- /dev/null +++ b/test/parser/samples/each-block/_actual-v2.json @@ -0,0 +1,39 @@ +{ + "hash": "mzeq0s", + "html": { + "start": 0, + "end": 50, + "type": "Fragment", + "children": [ + { + "start": 0, + "end": 27, + "type": "Text", + "data": "{#each animals as animal}\n\t" + }, + { + "start": 27, + "end": 42, + "type": "Element", + "name": "p", + "attributes": [], + "children": [ + { + "start": 30, + "end": 38, + "type": "Text", + "data": "{animal}" + } + ] + }, + { + "start": 42, + "end": 50, + "type": "Text", + "data": "\n{/each}" + } + ] + }, + "css": null, + "js": null +} \ No newline at end of file diff --git a/test/parser/samples/each-block/input-v2.html b/test/parser/samples/each-block/input-v2.html new file mode 100644 index 0000000000..83a5e88ddd --- /dev/null +++ b/test/parser/samples/each-block/input-v2.html @@ -0,0 +1,3 @@ +{#each animals as animal} +

{animal}

+{/each} diff --git a/test/parser/samples/each-block/output-v2.json b/test/parser/samples/each-block/output-v2.json new file mode 100644 index 0000000000..e549faca39 --- /dev/null +++ b/test/parser/samples/each-block/output-v2.json @@ -0,0 +1,46 @@ +{ + "hash": 220340986, + "html": { + "start": 0, + "end": 56, + "type": "Fragment", + "children": [ + { + "start": 0, + "end": 56, + "type": "EachBlock", + "expression": { + "type": "Identifier", + "start": 8, + "end": 15, + "name": "animals" + }, + "children": [ + { + "start": 29, + "end": 46, + "type": "Element", + "name": "p", + "attributes": [], + "children": [ + { + "start": 32, + "end": 42, + "type": "MustacheTag", + "expression": { + "type": "Identifier", + "start": 34, + "end": 40, + "name": "animal" + } + } + ] + } + ], + "context": "animal" + } + ] + }, + "css": null, + "js": null +} \ No newline at end of file diff --git a/test/parser/samples/element-with-mustache/_actual-v2.json b/test/parser/samples/element-with-mustache/_actual-v2.json new file mode 100644 index 0000000000..a65459a200 --- /dev/null +++ b/test/parser/samples/element-with-mustache/_actual-v2.json @@ -0,0 +1,44 @@ +{ + "hash": "9fs56", + "html": { + "start": 0, + "end": 22, + "type": "Fragment", + "children": [ + { + "start": 0, + "end": 22, + "type": "Element", + "name": "h1", + "attributes": [], + "children": [ + { + "start": 4, + "end": 10, + "type": "Text", + "data": "hello " + }, + { + "start": 10, + "end": 16, + "type": "MustacheTag", + "expression": { + "type": "Identifier", + "start": 11, + "end": 15, + "name": "name" + } + }, + { + "start": 16, + "end": 17, + "type": "Text", + "data": "!" + } + ] + } + ] + }, + "css": null, + "js": null +} \ No newline at end of file diff --git a/test/parser/samples/element-with-mustache/input-v2.html b/test/parser/samples/element-with-mustache/input-v2.html new file mode 100644 index 0000000000..1e9232da02 --- /dev/null +++ b/test/parser/samples/element-with-mustache/input-v2.html @@ -0,0 +1 @@ +

hello {name}!

diff --git a/test/parser/samples/element-with-mustache/output-v2.json b/test/parser/samples/element-with-mustache/output-v2.json new file mode 100644 index 0000000000..76e71dc327 --- /dev/null +++ b/test/parser/samples/element-with-mustache/output-v2.json @@ -0,0 +1,44 @@ +{ + "hash": 1265376132, + "html": { + "start": 0, + "end": 22, + "type": "Fragment", + "children": [ + { + "start": 0, + "end": 22, + "type": "Element", + "name": "h1", + "attributes": [], + "children": [ + { + "start": 4, + "end": 10, + "type": "Text", + "data": "hello " + }, + { + "start": 10, + "end": 16, + "type": "MustacheTag", + "expression": { + "type": "Identifier", + "start": 11, + "end": 15, + "name": "name" + } + }, + { + "start": 16, + "end": 17, + "type": "Text", + "data": "!" + } + ] + } + ] + }, + "css": null, + "js": null +} \ No newline at end of file diff --git a/test/parser/samples/element-with-text/_actual-v2.json b/test/parser/samples/element-with-text/_actual-v2.json new file mode 100644 index 0000000000..ee940e82e7 --- /dev/null +++ b/test/parser/samples/element-with-text/_actual-v2.json @@ -0,0 +1,27 @@ +{ + "hash": "a3xqjm", + "html": { + "start": 0, + "end": 17, + "type": "Fragment", + "children": [ + { + "start": 0, + "end": 17, + "type": "Element", + "name": "span", + "attributes": [], + "children": [ + { + "start": 6, + "end": 10, + "type": "Text", + "data": "test" + } + ] + } + ] + }, + "css": null, + "js": null +} \ No newline at end of file diff --git a/test/parser/samples/element-with-text/input-v2.html b/test/parser/samples/element-with-text/input-v2.html new file mode 100644 index 0000000000..fcf3199655 --- /dev/null +++ b/test/parser/samples/element-with-text/input-v2.html @@ -0,0 +1 @@ +test \ No newline at end of file diff --git a/test/parser/samples/element-with-text/output-v2.json b/test/parser/samples/element-with-text/output-v2.json new file mode 100644 index 0000000000..22cae35547 --- /dev/null +++ b/test/parser/samples/element-with-text/output-v2.json @@ -0,0 +1,27 @@ +{ + "hash": 611274658, + "html": { + "start": 0, + "end": 17, + "type": "Fragment", + "children": [ + { + "start": 0, + "end": 17, + "type": "Element", + "name": "span", + "attributes": [], + "children": [ + { + "start": 6, + "end": 10, + "type": "Text", + "data": "test" + } + ] + } + ] + }, + "css": null, + "js": null +} \ No newline at end of file diff --git a/test/parser/samples/elements/_actual-v2.json b/test/parser/samples/elements/_actual-v2.json new file mode 100644 index 0000000000..14de5ea00d --- /dev/null +++ b/test/parser/samples/elements/_actual-v2.json @@ -0,0 +1,28 @@ +{ + "hash": "dni3s5", + "html": { + "start": 0, + "end": 15, + "type": "Fragment", + "children": [ + { + "start": 0, + "end": 15, + "type": "Element", + "name": "!doctype", + "attributes": [ + { + "start": 10, + "end": 14, + "type": "Attribute", + "name": "html", + "value": true + } + ], + "children": [] + } + ] + }, + "css": null, + "js": null +} \ No newline at end of file diff --git a/test/parser/samples/elements/input-v2.html b/test/parser/samples/elements/input-v2.html new file mode 100644 index 0000000000..937d25b42e --- /dev/null +++ b/test/parser/samples/elements/input-v2.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/parser/samples/elements/output-v2.json b/test/parser/samples/elements/output-v2.json new file mode 100644 index 0000000000..7b4e6bffe1 --- /dev/null +++ b/test/parser/samples/elements/output-v2.json @@ -0,0 +1,28 @@ +{ + "hash": 825536165, + "html": { + "start": 0, + "end": 15, + "type": "Fragment", + "children": [ + { + "start": 0, + "end": 15, + "type": "Element", + "name": "!doctype", + "attributes": [ + { + "start": 10, + "end": 14, + "type": "Attribute", + "name": "html", + "value": true + } + ], + "children": [] + } + ] + }, + "css": null, + "js": null +} \ No newline at end of file diff --git a/test/parser/samples/error-binding-disabled/input-v2.html b/test/parser/samples/error-binding-disabled/input-v2.html new file mode 100644 index 0000000000..3af20a9ced --- /dev/null +++ b/test/parser/samples/error-binding-disabled/input-v2.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/parser/samples/error-binding-mustaches/input-v2.html b/test/parser/samples/error-binding-mustaches/input-v2.html new file mode 100644 index 0000000000..2629696c9e --- /dev/null +++ b/test/parser/samples/error-binding-mustaches/input-v2.html @@ -0,0 +1 @@ + diff --git a/test/parser/samples/error-binding-rvalue/input-v2.html b/test/parser/samples/error-binding-rvalue/input-v2.html new file mode 100644 index 0000000000..0b1f716c23 --- /dev/null +++ b/test/parser/samples/error-binding-rvalue/input-v2.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/parser/samples/error-comment-unclosed/input-v2.html b/test/parser/samples/error-comment-unclosed/input-v2.html new file mode 100644 index 0000000000..fe6d748e1b --- /dev/null +++ b/test/parser/samples/error-comment-unclosed/input-v2.html @@ -0,0 +1 @@ +