From af6167a998acac3fee33d147739b129d2ba63d08 Mon Sep 17 00:00:00 2001 From: Richard Harris Date: Sun, 27 Jan 2019 11:10:23 -0500 Subject: [PATCH] reshape ast --- src/compile/Component.ts | 66 +--- src/compile/css/Stylesheet.ts | 6 +- src/compile/nodes/shared/Expression.ts | 2 +- src/compile/render-dom/index.ts | 6 +- src/compile/render-ssr/index.ts | 2 +- src/interfaces.ts | 3 +- src/parse/acorn.ts | 4 +- src/parse/index.ts | 22 +- src/parse/read/script.ts | 25 +- test/parser/index.js | 3 +- .../samples/action-with-call/output.json | 5 +- .../action-with-identifier/output.json | 5 +- .../samples/action-with-literal/output.json | 5 +- test/parser/samples/action/output.json | 5 +- test/parser/samples/animation/output.json | 5 +- .../attribute-containing-solidus/output.json | 5 +- .../attribute-dynamic-boolean/output.json | 5 +- .../attribute-dynamic-reserved/output.json | 5 +- .../samples/attribute-dynamic/output.json | 5 +- .../samples/attribute-escaped/output.json | 5 +- .../samples/attribute-multiple/output.json | 5 +- .../samples/attribute-shorthand/output.json | 5 +- .../attribute-static-boolean/output.json | 5 +- .../samples/attribute-static/output.json | 5 +- .../samples/attribute-unquoted/output.json | 5 +- .../samples/await-then-catch/output.json | 5 +- .../samples/binding-shorthand/output.json | 5 +- test/parser/samples/binding/output.json | 5 +- test/parser/samples/comment/output.json | 5 +- .../samples/component-dynamic/output.json | 5 +- .../convert-entities-in-element/output.json | 5 +- .../samples/convert-entities/output.json | 5 +- test/parser/samples/css/output.json | 117 ++++--- .../parser/samples/dynamic-import/output.json | 328 +++++++++--------- .../each-block-destructured/output.json | 5 +- .../samples/each-block-else/output.json | 5 +- .../samples/each-block-indexed/output.json | 5 +- .../samples/each-block-keyed/output.json | 5 +- test/parser/samples/each-block/output.json | 5 +- .../samples/element-with-mustache/output.json | 5 +- .../samples/element-with-text/output.json | 5 +- test/parser/samples/elements/output.json | 5 +- test/parser/samples/event-handler/output.json | 5 +- test/parser/samples/if-block-else/output.json | 5 +- .../samples/if-block-elseif/output.json | 5 +- test/parser/samples/if-block/output.json | 5 +- .../samples/implicitly-closed-li/output.json | 5 +- test/parser/samples/nbsp/output.json | 5 +- test/parser/samples/raw-mustaches/output.json | 5 +- test/parser/samples/refs/output.json | 5 +- .../samples/script-comment-only/output.json | 25 +- .../output.json | 73 ++-- .../script-comment-trailing/output.json | 73 ++-- test/parser/samples/script/output.json | 73 ++-- .../samples/self-closing-element/output.json | 5 +- .../parser/samples/self-reference/output.json | 5 +- .../space-between-mustaches/output.json | 5 +- test/parser/samples/spread/output.json | 5 +- .../samples/textarea-children/output.json | 5 +- .../transition-intro-no-params/output.json | 5 +- .../samples/transition-intro/output.json | 5 +- .../samples/unusual-identifier/output.json | 5 +- .../whitespace-leading-trailing/output.json | 5 +- .../samples/whitespace-normal/output.json | 5 +- test/parser/samples/yield/output.json | 5 +- .../errors.json | 6 +- .../errors.json | 6 +- .../script-invalid-context/errors.json | 4 +- 68 files changed, 560 insertions(+), 529 deletions(-) diff --git a/src/compile/Component.ts b/src/compile/Component.ts index c7ca6b7feb..6dcf84d4dd 100644 --- a/src/compile/Component.ts +++ b/src/compile/Component.ts @@ -56,9 +56,6 @@ export default class Component { namespace: string; tag: string; - instance_script: Node; - module_script: Node; - imports: Node[] = []; module_javascript: string; javascript: string; @@ -122,26 +119,6 @@ export default class Component { this.stylesheet = new Stylesheet(source, ast, options.filename, options.dev); this.stylesheet.validate(this); - const module_scripts = ast.js.filter(script => this.get_context(script) === 'module'); - const instance_scripts = ast.js.filter(script => this.get_context(script) === 'default'); - - if (module_scripts.length > 1) { - this.error(module_scripts[1], { - code: `invalid-script`, - message: `A component can only have one '; +function get_context(parser: Parser, attributes: Node[], start: number) { + const context = attributes.find(attribute => attribute.name === 'context'); + if (!context) return 'default'; + + if (context.value.length !== 1 || context.value[0].type !== 'Text') { + parser.error({ + code: 'invalid-script', + message: `context attribute must be static` + }, start); + } + + const value = context.value[0].data; + + if (value !== 'module') { + parser.error({ + code: `invalid-script`, + message: `If the context attribute is supplied, its value must be "module"` + }, context.start); + } + + return value; +} + export default function readScript(parser: Parser, start: number, attributes: Node[]) { const scriptStart = parser.index; const scriptEnd = parser.template.indexOf(scriptClosingTag, scriptStart); @@ -30,7 +53,7 @@ export default function readScript(parser: Parser, start: number, attributes: No return { start, end: parser.index, - attributes, + context: get_context(parser, attributes, start), content: ast, }; } diff --git a/test/parser/index.js b/test/parser/index.js index 8f20c77abd..900cc3ae05 100644 --- a/test/parser/index.js +++ b/test/parser/index.js @@ -31,7 +31,8 @@ describe('parse', () => { assert.deepEqual(ast.html, expectedOutput.html); assert.deepEqual(ast.css, expectedOutput.css); - assert.deepEqual(ast.js, expectedOutput.js); + assert.deepEqual(ast.instance, expectedOutput.instance); + assert.deepEqual(ast.module, expectedOutput.module); } catch (err) { if (err.name !== 'ParseError') throw err; if (!expectedError) throw err; diff --git a/test/parser/samples/action-with-call/output.json b/test/parser/samples/action-with-call/output.json index 521599544b..d6aaa72892 100644 --- a/test/parser/samples/action-with-call/output.json +++ b/test/parser/samples/action-with-call/output.json @@ -42,6 +42,7 @@ } ] }, - "css": [], - "js": [] + "css": null, + "instance": null, + "module": null } \ No newline at end of file diff --git a/test/parser/samples/action-with-identifier/output.json b/test/parser/samples/action-with-identifier/output.json index 800ab800be..d58b9097b7 100644 --- a/test/parser/samples/action-with-identifier/output.json +++ b/test/parser/samples/action-with-identifier/output.json @@ -28,6 +28,7 @@ } ] }, - "css": [], - "js": [] + "css": null, + "instance": null, + "module": null } \ No newline at end of file diff --git a/test/parser/samples/action-with-literal/output.json b/test/parser/samples/action-with-literal/output.json index 0705cd9e39..4a6f596d10 100644 --- a/test/parser/samples/action-with-literal/output.json +++ b/test/parser/samples/action-with-literal/output.json @@ -29,6 +29,7 @@ } ] }, - "css": [], - "js": [] + "css": null, + "instance": null, + "module": null } \ No newline at end of file diff --git a/test/parser/samples/action/output.json b/test/parser/samples/action/output.json index 68afd79d23..2f553b5efa 100644 --- a/test/parser/samples/action/output.json +++ b/test/parser/samples/action/output.json @@ -23,6 +23,7 @@ } ] }, - "css": [], - "js": [] + "css": null, + "instance": null, + "module": null } \ No newline at end of file diff --git a/test/parser/samples/animation/output.json b/test/parser/samples/animation/output.json index 585ab3ff1c..8332b3ad04 100644 --- a/test/parser/samples/animation/output.json +++ b/test/parser/samples/animation/output.json @@ -55,6 +55,7 @@ } ] }, - "css": [], - "js": [] + "css": null, + "instance": null, + "module": null } \ No newline at end of file diff --git a/test/parser/samples/attribute-containing-solidus/output.json b/test/parser/samples/attribute-containing-solidus/output.json index 920a9420c8..95372bd77d 100644 --- a/test/parser/samples/attribute-containing-solidus/output.json +++ b/test/parser/samples/attribute-containing-solidus/output.json @@ -36,6 +36,7 @@ } ] }, - "css": [], - "js": [] + "css": null, + "instance": null, + "module": null } \ No newline at end of file diff --git a/test/parser/samples/attribute-dynamic-boolean/output.json b/test/parser/samples/attribute-dynamic-boolean/output.json index e50640f279..81a19f49b9 100644 --- a/test/parser/samples/attribute-dynamic-boolean/output.json +++ b/test/parser/samples/attribute-dynamic-boolean/output.json @@ -34,6 +34,7 @@ } ] }, - "css": [], - "js": [] + "css": null, + "instance": null, + "module": null } \ No newline at end of file diff --git a/test/parser/samples/attribute-dynamic-reserved/output.json b/test/parser/samples/attribute-dynamic-reserved/output.json index 042712b872..3a830d448f 100644 --- a/test/parser/samples/attribute-dynamic-reserved/output.json +++ b/test/parser/samples/attribute-dynamic-reserved/output.json @@ -34,6 +34,7 @@ } ] }, - "css": [], - "js": [] + "css": null, + "instance": null, + "module": null } \ No newline at end of file diff --git a/test/parser/samples/attribute-dynamic/output.json b/test/parser/samples/attribute-dynamic/output.json index f3099f6e62..50d8ec60a5 100644 --- a/test/parser/samples/attribute-dynamic/output.json +++ b/test/parser/samples/attribute-dynamic/output.json @@ -58,6 +58,7 @@ } ] }, - "css": [], - "js": [] + "css": null, + "instance": null, + "module": null } \ No newline at end of file diff --git a/test/parser/samples/attribute-escaped/output.json b/test/parser/samples/attribute-escaped/output.json index 979b54d713..6a4143e674 100644 --- a/test/parser/samples/attribute-escaped/output.json +++ b/test/parser/samples/attribute-escaped/output.json @@ -29,6 +29,7 @@ } ] }, - "css": [], - "js": [] + "css": null, + "instance": null, + "module": null } \ No newline at end of file diff --git a/test/parser/samples/attribute-multiple/output.json b/test/parser/samples/attribute-multiple/output.json index 5864363cdf..668409c0ef 100644 --- a/test/parser/samples/attribute-multiple/output.json +++ b/test/parser/samples/attribute-multiple/output.json @@ -43,6 +43,7 @@ } ] }, - "css": [], - "js": [] + "css": null, + "instance": null, + "module": null } \ No newline at end of file diff --git a/test/parser/samples/attribute-shorthand/output.json b/test/parser/samples/attribute-shorthand/output.json index 69f9329ed1..08ddf5eda9 100644 --- a/test/parser/samples/attribute-shorthand/output.json +++ b/test/parser/samples/attribute-shorthand/output.json @@ -34,6 +34,7 @@ } ] }, - "css": [], - "js": [] + "css": null, + "instance": null, + "module": null } \ No newline at end of file diff --git a/test/parser/samples/attribute-static-boolean/output.json b/test/parser/samples/attribute-static-boolean/output.json index 79ea9e9d11..f63b5734e0 100644 --- a/test/parser/samples/attribute-static-boolean/output.json +++ b/test/parser/samples/attribute-static-boolean/output.json @@ -22,6 +22,7 @@ } ] }, - "css": [], - "js": [] + "css": null, + "instance": null, + "module": null } \ No newline at end of file diff --git a/test/parser/samples/attribute-static/output.json b/test/parser/samples/attribute-static/output.json index cb0d7684da..3185e48736 100644 --- a/test/parser/samples/attribute-static/output.json +++ b/test/parser/samples/attribute-static/output.json @@ -29,6 +29,7 @@ } ] }, - "css": [], - "js": [] + "css": null, + "instance": null, + "module": null } \ No newline at end of file diff --git a/test/parser/samples/attribute-unquoted/output.json b/test/parser/samples/attribute-unquoted/output.json index 940ac5b01d..c7556f2eba 100644 --- a/test/parser/samples/attribute-unquoted/output.json +++ b/test/parser/samples/attribute-unquoted/output.json @@ -29,6 +29,7 @@ } ] }, - "css": [], - "js": [] + "css": null, + "instance": null, + "module": null } \ No newline at end of file diff --git a/test/parser/samples/await-then-catch/output.json b/test/parser/samples/await-then-catch/output.json index 1ab557f99d..21fc13eff9 100644 --- a/test/parser/samples/await-then-catch/output.json +++ b/test/parser/samples/await-then-catch/output.json @@ -155,6 +155,7 @@ } ] }, - "css": [], - "js": [] + "css": null, + "instance": null, + "module": null } \ No newline at end of file diff --git a/test/parser/samples/binding-shorthand/output.json b/test/parser/samples/binding-shorthand/output.json index c80fc5f7f2..3be1db50b4 100644 --- a/test/parser/samples/binding-shorthand/output.json +++ b/test/parser/samples/binding-shorthand/output.json @@ -28,6 +28,7 @@ } ] }, - "css": [], - "js": [] + "css": null, + "instance": null, + "module": null } \ No newline at end of file diff --git a/test/parser/samples/binding/output.json b/test/parser/samples/binding/output.json index 031d291fa7..5dc173c2a2 100644 --- a/test/parser/samples/binding/output.json +++ b/test/parser/samples/binding/output.json @@ -28,6 +28,7 @@ } ] }, - "css": [], - "js": [] + "css": null, + "instance": null, + "module": null } \ No newline at end of file diff --git a/test/parser/samples/comment/output.json b/test/parser/samples/comment/output.json index 10d85bf422..89295c188a 100644 --- a/test/parser/samples/comment/output.json +++ b/test/parser/samples/comment/output.json @@ -12,6 +12,7 @@ } ] }, - "css": [], - "js": [] + "css": null, + "instance": null, + "module": null } \ No newline at end of file diff --git a/test/parser/samples/component-dynamic/output.json b/test/parser/samples/component-dynamic/output.json index 9b08732c38..c2e4e3ee79 100644 --- a/test/parser/samples/component-dynamic/output.json +++ b/test/parser/samples/component-dynamic/output.json @@ -37,6 +37,7 @@ } ] }, - "css": [], - "js": [] + "css": null, + "instance": null, + "module": null } \ No newline at end of file diff --git a/test/parser/samples/convert-entities-in-element/output.json b/test/parser/samples/convert-entities-in-element/output.json index f481345a02..fb0f5b288e 100644 --- a/test/parser/samples/convert-entities-in-element/output.json +++ b/test/parser/samples/convert-entities-in-element/output.json @@ -21,6 +21,7 @@ } ] }, - "css": [], - "js": [] + "css": null, + "instance": null, + "module": null } \ No newline at end of file diff --git a/test/parser/samples/convert-entities/output.json b/test/parser/samples/convert-entities/output.json index b3e66a9007..ca1c1356f8 100644 --- a/test/parser/samples/convert-entities/output.json +++ b/test/parser/samples/convert-entities/output.json @@ -12,6 +12,7 @@ } ] }, - "css": [], - "js": [] + "css": null, + "instance": null, + "module": null } \ No newline at end of file diff --git a/test/parser/samples/css/output.json b/test/parser/samples/css/output.json index e91c31a71a..3127e01c71 100644 --- a/test/parser/samples/css/output.json +++ b/test/parser/samples/css/output.json @@ -27,71 +27,70 @@ } ] }, - "css": [ - { - "start": 16, - "end": 56, - "attributes": [], - "children": [ - { - "type": "Rule", - "selector": { - "type": "SelectorList", - "children": [ - { - "type": "Selector", + "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": "TypeSelector", - "name": "div", - "start": 25, - "end": 28 + "type": "Identifier", + "name": "red", + "start": 40, + "end": 43 } ], - "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, + "start": 39, "end": 43 - } - ], - "start": 29, - "end": 47 - }, - "start": 25, + }, + "start": 33, + "end": 43 + } + ], + "start": 29, "end": 47 - } - ], - "content": { - "start": 23, - "end": 48, - "styles": "\n\tdiv {\n\t\tcolor: red;\n\t}\n" + }, + "start": 25, + "end": 47 } + ], + "content": { + "start": 23, + "end": 48, + "styles": "\n\tdiv {\n\t\tcolor: red;\n\t}\n" } - ], - "js": [] + }, + "instance": null, + "module": null } \ No newline at end of file diff --git a/test/parser/samples/dynamic-import/output.json b/test/parser/samples/dynamic-import/output.json index 55c1bdf756..c0d4a45e0d 100644 --- a/test/parser/samples/dynamic-import/output.json +++ b/test/parser/samples/dynamic-import/output.json @@ -5,201 +5,199 @@ "type": "Fragment", "children": [] }, - "css": [], - "js": [ - { - "start": 0, - "end": 146, - "attributes": [], - "content": { - "type": "Program", - "start": 8, - "end": 137, - "body": [ - { - "type": "ImportDeclaration", - "start": 10, - "end": 43, - "specifiers": [ - { - "type": "ImportSpecifier", + "css": null, + "instance": { + "start": 0, + "end": 146, + "context": "default", + "content": { + "type": "Program", + "start": 8, + "end": 137, + "body": [ + { + "type": "ImportDeclaration", + "start": 10, + "end": 43, + "specifiers": [ + { + "type": "ImportSpecifier", + "start": 19, + "end": 26, + "imported": { + "type": "Identifier", "start": 19, "end": 26, - "imported": { - "type": "Identifier", - "start": 19, - "end": 26, - "name": "onMount" - }, - "local": { - "type": "Identifier", - "start": 19, - "end": 26, - "name": "onMount" - } + "name": "onMount" + }, + "local": { + "type": "Identifier", + "start": 19, + "end": 26, + "name": "onMount" } - ], - "source": { - "type": "Literal", - "start": 34, - "end": 42, - "value": "svelte", - "raw": "'svelte'" } - }, - { - "type": "ExpressionStatement", + ], + "source": { + "type": "Literal", + "start": 34, + "end": 42, + "value": "svelte", + "raw": "'svelte'" + } + }, + { + "type": "ExpressionStatement", + "start": 46, + "end": 136, + "expression": { + "type": "CallExpression", "start": 46, - "end": 136, - "expression": { - "type": "CallExpression", + "end": 135, + "callee": { + "type": "Identifier", "start": 46, - "end": 135, - "callee": { - "type": "Identifier", - "start": 46, - "end": 53, - "name": "onMount" - }, - "arguments": [ - { - "type": "ArrowFunctionExpression", - "start": 54, + "end": 53, + "name": "onMount" + }, + "arguments": [ + { + "type": "ArrowFunctionExpression", + "start": 54, + "end": 134, + "id": null, + "generator": false, + "expression": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 60, "end": 134, - "id": null, - "generator": false, - "expression": false, - "async": false, - "params": [], - "body": { - "type": "BlockStatement", - "start": 60, - "end": 134, - "body": [ - { - "type": "ExpressionStatement", + "body": [ + { + "type": "ExpressionStatement", + "start": 64, + "end": 131, + "expression": { + "type": "CallExpression", "start": 64, - "end": 131, - "expression": { - "type": "CallExpression", + "end": 130, + "callee": { + "type": "MemberExpression", "start": 64, - "end": 130, - "callee": { - "type": "MemberExpression", + "end": 87, + "object": { + "type": "CallExpression", "start": 64, - "end": 87, - "object": { - "type": "CallExpression", + "end": 82, + "callee": { + "type": "Import", "start": 64, - "end": 82, - "callee": { - "type": "Import", - "start": 64, - "end": 70 - }, - "arguments": [ - { - "type": "Literal", - "start": 71, - "end": 81, - "value": "./foo.js", - "raw": "'./foo.js'" - } - ] - }, - "property": { - "type": "Identifier", - "start": 83, - "end": 87, - "name": "then" + "end": 70 }, - "computed": false + "arguments": [ + { + "type": "Literal", + "start": 71, + "end": 81, + "value": "./foo.js", + "raw": "'./foo.js'" + } + ] + }, + "property": { + "type": "Identifier", + "start": 83, + "end": 87, + "name": "then" }, - "arguments": [ - { - "type": "ArrowFunctionExpression", - "start": 88, + "computed": false + }, + "arguments": [ + { + "type": "ArrowFunctionExpression", + "start": 88, + "end": 129, + "id": null, + "generator": false, + "expression": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 88, + "end": 91, + "name": "foo" + } + ], + "body": { + "type": "BlockStatement", + "start": 95, "end": 129, - "id": null, - "generator": false, - "expression": false, - "async": false, - "params": [ + "body": [ { - "type": "Identifier", - "start": 88, - "end": 91, - "name": "foo" - } - ], - "body": { - "type": "BlockStatement", - "start": 95, - "end": 129, - "body": [ - { - "type": "ExpressionStatement", + "type": "ExpressionStatement", + "start": 100, + "end": 125, + "expression": { + "type": "CallExpression", "start": 100, - "end": 125, - "expression": { - "type": "CallExpression", + "end": 124, + "callee": { + "type": "MemberExpression", "start": 100, - "end": 124, - "callee": { - "type": "MemberExpression", + "end": 111, + "object": { + "type": "Identifier", "start": 100, + "end": 107, + "name": "console" + }, + "property": { + "type": "Identifier", + "start": 108, "end": 111, + "name": "log" + }, + "computed": false + }, + "arguments": [ + { + "type": "MemberExpression", + "start": 112, + "end": 123, "object": { "type": "Identifier", - "start": 100, - "end": 107, - "name": "console" + "start": 112, + "end": 115, + "name": "foo" }, "property": { "type": "Identifier", - "start": 108, - "end": 111, - "name": "log" + "start": 116, + "end": 123, + "name": "default" }, "computed": false - }, - "arguments": [ - { - "type": "MemberExpression", - "start": 112, - "end": 123, - "object": { - "type": "Identifier", - "start": 112, - "end": 115, - "name": "foo" - }, - "property": { - "type": "Identifier", - "start": 116, - "end": 123, - "name": "default" - }, - "computed": false - } - ] - } + } + ] } - ] - } + } + ] } - ] - } + } + ] } - ] - } + } + ] } - ] - } + } + ] } - ], - "sourceType": "module" - } + } + ], + "sourceType": "module" } - ] + } } \ No newline at end of file diff --git a/test/parser/samples/each-block-destructured/output.json b/test/parser/samples/each-block-destructured/output.json index fdca5f82a2..b9efc18906 100644 --- a/test/parser/samples/each-block-destructured/output.json +++ b/test/parser/samples/each-block-destructured/output.json @@ -75,6 +75,7 @@ } ] }, - "css": [], - "js": [] + "css": null, + "instance": null, + "module": null } \ No newline at end of file diff --git a/test/parser/samples/each-block-else/output.json b/test/parser/samples/each-block-else/output.json index be0ac6d550..aefc8c2f39 100644 --- a/test/parser/samples/each-block-else/output.json +++ b/test/parser/samples/each-block-else/output.json @@ -67,6 +67,7 @@ } ] }, - "css": [], - "js": [] + "css": null, + "instance": null, + "module": null } \ No newline at end of file diff --git a/test/parser/samples/each-block-indexed/output.json b/test/parser/samples/each-block-indexed/output.json index bda5f86a89..7518652468 100644 --- a/test/parser/samples/each-block-indexed/output.json +++ b/test/parser/samples/each-block-indexed/output.json @@ -63,6 +63,7 @@ } ] }, - "css": [], - "js": [] + "css": null, + "instance": null, + "module": null } \ No newline at end of file diff --git a/test/parser/samples/each-block-keyed/output.json b/test/parser/samples/each-block-keyed/output.json index a00694fc4e..fe893bcdb9 100644 --- a/test/parser/samples/each-block-keyed/output.json +++ b/test/parser/samples/each-block-keyed/output.json @@ -63,6 +63,7 @@ } ] }, - "css": [], - "js": [] + "css": null, + "instance": null, + "module": null } \ No newline at end of file diff --git a/test/parser/samples/each-block/output.json b/test/parser/samples/each-block/output.json index a24c32e9ad..c16a71ad5d 100644 --- a/test/parser/samples/each-block/output.json +++ b/test/parser/samples/each-block/output.json @@ -45,6 +45,7 @@ } ] }, - "css": [], - "js": [] + "css": null, + "instance": null, + "module": null } \ No newline at end of file diff --git a/test/parser/samples/element-with-mustache/output.json b/test/parser/samples/element-with-mustache/output.json index a56cd27967..c8a386d681 100644 --- a/test/parser/samples/element-with-mustache/output.json +++ b/test/parser/samples/element-with-mustache/output.json @@ -38,6 +38,7 @@ } ] }, - "css": [], - "js": [] + "css": null, + "instance": null, + "module": null } \ No newline at end of file diff --git a/test/parser/samples/element-with-text/output.json b/test/parser/samples/element-with-text/output.json index 1ae33df94f..70f6163c93 100644 --- a/test/parser/samples/element-with-text/output.json +++ b/test/parser/samples/element-with-text/output.json @@ -21,6 +21,7 @@ } ] }, - "css": [], - "js": [] + "css": null, + "instance": null, + "module": null } \ No newline at end of file diff --git a/test/parser/samples/elements/output.json b/test/parser/samples/elements/output.json index 219799df3e..d216f7f5d8 100644 --- a/test/parser/samples/elements/output.json +++ b/test/parser/samples/elements/output.json @@ -22,6 +22,7 @@ } ] }, - "css": [], - "js": [] + "css": null, + "instance": null, + "module": null } \ No newline at end of file diff --git a/test/parser/samples/event-handler/output.json b/test/parser/samples/event-handler/output.json index 740e43e48d..b1fe89fc2a 100644 --- a/test/parser/samples/event-handler/output.json +++ b/test/parser/samples/event-handler/output.json @@ -98,6 +98,7 @@ } ] }, - "css": [], - "js": [] + "css": null, + "instance": null, + "module": null } \ No newline at end of file diff --git a/test/parser/samples/if-block-else/output.json b/test/parser/samples/if-block-else/output.json index 8e96c34efc..dedf2797c4 100644 --- a/test/parser/samples/if-block-else/output.json +++ b/test/parser/samples/if-block-else/output.json @@ -56,6 +56,7 @@ } ] }, - "css": [], - "js": [] + "css": null, + "instance": null, + "module": null } \ No newline at end of file diff --git a/test/parser/samples/if-block-elseif/output.json b/test/parser/samples/if-block-elseif/output.json index 257eb1e7d2..426e1f7fbc 100644 --- a/test/parser/samples/if-block-elseif/output.json +++ b/test/parser/samples/if-block-elseif/output.json @@ -96,6 +96,7 @@ } ] }, - "css": [], - "js": [] + "css": null, + "instance": null, + "module": null } \ No newline at end of file diff --git a/test/parser/samples/if-block/output.json b/test/parser/samples/if-block/output.json index ba734c0e56..d560824766 100644 --- a/test/parser/samples/if-block/output.json +++ b/test/parser/samples/if-block/output.json @@ -25,6 +25,7 @@ } ] }, - "css": [], - "js": [] + "css": null, + "instance": null, + "module": null } \ No newline at end of file diff --git a/test/parser/samples/implicitly-closed-li/output.json b/test/parser/samples/implicitly-closed-li/output.json index 69def7a9a2..caf69d7109 100644 --- a/test/parser/samples/implicitly-closed-li/output.json +++ b/test/parser/samples/implicitly-closed-li/output.json @@ -66,6 +66,7 @@ } ] }, - "css": [], - "js": [] + "css": null, + "instance": null, + "module": null } \ No newline at end of file diff --git a/test/parser/samples/nbsp/output.json b/test/parser/samples/nbsp/output.json index 7373bc9673..4fa318ce48 100644 --- a/test/parser/samples/nbsp/output.json +++ b/test/parser/samples/nbsp/output.json @@ -21,6 +21,7 @@ } ] }, - "css": [], - "js": [] + "css": null, + "instance": null, + "module": null } \ No newline at end of file diff --git a/test/parser/samples/raw-mustaches/output.json b/test/parser/samples/raw-mustaches/output.json index 41dab885e0..1d92b21c85 100644 --- a/test/parser/samples/raw-mustaches/output.json +++ b/test/parser/samples/raw-mustaches/output.json @@ -55,6 +55,7 @@ } ] }, - "css": [], - "js": [] + "css": null, + "instance": null, + "module": null } \ No newline at end of file diff --git a/test/parser/samples/refs/output.json b/test/parser/samples/refs/output.json index 3cd6c4d9fa..2cf5054304 100644 --- a/test/parser/samples/refs/output.json +++ b/test/parser/samples/refs/output.json @@ -28,6 +28,7 @@ } ] }, - "css": [], - "js": [] + "css": null, + "instance": null, + "module": null } \ No newline at end of file diff --git a/test/parser/samples/script-comment-only/output.json b/test/parser/samples/script-comment-only/output.json index b04d38633d..95ca769b20 100644 --- a/test/parser/samples/script-comment-only/output.json +++ b/test/parser/samples/script-comment-only/output.json @@ -20,19 +20,16 @@ } ] }, - "css": [], - "js": [ - { - "start": 0, - "end": 43, - "attributes": [], - "content": { - "type": "Program", - "start": 8, - "end": 34, - "body": [], - "sourceType": "module" - } + "instance": { + "start": 0, + "end": 43, + "context": "default", + "content": { + "type": "Program", + "start": 8, + "end": 34, + "body": [], + "sourceType": "module" } - ] + } } \ No newline at end of file diff --git a/test/parser/samples/script-comment-trailing-multiline/output.json b/test/parser/samples/script-comment-trailing-multiline/output.json index a32ff799f7..d4a45911a1 100644 --- a/test/parser/samples/script-comment-trailing-multiline/output.json +++ b/test/parser/samples/script-comment-trailing-multiline/output.json @@ -44,46 +44,43 @@ } ] }, - "css": [], - "js": [ - { - "start": 0, - "end": 77, - "attributes": [], - "content": { - "type": "Program", - "start": 8, - "end": 68, - "body": [ - { - "type": "VariableDeclaration", - "start": 10, - "end": 29, - "declarations": [ - { - "type": "VariableDeclarator", + "instance": { + "start": 0, + "end": 77, + "context": "default", + "content": { + "type": "Program", + "start": 8, + "end": 68, + "body": [ + { + "type": "VariableDeclaration", + "start": 10, + "end": 29, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 14, + "end": 28, + "id": { + "type": "Identifier", "start": 14, + "end": 18, + "name": "name" + }, + "init": { + "type": "Literal", + "start": 21, "end": 28, - "id": { - "type": "Identifier", - "start": 14, - "end": 18, - "name": "name" - }, - "init": { - "type": "Literal", - "start": 21, - "end": 28, - "value": "world", - "raw": "'world'" - } + "value": "world", + "raw": "'world'" } - ], - "kind": "let" - } - ], - "sourceType": "module" - } + } + ], + "kind": "let" + } + ], + "sourceType": "module" } - ] + } } \ No newline at end of file diff --git a/test/parser/samples/script-comment-trailing/output.json b/test/parser/samples/script-comment-trailing/output.json index 78012d4438..92d431b558 100644 --- a/test/parser/samples/script-comment-trailing/output.json +++ b/test/parser/samples/script-comment-trailing/output.json @@ -44,46 +44,43 @@ } ] }, - "css": [], - "js": [ - { - "start": 0, - "end": 66, - "attributes": [], - "content": { - "type": "Program", - "start": 8, - "end": 57, - "body": [ - { - "type": "VariableDeclaration", - "start": 10, - "end": 29, - "declarations": [ - { - "type": "VariableDeclarator", + "instance": { + "start": 0, + "end": 66, + "context": "default", + "content": { + "type": "Program", + "start": 8, + "end": 57, + "body": [ + { + "type": "VariableDeclaration", + "start": 10, + "end": 29, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 14, + "end": 28, + "id": { + "type": "Identifier", "start": 14, + "end": 18, + "name": "name" + }, + "init": { + "type": "Literal", + "start": 21, "end": 28, - "id": { - "type": "Identifier", - "start": 14, - "end": 18, - "name": "name" - }, - "init": { - "type": "Literal", - "start": 21, - "end": 28, - "value": "world", - "raw": "'world'" - } + "value": "world", + "raw": "'world'" } - ], - "kind": "let" - } - ], - "sourceType": "module" - } + } + ], + "kind": "let" + } + ], + "sourceType": "module" } - ] + } } \ No newline at end of file diff --git a/test/parser/samples/script/output.json b/test/parser/samples/script/output.json index bf89a0ff02..95966f5dc6 100644 --- a/test/parser/samples/script/output.json +++ b/test/parser/samples/script/output.json @@ -44,46 +44,43 @@ } ] }, - "css": [], - "js": [ - { - "start": 0, - "end": 39, - "attributes": [], - "content": { - "type": "Program", - "start": 8, - "end": 30, - "body": [ - { - "type": "VariableDeclaration", - "start": 10, - "end": 29, - "declarations": [ - { - "type": "VariableDeclarator", + "instance": { + "start": 0, + "end": 39, + "context": "default", + "content": { + "type": "Program", + "start": 8, + "end": 30, + "body": [ + { + "type": "VariableDeclaration", + "start": 10, + "end": 29, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 14, + "end": 28, + "id": { + "type": "Identifier", "start": 14, + "end": 18, + "name": "name" + }, + "init": { + "type": "Literal", + "start": 21, "end": 28, - "id": { - "type": "Identifier", - "start": 14, - "end": 18, - "name": "name" - }, - "init": { - "type": "Literal", - "start": 21, - "end": 28, - "value": "world", - "raw": "'world'" - } + "value": "world", + "raw": "'world'" } - ], - "kind": "let" - } - ], - "sourceType": "module" - } + } + ], + "kind": "let" + } + ], + "sourceType": "module" } - ] + } } \ No newline at end of file diff --git a/test/parser/samples/self-closing-element/output.json b/test/parser/samples/self-closing-element/output.json index f7475b41d7..47eea2f333 100644 --- a/test/parser/samples/self-closing-element/output.json +++ b/test/parser/samples/self-closing-element/output.json @@ -14,6 +14,7 @@ } ] }, - "css": [], - "js": [] + "css": null, + "instance": null, + "module": null } \ No newline at end of file diff --git a/test/parser/samples/self-reference/output.json b/test/parser/samples/self-reference/output.json index ff111e17ba..de5112a087 100644 --- a/test/parser/samples/self-reference/output.json +++ b/test/parser/samples/self-reference/output.json @@ -73,6 +73,7 @@ } ] }, - "css": [], - "js": [] + "css": null, + "instance": null, + "module": null } \ No newline at end of file diff --git a/test/parser/samples/space-between-mustaches/output.json b/test/parser/samples/space-between-mustaches/output.json index d66735213d..c89409daeb 100644 --- a/test/parser/samples/space-between-mustaches/output.json +++ b/test/parser/samples/space-between-mustaches/output.json @@ -72,6 +72,7 @@ } ] }, - "css": [], - "js": [] + "css": null, + "instance": null, + "module": null } \ No newline at end of file diff --git a/test/parser/samples/spread/output.json b/test/parser/samples/spread/output.json index a632dc89ab..3986da3578 100644 --- a/test/parser/samples/spread/output.json +++ b/test/parser/samples/spread/output.json @@ -26,6 +26,7 @@ } ] }, - "css": [], - "js": [] + "css": null, + "instance": null, + "module": null } \ 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 08f42919ed..3b403458fc 100644 --- a/test/parser/samples/textarea-children/output.json +++ b/test/parser/samples/textarea-children/output.json @@ -44,6 +44,7 @@ } ] }, - "css": [], - "js": [] + "css": null, + "instance": null, + "module": null } \ No newline at end of file diff --git a/test/parser/samples/transition-intro-no-params/output.json b/test/parser/samples/transition-intro-no-params/output.json index d53b4d9d88..edb15457e6 100644 --- a/test/parser/samples/transition-intro-no-params/output.json +++ b/test/parser/samples/transition-intro-no-params/output.json @@ -32,6 +32,7 @@ } ] }, - "css": [], - "js": [] + "css": null, + "instance": null, + "module": null } \ No newline at end of file diff --git a/test/parser/samples/transition-intro/output.json b/test/parser/samples/transition-intro/output.json index 6405d0bad5..5583dd89bc 100644 --- a/test/parser/samples/transition-intro/output.json +++ b/test/parser/samples/transition-intro/output.json @@ -60,6 +60,7 @@ } ] }, - "css": [], - "js": [] + "css": null, + "instance": null, + "module": null } \ No newline at end of file diff --git a/test/parser/samples/unusual-identifier/output.json b/test/parser/samples/unusual-identifier/output.json index fe9b175128..c0d4ecc3ff 100644 --- a/test/parser/samples/unusual-identifier/output.json +++ b/test/parser/samples/unusual-identifier/output.json @@ -45,6 +45,7 @@ } ] }, - "css": [], - "js": [] + "css": null, + "instance": null, + "module": null } \ No newline at end of file diff --git a/test/parser/samples/whitespace-leading-trailing/output.json b/test/parser/samples/whitespace-leading-trailing/output.json index 7dbf259721..f164af01ba 100644 --- a/test/parser/samples/whitespace-leading-trailing/output.json +++ b/test/parser/samples/whitespace-leading-trailing/output.json @@ -27,6 +27,7 @@ } ] }, - "css": [], - "js": [] + "css": null, + "instance": null, + "module": null } \ No newline at end of file diff --git a/test/parser/samples/whitespace-normal/output.json b/test/parser/samples/whitespace-normal/output.json index c150b53f04..e4ce956331 100644 --- a/test/parser/samples/whitespace-normal/output.json +++ b/test/parser/samples/whitespace-normal/output.json @@ -62,6 +62,7 @@ } ] }, - "css": [], - "js": [] + "css": null, + "instance": null, + "module": null } \ No newline at end of file diff --git a/test/parser/samples/yield/output.json b/test/parser/samples/yield/output.json index b16ab436f6..16ea79d8e8 100644 --- a/test/parser/samples/yield/output.json +++ b/test/parser/samples/yield/output.json @@ -17,6 +17,7 @@ } ] }, - "css": [], - "js": [] + "css": null, + "instance": null, + "module": null } \ No newline at end of file diff --git a/test/validator/samples/multiple-script-default-context/errors.json b/test/validator/samples/multiple-script-default-context/errors.json index 6e9a53d691..6f0637b51b 100644 --- a/test/validator/samples/multiple-script-default-context/errors.json +++ b/test/validator/samples/multiple-script-default-context/errors.json @@ -8,8 +8,8 @@ "character": 30 }, "end": { - "line": 7, - "column": 9, - "character": 58 + "line": 5, + "column": 0, + "character": 30 } }] \ No newline at end of file diff --git a/test/validator/samples/multiple-script-module-context/errors.json b/test/validator/samples/multiple-script-module-context/errors.json index ef8dc15273..7b86c61926 100644 --- a/test/validator/samples/multiple-script-module-context/errors.json +++ b/test/validator/samples/multiple-script-module-context/errors.json @@ -8,8 +8,8 @@ "character": 47 }, "end": { - "line": 7, - "column": 9, - "character": 92 + "line": 5, + "column": 0, + "character": 47 } }] \ No newline at end of file diff --git a/test/validator/samples/script-invalid-context/errors.json b/test/validator/samples/script-invalid-context/errors.json index 9c276d932d..07ad0f1270 100644 --- a/test/validator/samples/script-invalid-context/errors.json +++ b/test/validator/samples/script-invalid-context/errors.json @@ -9,7 +9,7 @@ }, "end": { "line": 1, - "column": 22, - "character": 22 + "column": 8, + "character": 8 } }] \ No newline at end of file