From 564ddba4bc112a884d9d696d56dba58501a6098f Mon Sep 17 00:00:00 2001 From: Rich-Harris Date: Fri, 18 Nov 2016 18:40:22 -0500 Subject: [PATCH] parse ' ) ) { scriptEnd = scriptStart + token.end; break; } } - js.content = parse( ) + const source = spaces( scriptStart ) + parser.template.slice( scriptStart, scriptEnd ); + + const ast = parse( source, { + ecmaVersion: 8, + sourceType: 'module' + }); + + ast.start = scriptStart; + + return { + start, + end: parser.index, + attributes, + content: ast + }; } diff --git a/compiler/parse/state/tag.js b/compiler/parse/state/tag.js index 0dd1ccaa5d..7cfaa32188 100644 --- a/compiler/parse/state/tag.js +++ b/compiler/parse/state/tag.js @@ -54,7 +54,7 @@ export default function tag ( parser ) { } parser.eat( '>', true ); - parser[ special.id ] = special.read( parser, start, attributes ); + parser[ special.property ] = special.read( parser, start, attributes ); return; } diff --git a/test/parser/script/output.json b/test/parser/script/output.json index 62ce17e170..82f481c9db 100644 --- a/test/parser/script/output.json +++ b/test/parser/script/output.json @@ -39,5 +39,83 @@ ] }, "css": null, - "js": null + "js": { + "start": 26, + "end": 105, + "attributes": [], + "content": { + "type": "Program", + "start": 34, + "end": 95, + "body": [ + { + "declaration": { + "start": 51, + "end": 94, + "type": "ObjectExpression", + "properties": [ + { + "start": 55, + "end": 91, + "type": "Property", + "computed": false, + "key": { + "start": 55, + "end": 59, + "type": "Identifier", + "name": "data" + }, + "kind": "init", + "method": false, + "shorthand": false, + "value": { + "start": 61, + "end": 91, + "type": "ArrowFunctionExpression", + "async": false, + "body": { + "start": 68, + "end": 90, + "type": "ObjectExpression", + "properties": [ + { + "start": 73, + "end": 86, + "type": "Property", + "computed": false, + "key": { + "start": 73, + "end": 77, + "type": "Identifier", + "name": "name" + }, + "kind": "init", + "method": false, + "shorthand": false, + "value": { + "start": 79, + "end": 86, + "type": "Literal", + "raw": "'world'", + "value": "world" + } + } + ] + }, + "expression": true, + "generator": false, + "id": null, + "params": [] + } + } + ] + }, + "end": 95, + "start": 36, + "type": "ExportDefaultDeclaration" + } + ], + "sourceType": "module" + } + } } diff --git a/test/parser/script/solo b/test/parser/script/solo deleted file mode 100644 index e69de29bb2..0000000000