diff --git a/src/parser/converts/element.ts b/src/parser/converts/element.ts index d7032527..0144db67 100644 --- a/src/parser/converts/element.ts +++ b/src/parser/converts/element.ts @@ -369,7 +369,15 @@ function convertSpecialElement( ctx.scriptLet.addExpression(thisExpression, thisAttr, null, (es) => { thisAttr.expression = es; }); - element.startTag.attributes.push(thisAttr); + + const targetIndex = element.startTag.attributes.findIndex( + (attr) => thisAttr.range[1] <= attr.range[0] + ); + if (targetIndex === -1) { + element.startTag.attributes.push(thisAttr); + } else { + element.startTag.attributes.splice(targetIndex, 0, thisAttr); + } } extractElementTags(element, ctx, { diff --git a/tests/fixtures/parser/ast/docs/template-syntax/15_1-svelte-component/02-output.json b/tests/fixtures/parser/ast/docs/template-syntax/15_1-svelte-component/02-output.json index 53a22c04..0f2f71da 100644 --- a/tests/fixtures/parser/ast/docs/template-syntax/15_1-svelte-component/02-output.json +++ b/tests/fixtures/parser/ast/docs/template-syntax/15_1-svelte-component/02-output.json @@ -25,80 +25,6 @@ "startTag": { "type": "SvelteStartTag", "attributes": [ - { - "type": "SvelteAttribute", - "key": { - "type": "SvelteName", - "name": "foo", - "range": [ - 52, - 55 - ], - "loc": { - "start": { - "line": 1, - "column": 52 - }, - "end": { - "line": 1, - "column": 55 - } - } - }, - "boolean": false, - "value": [ - { - "type": "SvelteMustacheTag", - "kind": "text", - "expression": { - "type": "Identifier", - "name": "bar", - "range": [ - 57, - 60 - ], - "loc": { - "start": { - "line": 1, - "column": 57 - }, - "end": { - "line": 1, - "column": 60 - } - } - }, - "range": [ - 56, - 61 - ], - "loc": { - "start": { - "line": 1, - "column": 56 - }, - "end": { - "line": 1, - "column": 61 - } - } - } - ], - "range": [ - 52, - 61 - ], - "loc": { - "start": { - "line": 1, - "column": 52 - }, - "end": { - "line": 1, - "column": 61 - } - } - }, { "type": "SvelteSpecialDirective", "kind": "this", @@ -188,6 +114,80 @@ "column": 51 } } + }, + { + "type": "SvelteAttribute", + "key": { + "type": "SvelteName", + "name": "foo", + "range": [ + 52, + 55 + ], + "loc": { + "start": { + "line": 1, + "column": 52 + }, + "end": { + "line": 1, + "column": 55 + } + } + }, + "boolean": false, + "value": [ + { + "type": "SvelteMustacheTag", + "kind": "text", + "expression": { + "type": "Identifier", + "name": "bar", + "range": [ + 57, + 60 + ], + "loc": { + "start": { + "line": 1, + "column": 57 + }, + "end": { + "line": 1, + "column": 60 + } + } + }, + "range": [ + 56, + 61 + ], + "loc": { + "start": { + "line": 1, + "column": 56 + }, + "end": { + "line": 1, + "column": 61 + } + } + } + ], + "range": [ + 52, + 61 + ], + "loc": { + "start": { + "line": 1, + "column": 52 + }, + "end": { + "line": 1, + "column": 61 + } + } } ], "selfClosing": true, diff --git a/tests/fixtures/parser/ast/docs/template-syntax/15_2-svelte-element/02-output.json b/tests/fixtures/parser/ast/docs/template-syntax/15_2-svelte-element/02-output.json index 8bb6ab45..cdc11b77 100644 --- a/tests/fixtures/parser/ast/docs/template-syntax/15_2-svelte-element/02-output.json +++ b/tests/fixtures/parser/ast/docs/template-syntax/15_2-svelte-element/02-output.json @@ -266,127 +266,127 @@ "type": "SvelteStartTag", "attributes": [ { - "type": "SvelteDirective", - "kind": "EventHandler", + "type": "SvelteSpecialDirective", + "kind": "this", "key": { - "type": "SvelteDirectiveKey", - "name": { - "type": "SvelteName", - "name": "click", - "range": [ - 89, - 94 - ], - "loc": { - "start": { - "line": 6, - "column": 30 - }, - "end": { - "line": 6, - "column": 35 - } - } - }, - "modifiers": [], + "type": "SvelteSpecialDirectiveKey", "range": [ - 86, - 94 + 75, + 79 ], "loc": { "start": { "line": 6, - "column": 27 + "column": 16 }, "end": { "line": 6, - "column": 35 + "column": 20 } } }, "expression": { "type": "Identifier", - "name": "handler", + "name": "tag", "range": [ - 96, - 103 + 81, + 84 ], "loc": { "start": { "line": 6, - "column": 37 + "column": 22 }, "end": { "line": 6, - "column": 44 + "column": 25 } } }, "range": [ - 86, - 104 + 75, + 85 ], "loc": { "start": { "line": 6, - "column": 27 + "column": 16 }, "end": { "line": 6, - "column": 45 + "column": 26 } } }, { - "type": "SvelteSpecialDirective", - "kind": "this", + "type": "SvelteDirective", + "kind": "EventHandler", "key": { - "type": "SvelteSpecialDirectiveKey", + "type": "SvelteDirectiveKey", + "name": { + "type": "SvelteName", + "name": "click", + "range": [ + 89, + 94 + ], + "loc": { + "start": { + "line": 6, + "column": 30 + }, + "end": { + "line": 6, + "column": 35 + } + } + }, + "modifiers": [], "range": [ - 75, - 79 + 86, + 94 ], "loc": { "start": { "line": 6, - "column": 16 + "column": 27 }, "end": { "line": 6, - "column": 20 + "column": 35 } } }, "expression": { "type": "Identifier", - "name": "tag", + "name": "handler", "range": [ - 81, - 84 + 96, + 103 ], "loc": { "start": { "line": 6, - "column": 22 + "column": 37 }, "end": { "line": 6, - "column": 25 + "column": 44 } } }, "range": [ - 75, - 85 + 86, + 104 ], "loc": { "start": { "line": 6, - "column": 16 + "column": 27 }, "end": { "line": 6, - "column": 26 + "column": 45 } } } diff --git a/tests/fixtures/parser/ast/svelte-element-with-bind-this-output.json b/tests/fixtures/parser/ast/svelte-element-with-bind-this-output.json index 74e9e4f9..bac854b8 100644 --- a/tests/fixtures/parser/ast/svelte-element-with-bind-this-output.json +++ b/tests/fixtures/parser/ast/svelte-element-with-bind-this-output.json @@ -392,128 +392,128 @@ "type": "SvelteStartTag", "attributes": [ { - "type": "SvelteDirective", - "kind": "Binding", + "type": "SvelteSpecialDirective", + "kind": "this", "key": { - "type": "SvelteDirectiveKey", - "name": { - "type": "SvelteName", - "name": "this", - "range": [ - 99, - 103 - ], - "loc": { - "start": { - "line": 7, - "column": 32 - }, - "end": { - "line": 7, - "column": 36 - } - } - }, - "modifiers": [], + "type": "SvelteSpecialDirectiveKey", "range": [ - 94, - 103 + 83, + 87 ], "loc": { "start": { "line": 7, - "column": 27 + "column": 16 }, "end": { "line": 7, - "column": 36 + "column": 20 } } }, "expression": { "type": "Identifier", - "name": "a", + "name": "tag", "range": [ - 105, - 106 + 89, + 92 ], "loc": { "start": { "line": 7, - "column": 38 + "column": 22 }, "end": { "line": 7, - "column": 39 + "column": 25 } } }, - "shorthand": false, "range": [ - 94, - 107 + 83, + 93 ], "loc": { "start": { "line": 7, - "column": 27 + "column": 16 }, "end": { "line": 7, - "column": 40 + "column": 26 } } }, { - "type": "SvelteSpecialDirective", - "kind": "this", + "type": "SvelteDirective", + "kind": "Binding", "key": { - "type": "SvelteSpecialDirectiveKey", + "type": "SvelteDirectiveKey", + "name": { + "type": "SvelteName", + "name": "this", + "range": [ + 99, + 103 + ], + "loc": { + "start": { + "line": 7, + "column": 32 + }, + "end": { + "line": 7, + "column": 36 + } + } + }, + "modifiers": [], "range": [ - 83, - 87 + 94, + 103 ], "loc": { "start": { "line": 7, - "column": 16 + "column": 27 }, "end": { "line": 7, - "column": 20 + "column": 36 } } }, "expression": { "type": "Identifier", - "name": "tag", + "name": "a", "range": [ - 89, - 92 + 105, + 106 ], "loc": { "start": { "line": 7, - "column": 22 + "column": 38 }, "end": { "line": 7, - "column": 25 + "column": 39 } } }, + "shorthand": false, "range": [ - 83, - 93 + 94, + 107 ], "loc": { "start": { "line": 7, - "column": 16 + "column": 27 }, "end": { "line": 7, - "column": 26 + "column": 40 } } } diff --git a/tests/fixtures/parser/ast/this-attr01-input.svelte b/tests/fixtures/parser/ast/this-attr01-input.svelte new file mode 100644 index 00000000..10e8190c --- /dev/null +++ b/tests/fixtures/parser/ast/this-attr01-input.svelte @@ -0,0 +1,15 @@ + + + \ No newline at end of file diff --git a/tests/fixtures/parser/ast/this-attr01-output.json b/tests/fixtures/parser/ast/this-attr01-output.json new file mode 100644 index 00000000..301337cc --- /dev/null +++ b/tests/fixtures/parser/ast/this-attr01-output.json @@ -0,0 +1,2060 @@ +{ + "type": "Program", + "body": [ + { + "type": "SvelteScriptElement", + "name": { + "type": "SvelteName", + "name": "script", + "range": [ + 1, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 7 + } + } + }, + "startTag": { + "type": "SvelteStartTag", + "attributes": [], + "selfClosing": false, + "range": [ + 0, + 8 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + } + }, + "body": [ + { + "type": "ImportDeclaration", + "source": { + "type": "Literal", + "raw": "'./foo'", + "value": "./foo", + "range": [ + 32, + 39 + ], + "loc": { + "start": { + "line": 2, + "column": 23 + }, + "end": { + "line": 2, + "column": 30 + } + } + }, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "local": { + "type": "Identifier", + "name": "component", + "range": [ + 17, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 17 + } + } + }, + "range": [ + 17, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 17 + } + } + } + ], + "range": [ + 10, + 39 + ], + "loc": { + "start": { + "line": 2, + "column": 1 + }, + "end": { + "line": 2, + "column": 30 + } + } + }, + { + "type": "VariableDeclaration", + "kind": "const", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "style", + "range": [ + 47, + 52 + ], + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 12 + } + } + }, + "init": { + "type": "ObjectExpression", + "properties": [ + { + "type": "Property", + "kind": "init", + "computed": false, + "key": { + "type": "Identifier", + "name": "color", + "range": [ + 57, + 62 + ], + "loc": { + "start": { + "line": 3, + "column": 17 + }, + "end": { + "line": 3, + "column": 22 + } + } + }, + "method": false, + "shorthand": false, + "value": { + "type": "Literal", + "raw": "'red'", + "value": "red", + "range": [ + 64, + 69 + ], + "loc": { + "start": { + "line": 3, + "column": 24 + }, + "end": { + "line": 3, + "column": 29 + } + } + }, + "range": [ + 57, + 69 + ], + "loc": { + "start": { + "line": 3, + "column": 17 + }, + "end": { + "line": 3, + "column": 29 + } + } + } + ], + "range": [ + 55, + 71 + ], + "loc": { + "start": { + "line": 3, + "column": 15 + }, + "end": { + "line": 3, + "column": 31 + } + } + }, + "range": [ + 47, + 71 + ], + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 31 + } + } + } + ], + "range": [ + 41, + 71 + ], + "loc": { + "start": { + "line": 3, + "column": 1 + }, + "end": { + "line": 3, + "column": 31 + } + } + }, + { + "type": "VariableDeclaration", + "kind": "let", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "componentValue", + "range": [ + 77, + 91 + ], + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 19 + } + } + }, + "init": null, + "range": [ + 77, + 91 + ], + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 19 + } + } + } + ], + "range": [ + 73, + 91 + ], + "loc": { + "start": { + "line": 4, + "column": 1 + }, + "end": { + "line": 4, + "column": 19 + } + } + }, + { + "type": "VariableDeclaration", + "kind": "let", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "metaData", + "range": [ + 97, + 105 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 13 + } + } + }, + "init": { + "type": "ObjectExpression", + "properties": [], + "range": [ + 108, + 110 + ], + "loc": { + "start": { + "line": 5, + "column": 16 + }, + "end": { + "line": 5, + "column": 18 + } + } + }, + "range": [ + 97, + 110 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 18 + } + } + } + ], + "range": [ + 93, + 110 + ], + "loc": { + "start": { + "line": 5, + "column": 1 + }, + "end": { + "line": 5, + "column": 18 + } + } + }, + { + "type": "FunctionDeclaration", + "async": false, + "body": { + "type": "BlockStatement", + "body": [], + "range": [ + 136, + 138 + ], + "loc": { + "start": { + "line": 6, + "column": 25 + }, + "end": { + "line": 6, + "column": 27 + } + } + }, + "expression": false, + "generator": false, + "id": { + "type": "Identifier", + "name": "handleChange", + "range": [ + 121, + 133 + ], + "loc": { + "start": { + "line": 6, + "column": 10 + }, + "end": { + "line": 6, + "column": 22 + } + } + }, + "params": [], + "range": [ + 112, + 138 + ], + "loc": { + "start": { + "line": 6, + "column": 1 + }, + "end": { + "line": 6, + "column": 27 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", + "range": [ + 139, + 148 + ], + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 9 + } + } + }, + "range": [ + 0, + 148 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 7, + "column": 9 + } + } + }, + { + "type": "SvelteText", + "value": "\n\n", + "range": [ + 148, + 150 + ], + "loc": { + "start": { + "line": 7, + "column": 9 + }, + "end": { + "line": 9, + "column": 0 + } + } + }, + { + "type": "SvelteElement", + "kind": "special", + "name": { + "type": "SvelteName", + "name": "svelte:component", + "range": [ + 151, + 167 + ], + "loc": { + "start": { + "line": 9, + "column": 1 + }, + "end": { + "line": 9, + "column": 17 + } + } + }, + "startTag": { + "type": "SvelteStartTag", + "attributes": [ + { + "type": "SvelteSpecialDirective", + "kind": "this", + "key": { + "type": "SvelteSpecialDirectiveKey", + "range": [ + 169, + 173 + ], + "loc": { + "start": { + "line": 10, + "column": 1 + }, + "end": { + "line": 10, + "column": 5 + } + } + }, + "expression": { + "type": "Identifier", + "name": "component", + "range": [ + 175, + 184 + ], + "loc": { + "start": { + "line": 10, + "column": 7 + }, + "end": { + "line": 10, + "column": 16 + } + } + }, + "range": [ + 169, + 185 + ], + "loc": { + "start": { + "line": 10, + "column": 1 + }, + "end": { + "line": 10, + "column": 17 + } + } + }, + { + "type": "SvelteAttribute", + "key": { + "type": "SvelteName", + "name": "--style-props", + "range": [ + 187, + 200 + ], + "loc": { + "start": { + "line": 11, + "column": 1 + }, + "end": { + "line": 11, + "column": 14 + } + } + }, + "boolean": false, + "value": [ + { + "type": "SvelteMustacheTag", + "kind": "text", + "expression": { + "type": "Identifier", + "name": "style", + "range": [ + 202, + 207 + ], + "loc": { + "start": { + "line": 11, + "column": 16 + }, + "end": { + "line": 11, + "column": 21 + } + } + }, + "range": [ + 201, + 208 + ], + "loc": { + "start": { + "line": 11, + "column": 15 + }, + "end": { + "line": 11, + "column": 22 + } + } + } + ], + "range": [ + 187, + 208 + ], + "loc": { + "start": { + "line": 11, + "column": 1 + }, + "end": { + "line": 11, + "column": 22 + } + } + }, + { + "type": "SvelteDirective", + "kind": "Binding", + "key": { + "type": "SvelteDirectiveKey", + "name": { + "type": "SvelteName", + "name": "value", + "range": [ + 215, + 220 + ], + "loc": { + "start": { + "line": 12, + "column": 6 + }, + "end": { + "line": 12, + "column": 11 + } + } + }, + "modifiers": [], + "range": [ + 210, + 220 + ], + "loc": { + "start": { + "line": 12, + "column": 1 + }, + "end": { + "line": 12, + "column": 11 + } + } + }, + "expression": { + "type": "Identifier", + "name": "componentValue", + "range": [ + 222, + 236 + ], + "loc": { + "start": { + "line": 12, + "column": 13 + }, + "end": { + "line": 12, + "column": 27 + } + } + }, + "shorthand": false, + "range": [ + 210, + 237 + ], + "loc": { + "start": { + "line": 12, + "column": 1 + }, + "end": { + "line": 12, + "column": 28 + } + } + }, + { + "type": "SvelteDirective", + "kind": "EventHandler", + "key": { + "type": "SvelteDirectiveKey", + "name": { + "type": "SvelteName", + "name": "changeValue", + "range": [ + 242, + 253 + ], + "loc": { + "start": { + "line": 13, + "column": 4 + }, + "end": { + "line": 13, + "column": 15 + } + } + }, + "modifiers": [], + "range": [ + 239, + 253 + ], + "loc": { + "start": { + "line": 13, + "column": 1 + }, + "end": { + "line": 13, + "column": 15 + } + } + }, + "expression": { + "type": "Identifier", + "name": "handleChange", + "range": [ + 255, + 267 + ], + "loc": { + "start": { + "line": 13, + "column": 17 + }, + "end": { + "line": 13, + "column": 29 + } + } + }, + "range": [ + 239, + 268 + ], + "loc": { + "start": { + "line": 13, + "column": 1 + }, + "end": { + "line": 13, + "column": 30 + } + } + }, + { + "type": "SvelteDirective", + "kind": "Binding", + "key": { + "type": "SvelteDirectiveKey", + "name": { + "type": "SvelteName", + "name": "metaData", + "range": [ + 275, + 283 + ], + "loc": { + "start": { + "line": 14, + "column": 6 + }, + "end": { + "line": 14, + "column": 14 + } + } + }, + "modifiers": [], + "range": [ + 270, + 283 + ], + "loc": { + "start": { + "line": 14, + "column": 1 + }, + "end": { + "line": 14, + "column": 14 + } + } + }, + "expression": { + "type": "Identifier", + "name": "metaData", + "range": [ + 275, + 283 + ], + "loc": { + "start": { + "line": 14, + "column": 6 + }, + "end": { + "line": 14, + "column": 14 + } + } + }, + "shorthand": true, + "range": [ + 270, + 283 + ], + "loc": { + "start": { + "line": 14, + "column": 1 + }, + "end": { + "line": 14, + "column": 14 + } + } + } + ], + "selfClosing": true, + "range": [ + 150, + 286 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 15, + "column": 2 + } + } + }, + "children": [], + "endTag": null, + "range": [ + 150, + 286 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 15, + "column": 2 + } + } + } + ], + "sourceType": "module", + "comments": [], + "tokens": [ + { + "type": "Punctuator", + "value": "<", + "range": [ + 0, + 1 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "script", + "range": [ + 1, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 7 + } + } + }, + { + "type": "Punctuator", + "value": ">", + "range": [ + 7, + 8 + ], + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + } + }, + { + "type": "Keyword", + "value": "import", + "range": [ + 10, + 16 + ], + "loc": { + "start": { + "line": 2, + "column": 1 + }, + "end": { + "line": 2, + "column": 7 + } + } + }, + { + "type": "Identifier", + "value": "component", + "range": [ + 17, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 17 + } + } + }, + { + "type": "Identifier", + "value": "from", + "range": [ + 27, + 31 + ], + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 22 + } + } + }, + { + "type": "String", + "value": "'./foo'", + "range": [ + 32, + 39 + ], + "loc": { + "start": { + "line": 2, + "column": 23 + }, + "end": { + "line": 2, + "column": 30 + } + } + }, + { + "type": "Keyword", + "value": "const", + "range": [ + 41, + 46 + ], + "loc": { + "start": { + "line": 3, + "column": 1 + }, + "end": { + "line": 3, + "column": 6 + } + } + }, + { + "type": "Identifier", + "value": "style", + "range": [ + 47, + 52 + ], + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 12 + } + } + }, + { + "type": "Punctuator", + "value": "=", + "range": [ + 53, + 54 + ], + "loc": { + "start": { + "line": 3, + "column": 13 + }, + "end": { + "line": 3, + "column": 14 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 55, + 56 + ], + "loc": { + "start": { + "line": 3, + "column": 15 + }, + "end": { + "line": 3, + "column": 16 + } + } + }, + { + "type": "Identifier", + "value": "color", + "range": [ + 57, + 62 + ], + "loc": { + "start": { + "line": 3, + "column": 17 + }, + "end": { + "line": 3, + "column": 22 + } + } + }, + { + "type": "Punctuator", + "value": ":", + "range": [ + 62, + 63 + ], + "loc": { + "start": { + "line": 3, + "column": 22 + }, + "end": { + "line": 3, + "column": 23 + } + } + }, + { + "type": "String", + "value": "'red'", + "range": [ + 64, + 69 + ], + "loc": { + "start": { + "line": 3, + "column": 24 + }, + "end": { + "line": 3, + "column": 29 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 70, + 71 + ], + "loc": { + "start": { + "line": 3, + "column": 30 + }, + "end": { + "line": 3, + "column": 31 + } + } + }, + { + "type": "Keyword", + "value": "let", + "range": [ + 73, + 76 + ], + "loc": { + "start": { + "line": 4, + "column": 1 + }, + "end": { + "line": 4, + "column": 4 + } + } + }, + { + "type": "Identifier", + "value": "componentValue", + "range": [ + 77, + 91 + ], + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 19 + } + } + }, + { + "type": "Keyword", + "value": "let", + "range": [ + 93, + 96 + ], + "loc": { + "start": { + "line": 5, + "column": 1 + }, + "end": { + "line": 5, + "column": 4 + } + } + }, + { + "type": "Identifier", + "value": "metaData", + "range": [ + 97, + 105 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 13 + } + } + }, + { + "type": "Punctuator", + "value": "=", + "range": [ + 106, + 107 + ], + "loc": { + "start": { + "line": 5, + "column": 14 + }, + "end": { + "line": 5, + "column": 15 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 108, + 109 + ], + "loc": { + "start": { + "line": 5, + "column": 16 + }, + "end": { + "line": 5, + "column": 17 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 109, + 110 + ], + "loc": { + "start": { + "line": 5, + "column": 17 + }, + "end": { + "line": 5, + "column": 18 + } + } + }, + { + "type": "Keyword", + "value": "function", + "range": [ + 112, + 120 + ], + "loc": { + "start": { + "line": 6, + "column": 1 + }, + "end": { + "line": 6, + "column": 9 + } + } + }, + { + "type": "Identifier", + "value": "handleChange", + "range": [ + 121, + 133 + ], + "loc": { + "start": { + "line": 6, + "column": 10 + }, + "end": { + "line": 6, + "column": 22 + } + } + }, + { + "type": "Punctuator", + "value": "(", + "range": [ + 133, + 134 + ], + "loc": { + "start": { + "line": 6, + "column": 22 + }, + "end": { + "line": 6, + "column": 23 + } + } + }, + { + "type": "Punctuator", + "value": ")", + "range": [ + 134, + 135 + ], + "loc": { + "start": { + "line": 6, + "column": 23 + }, + "end": { + "line": 6, + "column": 24 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 136, + 137 + ], + "loc": { + "start": { + "line": 6, + "column": 25 + }, + "end": { + "line": 6, + "column": 26 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 137, + 138 + ], + "loc": { + "start": { + "line": 6, + "column": 26 + }, + "end": { + "line": 6, + "column": 27 + } + } + }, + { + "type": "Punctuator", + "value": "<", + "range": [ + 139, + 140 + ], + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 1 + } + } + }, + { + "type": "Punctuator", + "value": "/", + "range": [ + 140, + 141 + ], + "loc": { + "start": { + "line": 7, + "column": 1 + }, + "end": { + "line": 7, + "column": 2 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "script", + "range": [ + 141, + 147 + ], + "loc": { + "start": { + "line": 7, + "column": 2 + }, + "end": { + "line": 7, + "column": 8 + } + } + }, + { + "type": "Punctuator", + "value": ">", + "range": [ + 147, + 148 + ], + "loc": { + "start": { + "line": 7, + "column": 8 + }, + "end": { + "line": 7, + "column": 9 + } + } + }, + { + "type": "HTMLText", + "value": "\n\n", + "range": [ + 148, + 150 + ], + "loc": { + "start": { + "line": 7, + "column": 9 + }, + "end": { + "line": 9, + "column": 0 + } + } + }, + { + "type": "Punctuator", + "value": "<", + "range": [ + 150, + 151 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 1 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "svelte:component", + "range": [ + 151, + 167 + ], + "loc": { + "start": { + "line": 9, + "column": 1 + }, + "end": { + "line": 9, + "column": 17 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "this", + "range": [ + 169, + 173 + ], + "loc": { + "start": { + "line": 10, + "column": 1 + }, + "end": { + "line": 10, + "column": 5 + } + } + }, + { + "type": "Punctuator", + "value": "=", + "range": [ + 173, + 174 + ], + "loc": { + "start": { + "line": 10, + "column": 5 + }, + "end": { + "line": 10, + "column": 6 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 174, + 175 + ], + "loc": { + "start": { + "line": 10, + "column": 6 + }, + "end": { + "line": 10, + "column": 7 + } + } + }, + { + "type": "Identifier", + "value": "component", + "range": [ + 175, + 184 + ], + "loc": { + "start": { + "line": 10, + "column": 7 + }, + "end": { + "line": 10, + "column": 16 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 184, + 185 + ], + "loc": { + "start": { + "line": 10, + "column": 16 + }, + "end": { + "line": 10, + "column": 17 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "--style-props", + "range": [ + 187, + 200 + ], + "loc": { + "start": { + "line": 11, + "column": 1 + }, + "end": { + "line": 11, + "column": 14 + } + } + }, + { + "type": "Punctuator", + "value": "=", + "range": [ + 200, + 201 + ], + "loc": { + "start": { + "line": 11, + "column": 14 + }, + "end": { + "line": 11, + "column": 15 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 201, + 202 + ], + "loc": { + "start": { + "line": 11, + "column": 15 + }, + "end": { + "line": 11, + "column": 16 + } + } + }, + { + "type": "Identifier", + "value": "style", + "range": [ + 202, + 207 + ], + "loc": { + "start": { + "line": 11, + "column": 16 + }, + "end": { + "line": 11, + "column": 21 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 207, + 208 + ], + "loc": { + "start": { + "line": 11, + "column": 21 + }, + "end": { + "line": 11, + "column": 22 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "bind", + "range": [ + 210, + 214 + ], + "loc": { + "start": { + "line": 12, + "column": 1 + }, + "end": { + "line": 12, + "column": 5 + } + } + }, + { + "type": "Punctuator", + "value": ":", + "range": [ + 214, + 215 + ], + "loc": { + "start": { + "line": 12, + "column": 5 + }, + "end": { + "line": 12, + "column": 6 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "value", + "range": [ + 215, + 220 + ], + "loc": { + "start": { + "line": 12, + "column": 6 + }, + "end": { + "line": 12, + "column": 11 + } + } + }, + { + "type": "Punctuator", + "value": "=", + "range": [ + 220, + 221 + ], + "loc": { + "start": { + "line": 12, + "column": 11 + }, + "end": { + "line": 12, + "column": 12 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 221, + 222 + ], + "loc": { + "start": { + "line": 12, + "column": 12 + }, + "end": { + "line": 12, + "column": 13 + } + } + }, + { + "type": "Identifier", + "value": "componentValue", + "range": [ + 222, + 236 + ], + "loc": { + "start": { + "line": 12, + "column": 13 + }, + "end": { + "line": 12, + "column": 27 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 236, + 237 + ], + "loc": { + "start": { + "line": 12, + "column": 27 + }, + "end": { + "line": 12, + "column": 28 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "on", + "range": [ + 239, + 241 + ], + "loc": { + "start": { + "line": 13, + "column": 1 + }, + "end": { + "line": 13, + "column": 3 + } + } + }, + { + "type": "Punctuator", + "value": ":", + "range": [ + 241, + 242 + ], + "loc": { + "start": { + "line": 13, + "column": 3 + }, + "end": { + "line": 13, + "column": 4 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "changeValue", + "range": [ + 242, + 253 + ], + "loc": { + "start": { + "line": 13, + "column": 4 + }, + "end": { + "line": 13, + "column": 15 + } + } + }, + { + "type": "Punctuator", + "value": "=", + "range": [ + 253, + 254 + ], + "loc": { + "start": { + "line": 13, + "column": 15 + }, + "end": { + "line": 13, + "column": 16 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 254, + 255 + ], + "loc": { + "start": { + "line": 13, + "column": 16 + }, + "end": { + "line": 13, + "column": 17 + } + } + }, + { + "type": "Identifier", + "value": "handleChange", + "range": [ + 255, + 267 + ], + "loc": { + "start": { + "line": 13, + "column": 17 + }, + "end": { + "line": 13, + "column": 29 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 267, + 268 + ], + "loc": { + "start": { + "line": 13, + "column": 29 + }, + "end": { + "line": 13, + "column": 30 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "bind", + "range": [ + 270, + 274 + ], + "loc": { + "start": { + "line": 14, + "column": 1 + }, + "end": { + "line": 14, + "column": 5 + } + } + }, + { + "type": "Punctuator", + "value": ":", + "range": [ + 274, + 275 + ], + "loc": { + "start": { + "line": 14, + "column": 5 + }, + "end": { + "line": 14, + "column": 6 + } + } + }, + { + "type": "Identifier", + "value": "metaData", + "range": [ + 275, + 283 + ], + "loc": { + "start": { + "line": 14, + "column": 6 + }, + "end": { + "line": 14, + "column": 14 + } + } + }, + { + "type": "Punctuator", + "value": "/", + "range": [ + 284, + 285 + ], + "loc": { + "start": { + "line": 15, + "column": 0 + }, + "end": { + "line": 15, + "column": 1 + } + } + }, + { + "type": "Punctuator", + "value": ">", + "range": [ + 285, + 286 + ], + "loc": { + "start": { + "line": 15, + "column": 1 + }, + "end": { + "line": 15, + "column": 2 + } + } + } + ], + "range": [ + 0, + 286 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 15, + "column": 2 + } + } +} \ No newline at end of file diff --git a/tests/fixtures/parser/ast/this-attr01-scope-output.json b/tests/fixtures/parser/ast/this-attr01-scope-output.json new file mode 100644 index 00000000..b728cf65 --- /dev/null +++ b/tests/fixtures/parser/ast/this-attr01-scope-output.json @@ -0,0 +1,1144 @@ +{ + "type": "global", + "variables": [ + { + "name": "$$slots", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$$props", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$$restProps", + "identifiers": [], + "defs": [], + "references": [] + } + ], + "references": [], + "childScopes": [ + { + "type": "module", + "variables": [ + { + "name": "component", + "identifiers": [ + { + "type": "Identifier", + "name": "component", + "range": [ + 17, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 17 + } + } + } + ], + "defs": [ + { + "type": "ImportBinding", + "name": { + "type": "Identifier", + "name": "component", + "range": [ + 17, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 17 + } + } + }, + "node": { + "type": "ImportDefaultSpecifier", + "local": { + "type": "Identifier", + "name": "component", + "range": [ + 17, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 17 + } + } + }, + "range": [ + 17, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 17 + } + } + } + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "component", + "range": [ + 175, + 184 + ], + "loc": { + "start": { + "line": 10, + "column": 7 + }, + "end": { + "line": 10, + "column": 16 + } + } + }, + "from": "module", + "init": null, + "resolved": { + "type": "Identifier", + "name": "component", + "range": [ + 17, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 17 + } + } + } + } + ] + }, + { + "name": "style", + "identifiers": [ + { + "type": "Identifier", + "name": "style", + "range": [ + 47, + 52 + ], + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 12 + } + } + } + ], + "defs": [ + { + "type": "Variable", + "name": { + "type": "Identifier", + "name": "style", + "range": [ + 47, + 52 + ], + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 12 + } + } + }, + "node": { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "style", + "range": [ + 47, + 52 + ], + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 12 + } + } + }, + "init": { + "type": "ObjectExpression", + "properties": [ + { + "type": "Property", + "kind": "init", + "computed": false, + "key": { + "type": "Identifier", + "name": "color", + "range": [ + 57, + 62 + ], + "loc": { + "start": { + "line": 3, + "column": 17 + }, + "end": { + "line": 3, + "column": 22 + } + } + }, + "method": false, + "shorthand": false, + "value": { + "type": "Literal", + "raw": "'red'", + "value": "red", + "range": [ + 64, + 69 + ], + "loc": { + "start": { + "line": 3, + "column": 24 + }, + "end": { + "line": 3, + "column": 29 + } + } + }, + "range": [ + 57, + 69 + ], + "loc": { + "start": { + "line": 3, + "column": 17 + }, + "end": { + "line": 3, + "column": 29 + } + } + } + ], + "range": [ + 55, + 71 + ], + "loc": { + "start": { + "line": 3, + "column": 15 + }, + "end": { + "line": 3, + "column": 31 + } + } + }, + "range": [ + 47, + 71 + ], + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 31 + } + } + } + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "style", + "range": [ + 47, + 52 + ], + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 12 + } + } + }, + "from": "module", + "init": true, + "resolved": { + "type": "Identifier", + "name": "style", + "range": [ + 47, + 52 + ], + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 12 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "style", + "range": [ + 202, + 207 + ], + "loc": { + "start": { + "line": 11, + "column": 16 + }, + "end": { + "line": 11, + "column": 21 + } + } + }, + "from": "module", + "init": null, + "resolved": { + "type": "Identifier", + "name": "style", + "range": [ + 47, + 52 + ], + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 12 + } + } + } + } + ] + }, + { + "name": "componentValue", + "identifiers": [ + { + "type": "Identifier", + "name": "componentValue", + "range": [ + 77, + 91 + ], + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 19 + } + } + } + ], + "defs": [ + { + "type": "Variable", + "name": { + "type": "Identifier", + "name": "componentValue", + "range": [ + 77, + 91 + ], + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 19 + } + } + }, + "node": { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "componentValue", + "range": [ + 77, + 91 + ], + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 19 + } + } + }, + "init": null, + "range": [ + 77, + 91 + ], + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 19 + } + } + } + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "componentValue", + "range": [ + 222, + 236 + ], + "loc": { + "start": { + "line": 12, + "column": 13 + }, + "end": { + "line": 12, + "column": 27 + } + } + }, + "from": "module", + "init": null, + "resolved": { + "type": "Identifier", + "name": "componentValue", + "range": [ + 77, + 91 + ], + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 19 + } + } + } + } + ] + }, + { + "name": "metaData", + "identifiers": [ + { + "type": "Identifier", + "name": "metaData", + "range": [ + 97, + 105 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 13 + } + } + } + ], + "defs": [ + { + "type": "Variable", + "name": { + "type": "Identifier", + "name": "metaData", + "range": [ + 97, + 105 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 13 + } + } + }, + "node": { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "metaData", + "range": [ + 97, + 105 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 13 + } + } + }, + "init": { + "type": "ObjectExpression", + "properties": [], + "range": [ + 108, + 110 + ], + "loc": { + "start": { + "line": 5, + "column": 16 + }, + "end": { + "line": 5, + "column": 18 + } + } + }, + "range": [ + 97, + 110 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 18 + } + } + } + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "metaData", + "range": [ + 97, + 105 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 13 + } + } + }, + "from": "module", + "init": true, + "resolved": { + "type": "Identifier", + "name": "metaData", + "range": [ + 97, + 105 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 13 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "metaData", + "range": [ + 275, + 283 + ], + "loc": { + "start": { + "line": 14, + "column": 6 + }, + "end": { + "line": 14, + "column": 14 + } + } + }, + "from": "module", + "init": null, + "resolved": { + "type": "Identifier", + "name": "metaData", + "range": [ + 97, + 105 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 13 + } + } + } + } + ] + }, + { + "name": "handleChange", + "identifiers": [ + { + "type": "Identifier", + "name": "handleChange", + "range": [ + 121, + 133 + ], + "loc": { + "start": { + "line": 6, + "column": 10 + }, + "end": { + "line": 6, + "column": 22 + } + } + } + ], + "defs": [ + { + "type": "FunctionName", + "name": { + "type": "Identifier", + "name": "handleChange", + "range": [ + 121, + 133 + ], + "loc": { + "start": { + "line": 6, + "column": 10 + }, + "end": { + "line": 6, + "column": 22 + } + } + }, + "node": { + "type": "FunctionDeclaration", + "async": false, + "body": { + "type": "BlockStatement", + "body": [], + "range": [ + 136, + 138 + ], + "loc": { + "start": { + "line": 6, + "column": 25 + }, + "end": { + "line": 6, + "column": 27 + } + } + }, + "expression": false, + "generator": false, + "id": { + "type": "Identifier", + "name": "handleChange", + "range": [ + 121, + 133 + ], + "loc": { + "start": { + "line": 6, + "column": 10 + }, + "end": { + "line": 6, + "column": 22 + } + } + }, + "params": [], + "range": [ + 112, + 138 + ], + "loc": { + "start": { + "line": 6, + "column": 1 + }, + "end": { + "line": 6, + "column": 27 + } + } + } + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "handleChange", + "range": [ + 255, + 267 + ], + "loc": { + "start": { + "line": 13, + "column": 17 + }, + "end": { + "line": 13, + "column": 29 + } + } + }, + "from": "module", + "init": null, + "resolved": { + "type": "Identifier", + "name": "handleChange", + "range": [ + 121, + 133 + ], + "loc": { + "start": { + "line": 6, + "column": 10 + }, + "end": { + "line": 6, + "column": 22 + } + } + } + } + ] + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "style", + "range": [ + 47, + 52 + ], + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 12 + } + } + }, + "from": "module", + "init": true, + "resolved": { + "type": "Identifier", + "name": "style", + "range": [ + 47, + 52 + ], + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 12 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "metaData", + "range": [ + 97, + 105 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 13 + } + } + }, + "from": "module", + "init": true, + "resolved": { + "type": "Identifier", + "name": "metaData", + "range": [ + 97, + 105 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 13 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "style", + "range": [ + 202, + 207 + ], + "loc": { + "start": { + "line": 11, + "column": 16 + }, + "end": { + "line": 11, + "column": 21 + } + } + }, + "from": "module", + "init": null, + "resolved": { + "type": "Identifier", + "name": "style", + "range": [ + 47, + 52 + ], + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 12 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "componentValue", + "range": [ + 222, + 236 + ], + "loc": { + "start": { + "line": 12, + "column": 13 + }, + "end": { + "line": 12, + "column": 27 + } + } + }, + "from": "module", + "init": null, + "resolved": { + "type": "Identifier", + "name": "componentValue", + "range": [ + 77, + 91 + ], + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 19 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "handleChange", + "range": [ + 255, + 267 + ], + "loc": { + "start": { + "line": 13, + "column": 17 + }, + "end": { + "line": 13, + "column": 29 + } + } + }, + "from": "module", + "init": null, + "resolved": { + "type": "Identifier", + "name": "handleChange", + "range": [ + 121, + 133 + ], + "loc": { + "start": { + "line": 6, + "column": 10 + }, + "end": { + "line": 6, + "column": 22 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "metaData", + "range": [ + 275, + 283 + ], + "loc": { + "start": { + "line": 14, + "column": 6 + }, + "end": { + "line": 14, + "column": 14 + } + } + }, + "from": "module", + "init": null, + "resolved": { + "type": "Identifier", + "name": "metaData", + "range": [ + 97, + 105 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 13 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "component", + "range": [ + 175, + 184 + ], + "loc": { + "start": { + "line": 10, + "column": 7 + }, + "end": { + "line": 10, + "column": 16 + } + } + }, + "from": "module", + "init": null, + "resolved": { + "type": "Identifier", + "name": "component", + "range": [ + 17, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 17 + } + } + } + } + ], + "childScopes": [ + { + "type": "function", + "variables": [ + { + "name": "arguments", + "identifiers": [], + "defs": [], + "references": [] + } + ], + "references": [], + "childScopes": [], + "through": [] + } + ], + "through": [] + } + ], + "through": [] +} \ No newline at end of file diff --git a/tests/fixtures/parser/ast/this-attr02-input.svelte b/tests/fixtures/parser/ast/this-attr02-input.svelte new file mode 100644 index 00000000..9e701ab7 --- /dev/null +++ b/tests/fixtures/parser/ast/this-attr02-input.svelte @@ -0,0 +1,15 @@ + + + \ No newline at end of file diff --git a/tests/fixtures/parser/ast/this-attr02-output.json b/tests/fixtures/parser/ast/this-attr02-output.json new file mode 100644 index 00000000..73079c24 --- /dev/null +++ b/tests/fixtures/parser/ast/this-attr02-output.json @@ -0,0 +1,2060 @@ +{ + "type": "Program", + "body": [ + { + "type": "SvelteScriptElement", + "name": { + "type": "SvelteName", + "name": "script", + "range": [ + 1, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 7 + } + } + }, + "startTag": { + "type": "SvelteStartTag", + "attributes": [], + "selfClosing": false, + "range": [ + 0, + 8 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + } + }, + "body": [ + { + "type": "ImportDeclaration", + "source": { + "type": "Literal", + "raw": "'./foo'", + "value": "./foo", + "range": [ + 32, + 39 + ], + "loc": { + "start": { + "line": 2, + "column": 23 + }, + "end": { + "line": 2, + "column": 30 + } + } + }, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "local": { + "type": "Identifier", + "name": "component", + "range": [ + 17, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 17 + } + } + }, + "range": [ + 17, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 17 + } + } + } + ], + "range": [ + 10, + 39 + ], + "loc": { + "start": { + "line": 2, + "column": 1 + }, + "end": { + "line": 2, + "column": 30 + } + } + }, + { + "type": "VariableDeclaration", + "kind": "const", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "style", + "range": [ + 47, + 52 + ], + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 12 + } + } + }, + "init": { + "type": "ObjectExpression", + "properties": [ + { + "type": "Property", + "kind": "init", + "computed": false, + "key": { + "type": "Identifier", + "name": "color", + "range": [ + 57, + 62 + ], + "loc": { + "start": { + "line": 3, + "column": 17 + }, + "end": { + "line": 3, + "column": 22 + } + } + }, + "method": false, + "shorthand": false, + "value": { + "type": "Literal", + "raw": "'red'", + "value": "red", + "range": [ + 64, + 69 + ], + "loc": { + "start": { + "line": 3, + "column": 24 + }, + "end": { + "line": 3, + "column": 29 + } + } + }, + "range": [ + 57, + 69 + ], + "loc": { + "start": { + "line": 3, + "column": 17 + }, + "end": { + "line": 3, + "column": 29 + } + } + } + ], + "range": [ + 55, + 71 + ], + "loc": { + "start": { + "line": 3, + "column": 15 + }, + "end": { + "line": 3, + "column": 31 + } + } + }, + "range": [ + 47, + 71 + ], + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 31 + } + } + } + ], + "range": [ + 41, + 71 + ], + "loc": { + "start": { + "line": 3, + "column": 1 + }, + "end": { + "line": 3, + "column": 31 + } + } + }, + { + "type": "VariableDeclaration", + "kind": "let", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "componentValue", + "range": [ + 77, + 91 + ], + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 19 + } + } + }, + "init": null, + "range": [ + 77, + 91 + ], + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 19 + } + } + } + ], + "range": [ + 73, + 91 + ], + "loc": { + "start": { + "line": 4, + "column": 1 + }, + "end": { + "line": 4, + "column": 19 + } + } + }, + { + "type": "VariableDeclaration", + "kind": "let", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "metaData", + "range": [ + 97, + 105 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 13 + } + } + }, + "init": { + "type": "ObjectExpression", + "properties": [], + "range": [ + 108, + 110 + ], + "loc": { + "start": { + "line": 5, + "column": 16 + }, + "end": { + "line": 5, + "column": 18 + } + } + }, + "range": [ + 97, + 110 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 18 + } + } + } + ], + "range": [ + 93, + 110 + ], + "loc": { + "start": { + "line": 5, + "column": 1 + }, + "end": { + "line": 5, + "column": 18 + } + } + }, + { + "type": "FunctionDeclaration", + "async": false, + "body": { + "type": "BlockStatement", + "body": [], + "range": [ + 136, + 138 + ], + "loc": { + "start": { + "line": 6, + "column": 25 + }, + "end": { + "line": 6, + "column": 27 + } + } + }, + "expression": false, + "generator": false, + "id": { + "type": "Identifier", + "name": "handleChange", + "range": [ + 121, + 133 + ], + "loc": { + "start": { + "line": 6, + "column": 10 + }, + "end": { + "line": 6, + "column": 22 + } + } + }, + "params": [], + "range": [ + 112, + 138 + ], + "loc": { + "start": { + "line": 6, + "column": 1 + }, + "end": { + "line": 6, + "column": 27 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", + "range": [ + 139, + 148 + ], + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 9 + } + } + }, + "range": [ + 0, + 148 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 7, + "column": 9 + } + } + }, + { + "type": "SvelteText", + "value": "\n\n", + "range": [ + 148, + 150 + ], + "loc": { + "start": { + "line": 7, + "column": 9 + }, + "end": { + "line": 9, + "column": 0 + } + } + }, + { + "type": "SvelteElement", + "kind": "special", + "name": { + "type": "SvelteName", + "name": "svelte:component", + "range": [ + 151, + 167 + ], + "loc": { + "start": { + "line": 9, + "column": 1 + }, + "end": { + "line": 9, + "column": 17 + } + } + }, + "startTag": { + "type": "SvelteStartTag", + "attributes": [ + { + "type": "SvelteAttribute", + "key": { + "type": "SvelteName", + "name": "--style-props", + "range": [ + 169, + 182 + ], + "loc": { + "start": { + "line": 10, + "column": 1 + }, + "end": { + "line": 10, + "column": 14 + } + } + }, + "boolean": false, + "value": [ + { + "type": "SvelteMustacheTag", + "kind": "text", + "expression": { + "type": "Identifier", + "name": "style", + "range": [ + 184, + 189 + ], + "loc": { + "start": { + "line": 10, + "column": 16 + }, + "end": { + "line": 10, + "column": 21 + } + } + }, + "range": [ + 183, + 190 + ], + "loc": { + "start": { + "line": 10, + "column": 15 + }, + "end": { + "line": 10, + "column": 22 + } + } + } + ], + "range": [ + 169, + 190 + ], + "loc": { + "start": { + "line": 10, + "column": 1 + }, + "end": { + "line": 10, + "column": 22 + } + } + }, + { + "type": "SvelteDirective", + "kind": "Binding", + "key": { + "type": "SvelteDirectiveKey", + "name": { + "type": "SvelteName", + "name": "value", + "range": [ + 197, + 202 + ], + "loc": { + "start": { + "line": 11, + "column": 6 + }, + "end": { + "line": 11, + "column": 11 + } + } + }, + "modifiers": [], + "range": [ + 192, + 202 + ], + "loc": { + "start": { + "line": 11, + "column": 1 + }, + "end": { + "line": 11, + "column": 11 + } + } + }, + "expression": { + "type": "Identifier", + "name": "componentValue", + "range": [ + 204, + 218 + ], + "loc": { + "start": { + "line": 11, + "column": 13 + }, + "end": { + "line": 11, + "column": 27 + } + } + }, + "shorthand": false, + "range": [ + 192, + 219 + ], + "loc": { + "start": { + "line": 11, + "column": 1 + }, + "end": { + "line": 11, + "column": 28 + } + } + }, + { + "type": "SvelteSpecialDirective", + "kind": "this", + "key": { + "type": "SvelteSpecialDirectiveKey", + "range": [ + 221, + 225 + ], + "loc": { + "start": { + "line": 12, + "column": 1 + }, + "end": { + "line": 12, + "column": 5 + } + } + }, + "expression": { + "type": "Identifier", + "name": "component", + "range": [ + 227, + 236 + ], + "loc": { + "start": { + "line": 12, + "column": 7 + }, + "end": { + "line": 12, + "column": 16 + } + } + }, + "range": [ + 221, + 237 + ], + "loc": { + "start": { + "line": 12, + "column": 1 + }, + "end": { + "line": 12, + "column": 17 + } + } + }, + { + "type": "SvelteDirective", + "kind": "EventHandler", + "key": { + "type": "SvelteDirectiveKey", + "name": { + "type": "SvelteName", + "name": "changeValue", + "range": [ + 242, + 253 + ], + "loc": { + "start": { + "line": 13, + "column": 4 + }, + "end": { + "line": 13, + "column": 15 + } + } + }, + "modifiers": [], + "range": [ + 239, + 253 + ], + "loc": { + "start": { + "line": 13, + "column": 1 + }, + "end": { + "line": 13, + "column": 15 + } + } + }, + "expression": { + "type": "Identifier", + "name": "handleChange", + "range": [ + 255, + 267 + ], + "loc": { + "start": { + "line": 13, + "column": 17 + }, + "end": { + "line": 13, + "column": 29 + } + } + }, + "range": [ + 239, + 268 + ], + "loc": { + "start": { + "line": 13, + "column": 1 + }, + "end": { + "line": 13, + "column": 30 + } + } + }, + { + "type": "SvelteDirective", + "kind": "Binding", + "key": { + "type": "SvelteDirectiveKey", + "name": { + "type": "SvelteName", + "name": "metaData", + "range": [ + 275, + 283 + ], + "loc": { + "start": { + "line": 14, + "column": 6 + }, + "end": { + "line": 14, + "column": 14 + } + } + }, + "modifiers": [], + "range": [ + 270, + 283 + ], + "loc": { + "start": { + "line": 14, + "column": 1 + }, + "end": { + "line": 14, + "column": 14 + } + } + }, + "expression": { + "type": "Identifier", + "name": "metaData", + "range": [ + 275, + 283 + ], + "loc": { + "start": { + "line": 14, + "column": 6 + }, + "end": { + "line": 14, + "column": 14 + } + } + }, + "shorthand": true, + "range": [ + 270, + 283 + ], + "loc": { + "start": { + "line": 14, + "column": 1 + }, + "end": { + "line": 14, + "column": 14 + } + } + } + ], + "selfClosing": true, + "range": [ + 150, + 286 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 15, + "column": 2 + } + } + }, + "children": [], + "endTag": null, + "range": [ + 150, + 286 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 15, + "column": 2 + } + } + } + ], + "sourceType": "module", + "comments": [], + "tokens": [ + { + "type": "Punctuator", + "value": "<", + "range": [ + 0, + 1 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "script", + "range": [ + 1, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 7 + } + } + }, + { + "type": "Punctuator", + "value": ">", + "range": [ + 7, + 8 + ], + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + } + }, + { + "type": "Keyword", + "value": "import", + "range": [ + 10, + 16 + ], + "loc": { + "start": { + "line": 2, + "column": 1 + }, + "end": { + "line": 2, + "column": 7 + } + } + }, + { + "type": "Identifier", + "value": "component", + "range": [ + 17, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 17 + } + } + }, + { + "type": "Identifier", + "value": "from", + "range": [ + 27, + 31 + ], + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 22 + } + } + }, + { + "type": "String", + "value": "'./foo'", + "range": [ + 32, + 39 + ], + "loc": { + "start": { + "line": 2, + "column": 23 + }, + "end": { + "line": 2, + "column": 30 + } + } + }, + { + "type": "Keyword", + "value": "const", + "range": [ + 41, + 46 + ], + "loc": { + "start": { + "line": 3, + "column": 1 + }, + "end": { + "line": 3, + "column": 6 + } + } + }, + { + "type": "Identifier", + "value": "style", + "range": [ + 47, + 52 + ], + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 12 + } + } + }, + { + "type": "Punctuator", + "value": "=", + "range": [ + 53, + 54 + ], + "loc": { + "start": { + "line": 3, + "column": 13 + }, + "end": { + "line": 3, + "column": 14 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 55, + 56 + ], + "loc": { + "start": { + "line": 3, + "column": 15 + }, + "end": { + "line": 3, + "column": 16 + } + } + }, + { + "type": "Identifier", + "value": "color", + "range": [ + 57, + 62 + ], + "loc": { + "start": { + "line": 3, + "column": 17 + }, + "end": { + "line": 3, + "column": 22 + } + } + }, + { + "type": "Punctuator", + "value": ":", + "range": [ + 62, + 63 + ], + "loc": { + "start": { + "line": 3, + "column": 22 + }, + "end": { + "line": 3, + "column": 23 + } + } + }, + { + "type": "String", + "value": "'red'", + "range": [ + 64, + 69 + ], + "loc": { + "start": { + "line": 3, + "column": 24 + }, + "end": { + "line": 3, + "column": 29 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 70, + 71 + ], + "loc": { + "start": { + "line": 3, + "column": 30 + }, + "end": { + "line": 3, + "column": 31 + } + } + }, + { + "type": "Keyword", + "value": "let", + "range": [ + 73, + 76 + ], + "loc": { + "start": { + "line": 4, + "column": 1 + }, + "end": { + "line": 4, + "column": 4 + } + } + }, + { + "type": "Identifier", + "value": "componentValue", + "range": [ + 77, + 91 + ], + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 19 + } + } + }, + { + "type": "Keyword", + "value": "let", + "range": [ + 93, + 96 + ], + "loc": { + "start": { + "line": 5, + "column": 1 + }, + "end": { + "line": 5, + "column": 4 + } + } + }, + { + "type": "Identifier", + "value": "metaData", + "range": [ + 97, + 105 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 13 + } + } + }, + { + "type": "Punctuator", + "value": "=", + "range": [ + 106, + 107 + ], + "loc": { + "start": { + "line": 5, + "column": 14 + }, + "end": { + "line": 5, + "column": 15 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 108, + 109 + ], + "loc": { + "start": { + "line": 5, + "column": 16 + }, + "end": { + "line": 5, + "column": 17 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 109, + 110 + ], + "loc": { + "start": { + "line": 5, + "column": 17 + }, + "end": { + "line": 5, + "column": 18 + } + } + }, + { + "type": "Keyword", + "value": "function", + "range": [ + 112, + 120 + ], + "loc": { + "start": { + "line": 6, + "column": 1 + }, + "end": { + "line": 6, + "column": 9 + } + } + }, + { + "type": "Identifier", + "value": "handleChange", + "range": [ + 121, + 133 + ], + "loc": { + "start": { + "line": 6, + "column": 10 + }, + "end": { + "line": 6, + "column": 22 + } + } + }, + { + "type": "Punctuator", + "value": "(", + "range": [ + 133, + 134 + ], + "loc": { + "start": { + "line": 6, + "column": 22 + }, + "end": { + "line": 6, + "column": 23 + } + } + }, + { + "type": "Punctuator", + "value": ")", + "range": [ + 134, + 135 + ], + "loc": { + "start": { + "line": 6, + "column": 23 + }, + "end": { + "line": 6, + "column": 24 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 136, + 137 + ], + "loc": { + "start": { + "line": 6, + "column": 25 + }, + "end": { + "line": 6, + "column": 26 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 137, + 138 + ], + "loc": { + "start": { + "line": 6, + "column": 26 + }, + "end": { + "line": 6, + "column": 27 + } + } + }, + { + "type": "Punctuator", + "value": "<", + "range": [ + 139, + 140 + ], + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 1 + } + } + }, + { + "type": "Punctuator", + "value": "/", + "range": [ + 140, + 141 + ], + "loc": { + "start": { + "line": 7, + "column": 1 + }, + "end": { + "line": 7, + "column": 2 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "script", + "range": [ + 141, + 147 + ], + "loc": { + "start": { + "line": 7, + "column": 2 + }, + "end": { + "line": 7, + "column": 8 + } + } + }, + { + "type": "Punctuator", + "value": ">", + "range": [ + 147, + 148 + ], + "loc": { + "start": { + "line": 7, + "column": 8 + }, + "end": { + "line": 7, + "column": 9 + } + } + }, + { + "type": "HTMLText", + "value": "\n\n", + "range": [ + 148, + 150 + ], + "loc": { + "start": { + "line": 7, + "column": 9 + }, + "end": { + "line": 9, + "column": 0 + } + } + }, + { + "type": "Punctuator", + "value": "<", + "range": [ + 150, + 151 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 1 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "svelte:component", + "range": [ + 151, + 167 + ], + "loc": { + "start": { + "line": 9, + "column": 1 + }, + "end": { + "line": 9, + "column": 17 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "--style-props", + "range": [ + 169, + 182 + ], + "loc": { + "start": { + "line": 10, + "column": 1 + }, + "end": { + "line": 10, + "column": 14 + } + } + }, + { + "type": "Punctuator", + "value": "=", + "range": [ + 182, + 183 + ], + "loc": { + "start": { + "line": 10, + "column": 14 + }, + "end": { + "line": 10, + "column": 15 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 183, + 184 + ], + "loc": { + "start": { + "line": 10, + "column": 15 + }, + "end": { + "line": 10, + "column": 16 + } + } + }, + { + "type": "Identifier", + "value": "style", + "range": [ + 184, + 189 + ], + "loc": { + "start": { + "line": 10, + "column": 16 + }, + "end": { + "line": 10, + "column": 21 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 189, + 190 + ], + "loc": { + "start": { + "line": 10, + "column": 21 + }, + "end": { + "line": 10, + "column": 22 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "bind", + "range": [ + 192, + 196 + ], + "loc": { + "start": { + "line": 11, + "column": 1 + }, + "end": { + "line": 11, + "column": 5 + } + } + }, + { + "type": "Punctuator", + "value": ":", + "range": [ + 196, + 197 + ], + "loc": { + "start": { + "line": 11, + "column": 5 + }, + "end": { + "line": 11, + "column": 6 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "value", + "range": [ + 197, + 202 + ], + "loc": { + "start": { + "line": 11, + "column": 6 + }, + "end": { + "line": 11, + "column": 11 + } + } + }, + { + "type": "Punctuator", + "value": "=", + "range": [ + 202, + 203 + ], + "loc": { + "start": { + "line": 11, + "column": 11 + }, + "end": { + "line": 11, + "column": 12 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 203, + 204 + ], + "loc": { + "start": { + "line": 11, + "column": 12 + }, + "end": { + "line": 11, + "column": 13 + } + } + }, + { + "type": "Identifier", + "value": "componentValue", + "range": [ + 204, + 218 + ], + "loc": { + "start": { + "line": 11, + "column": 13 + }, + "end": { + "line": 11, + "column": 27 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 218, + 219 + ], + "loc": { + "start": { + "line": 11, + "column": 27 + }, + "end": { + "line": 11, + "column": 28 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "this", + "range": [ + 221, + 225 + ], + "loc": { + "start": { + "line": 12, + "column": 1 + }, + "end": { + "line": 12, + "column": 5 + } + } + }, + { + "type": "Punctuator", + "value": "=", + "range": [ + 225, + 226 + ], + "loc": { + "start": { + "line": 12, + "column": 5 + }, + "end": { + "line": 12, + "column": 6 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 226, + 227 + ], + "loc": { + "start": { + "line": 12, + "column": 6 + }, + "end": { + "line": 12, + "column": 7 + } + } + }, + { + "type": "Identifier", + "value": "component", + "range": [ + 227, + 236 + ], + "loc": { + "start": { + "line": 12, + "column": 7 + }, + "end": { + "line": 12, + "column": 16 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 236, + 237 + ], + "loc": { + "start": { + "line": 12, + "column": 16 + }, + "end": { + "line": 12, + "column": 17 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "on", + "range": [ + 239, + 241 + ], + "loc": { + "start": { + "line": 13, + "column": 1 + }, + "end": { + "line": 13, + "column": 3 + } + } + }, + { + "type": "Punctuator", + "value": ":", + "range": [ + 241, + 242 + ], + "loc": { + "start": { + "line": 13, + "column": 3 + }, + "end": { + "line": 13, + "column": 4 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "changeValue", + "range": [ + 242, + 253 + ], + "loc": { + "start": { + "line": 13, + "column": 4 + }, + "end": { + "line": 13, + "column": 15 + } + } + }, + { + "type": "Punctuator", + "value": "=", + "range": [ + 253, + 254 + ], + "loc": { + "start": { + "line": 13, + "column": 15 + }, + "end": { + "line": 13, + "column": 16 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 254, + 255 + ], + "loc": { + "start": { + "line": 13, + "column": 16 + }, + "end": { + "line": 13, + "column": 17 + } + } + }, + { + "type": "Identifier", + "value": "handleChange", + "range": [ + 255, + 267 + ], + "loc": { + "start": { + "line": 13, + "column": 17 + }, + "end": { + "line": 13, + "column": 29 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 267, + 268 + ], + "loc": { + "start": { + "line": 13, + "column": 29 + }, + "end": { + "line": 13, + "column": 30 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "bind", + "range": [ + 270, + 274 + ], + "loc": { + "start": { + "line": 14, + "column": 1 + }, + "end": { + "line": 14, + "column": 5 + } + } + }, + { + "type": "Punctuator", + "value": ":", + "range": [ + 274, + 275 + ], + "loc": { + "start": { + "line": 14, + "column": 5 + }, + "end": { + "line": 14, + "column": 6 + } + } + }, + { + "type": "Identifier", + "value": "metaData", + "range": [ + 275, + 283 + ], + "loc": { + "start": { + "line": 14, + "column": 6 + }, + "end": { + "line": 14, + "column": 14 + } + } + }, + { + "type": "Punctuator", + "value": "/", + "range": [ + 284, + 285 + ], + "loc": { + "start": { + "line": 15, + "column": 0 + }, + "end": { + "line": 15, + "column": 1 + } + } + }, + { + "type": "Punctuator", + "value": ">", + "range": [ + 285, + 286 + ], + "loc": { + "start": { + "line": 15, + "column": 1 + }, + "end": { + "line": 15, + "column": 2 + } + } + } + ], + "range": [ + 0, + 286 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 15, + "column": 2 + } + } +} \ No newline at end of file diff --git a/tests/fixtures/parser/ast/this-attr02-scope-output.json b/tests/fixtures/parser/ast/this-attr02-scope-output.json new file mode 100644 index 00000000..d6e06927 --- /dev/null +++ b/tests/fixtures/parser/ast/this-attr02-scope-output.json @@ -0,0 +1,1144 @@ +{ + "type": "global", + "variables": [ + { + "name": "$$slots", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$$props", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$$restProps", + "identifiers": [], + "defs": [], + "references": [] + } + ], + "references": [], + "childScopes": [ + { + "type": "module", + "variables": [ + { + "name": "component", + "identifiers": [ + { + "type": "Identifier", + "name": "component", + "range": [ + 17, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 17 + } + } + } + ], + "defs": [ + { + "type": "ImportBinding", + "name": { + "type": "Identifier", + "name": "component", + "range": [ + 17, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 17 + } + } + }, + "node": { + "type": "ImportDefaultSpecifier", + "local": { + "type": "Identifier", + "name": "component", + "range": [ + 17, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 17 + } + } + }, + "range": [ + 17, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 17 + } + } + } + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "component", + "range": [ + 227, + 236 + ], + "loc": { + "start": { + "line": 12, + "column": 7 + }, + "end": { + "line": 12, + "column": 16 + } + } + }, + "from": "module", + "init": null, + "resolved": { + "type": "Identifier", + "name": "component", + "range": [ + 17, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 17 + } + } + } + } + ] + }, + { + "name": "style", + "identifiers": [ + { + "type": "Identifier", + "name": "style", + "range": [ + 47, + 52 + ], + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 12 + } + } + } + ], + "defs": [ + { + "type": "Variable", + "name": { + "type": "Identifier", + "name": "style", + "range": [ + 47, + 52 + ], + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 12 + } + } + }, + "node": { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "style", + "range": [ + 47, + 52 + ], + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 12 + } + } + }, + "init": { + "type": "ObjectExpression", + "properties": [ + { + "type": "Property", + "kind": "init", + "computed": false, + "key": { + "type": "Identifier", + "name": "color", + "range": [ + 57, + 62 + ], + "loc": { + "start": { + "line": 3, + "column": 17 + }, + "end": { + "line": 3, + "column": 22 + } + } + }, + "method": false, + "shorthand": false, + "value": { + "type": "Literal", + "raw": "'red'", + "value": "red", + "range": [ + 64, + 69 + ], + "loc": { + "start": { + "line": 3, + "column": 24 + }, + "end": { + "line": 3, + "column": 29 + } + } + }, + "range": [ + 57, + 69 + ], + "loc": { + "start": { + "line": 3, + "column": 17 + }, + "end": { + "line": 3, + "column": 29 + } + } + } + ], + "range": [ + 55, + 71 + ], + "loc": { + "start": { + "line": 3, + "column": 15 + }, + "end": { + "line": 3, + "column": 31 + } + } + }, + "range": [ + 47, + 71 + ], + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 31 + } + } + } + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "style", + "range": [ + 47, + 52 + ], + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 12 + } + } + }, + "from": "module", + "init": true, + "resolved": { + "type": "Identifier", + "name": "style", + "range": [ + 47, + 52 + ], + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 12 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "style", + "range": [ + 184, + 189 + ], + "loc": { + "start": { + "line": 10, + "column": 16 + }, + "end": { + "line": 10, + "column": 21 + } + } + }, + "from": "module", + "init": null, + "resolved": { + "type": "Identifier", + "name": "style", + "range": [ + 47, + 52 + ], + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 12 + } + } + } + } + ] + }, + { + "name": "componentValue", + "identifiers": [ + { + "type": "Identifier", + "name": "componentValue", + "range": [ + 77, + 91 + ], + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 19 + } + } + } + ], + "defs": [ + { + "type": "Variable", + "name": { + "type": "Identifier", + "name": "componentValue", + "range": [ + 77, + 91 + ], + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 19 + } + } + }, + "node": { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "componentValue", + "range": [ + 77, + 91 + ], + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 19 + } + } + }, + "init": null, + "range": [ + 77, + 91 + ], + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 19 + } + } + } + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "componentValue", + "range": [ + 204, + 218 + ], + "loc": { + "start": { + "line": 11, + "column": 13 + }, + "end": { + "line": 11, + "column": 27 + } + } + }, + "from": "module", + "init": null, + "resolved": { + "type": "Identifier", + "name": "componentValue", + "range": [ + 77, + 91 + ], + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 19 + } + } + } + } + ] + }, + { + "name": "metaData", + "identifiers": [ + { + "type": "Identifier", + "name": "metaData", + "range": [ + 97, + 105 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 13 + } + } + } + ], + "defs": [ + { + "type": "Variable", + "name": { + "type": "Identifier", + "name": "metaData", + "range": [ + 97, + 105 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 13 + } + } + }, + "node": { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "metaData", + "range": [ + 97, + 105 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 13 + } + } + }, + "init": { + "type": "ObjectExpression", + "properties": [], + "range": [ + 108, + 110 + ], + "loc": { + "start": { + "line": 5, + "column": 16 + }, + "end": { + "line": 5, + "column": 18 + } + } + }, + "range": [ + 97, + 110 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 18 + } + } + } + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "metaData", + "range": [ + 97, + 105 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 13 + } + } + }, + "from": "module", + "init": true, + "resolved": { + "type": "Identifier", + "name": "metaData", + "range": [ + 97, + 105 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 13 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "metaData", + "range": [ + 275, + 283 + ], + "loc": { + "start": { + "line": 14, + "column": 6 + }, + "end": { + "line": 14, + "column": 14 + } + } + }, + "from": "module", + "init": null, + "resolved": { + "type": "Identifier", + "name": "metaData", + "range": [ + 97, + 105 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 13 + } + } + } + } + ] + }, + { + "name": "handleChange", + "identifiers": [ + { + "type": "Identifier", + "name": "handleChange", + "range": [ + 121, + 133 + ], + "loc": { + "start": { + "line": 6, + "column": 10 + }, + "end": { + "line": 6, + "column": 22 + } + } + } + ], + "defs": [ + { + "type": "FunctionName", + "name": { + "type": "Identifier", + "name": "handleChange", + "range": [ + 121, + 133 + ], + "loc": { + "start": { + "line": 6, + "column": 10 + }, + "end": { + "line": 6, + "column": 22 + } + } + }, + "node": { + "type": "FunctionDeclaration", + "async": false, + "body": { + "type": "BlockStatement", + "body": [], + "range": [ + 136, + 138 + ], + "loc": { + "start": { + "line": 6, + "column": 25 + }, + "end": { + "line": 6, + "column": 27 + } + } + }, + "expression": false, + "generator": false, + "id": { + "type": "Identifier", + "name": "handleChange", + "range": [ + 121, + 133 + ], + "loc": { + "start": { + "line": 6, + "column": 10 + }, + "end": { + "line": 6, + "column": 22 + } + } + }, + "params": [], + "range": [ + 112, + 138 + ], + "loc": { + "start": { + "line": 6, + "column": 1 + }, + "end": { + "line": 6, + "column": 27 + } + } + } + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "handleChange", + "range": [ + 255, + 267 + ], + "loc": { + "start": { + "line": 13, + "column": 17 + }, + "end": { + "line": 13, + "column": 29 + } + } + }, + "from": "module", + "init": null, + "resolved": { + "type": "Identifier", + "name": "handleChange", + "range": [ + 121, + 133 + ], + "loc": { + "start": { + "line": 6, + "column": 10 + }, + "end": { + "line": 6, + "column": 22 + } + } + } + } + ] + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "style", + "range": [ + 47, + 52 + ], + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 12 + } + } + }, + "from": "module", + "init": true, + "resolved": { + "type": "Identifier", + "name": "style", + "range": [ + 47, + 52 + ], + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 12 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "metaData", + "range": [ + 97, + 105 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 13 + } + } + }, + "from": "module", + "init": true, + "resolved": { + "type": "Identifier", + "name": "metaData", + "range": [ + 97, + 105 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 13 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "style", + "range": [ + 184, + 189 + ], + "loc": { + "start": { + "line": 10, + "column": 16 + }, + "end": { + "line": 10, + "column": 21 + } + } + }, + "from": "module", + "init": null, + "resolved": { + "type": "Identifier", + "name": "style", + "range": [ + 47, + 52 + ], + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 12 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "componentValue", + "range": [ + 204, + 218 + ], + "loc": { + "start": { + "line": 11, + "column": 13 + }, + "end": { + "line": 11, + "column": 27 + } + } + }, + "from": "module", + "init": null, + "resolved": { + "type": "Identifier", + "name": "componentValue", + "range": [ + 77, + 91 + ], + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 19 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "handleChange", + "range": [ + 255, + 267 + ], + "loc": { + "start": { + "line": 13, + "column": 17 + }, + "end": { + "line": 13, + "column": 29 + } + } + }, + "from": "module", + "init": null, + "resolved": { + "type": "Identifier", + "name": "handleChange", + "range": [ + 121, + 133 + ], + "loc": { + "start": { + "line": 6, + "column": 10 + }, + "end": { + "line": 6, + "column": 22 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "metaData", + "range": [ + 275, + 283 + ], + "loc": { + "start": { + "line": 14, + "column": 6 + }, + "end": { + "line": 14, + "column": 14 + } + } + }, + "from": "module", + "init": null, + "resolved": { + "type": "Identifier", + "name": "metaData", + "range": [ + 97, + 105 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 13 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "component", + "range": [ + 227, + 236 + ], + "loc": { + "start": { + "line": 12, + "column": 7 + }, + "end": { + "line": 12, + "column": 16 + } + } + }, + "from": "module", + "init": null, + "resolved": { + "type": "Identifier", + "name": "component", + "range": [ + 17, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 17 + } + } + } + } + ], + "childScopes": [ + { + "type": "function", + "variables": [ + { + "name": "arguments", + "identifiers": [], + "defs": [], + "references": [] + } + ], + "references": [], + "childScopes": [], + "through": [] + } + ], + "through": [] + } + ], + "through": [] +} \ No newline at end of file diff --git a/tests/fixtures/parser/ast/this-attr03-input.svelte b/tests/fixtures/parser/ast/this-attr03-input.svelte new file mode 100644 index 00000000..9a470326 --- /dev/null +++ b/tests/fixtures/parser/ast/this-attr03-input.svelte @@ -0,0 +1,15 @@ + + + \ No newline at end of file diff --git a/tests/fixtures/parser/ast/this-attr03-output.json b/tests/fixtures/parser/ast/this-attr03-output.json new file mode 100644 index 00000000..6e75521c --- /dev/null +++ b/tests/fixtures/parser/ast/this-attr03-output.json @@ -0,0 +1,2060 @@ +{ + "type": "Program", + "body": [ + { + "type": "SvelteScriptElement", + "name": { + "type": "SvelteName", + "name": "script", + "range": [ + 1, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 7 + } + } + }, + "startTag": { + "type": "SvelteStartTag", + "attributes": [], + "selfClosing": false, + "range": [ + 0, + 8 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + } + }, + "body": [ + { + "type": "ImportDeclaration", + "source": { + "type": "Literal", + "raw": "'./foo'", + "value": "./foo", + "range": [ + 32, + 39 + ], + "loc": { + "start": { + "line": 2, + "column": 23 + }, + "end": { + "line": 2, + "column": 30 + } + } + }, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "local": { + "type": "Identifier", + "name": "component", + "range": [ + 17, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 17 + } + } + }, + "range": [ + 17, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 17 + } + } + } + ], + "range": [ + 10, + 39 + ], + "loc": { + "start": { + "line": 2, + "column": 1 + }, + "end": { + "line": 2, + "column": 30 + } + } + }, + { + "type": "VariableDeclaration", + "kind": "const", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "style", + "range": [ + 47, + 52 + ], + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 12 + } + } + }, + "init": { + "type": "ObjectExpression", + "properties": [ + { + "type": "Property", + "kind": "init", + "computed": false, + "key": { + "type": "Identifier", + "name": "color", + "range": [ + 57, + 62 + ], + "loc": { + "start": { + "line": 3, + "column": 17 + }, + "end": { + "line": 3, + "column": 22 + } + } + }, + "method": false, + "shorthand": false, + "value": { + "type": "Literal", + "raw": "'red'", + "value": "red", + "range": [ + 64, + 69 + ], + "loc": { + "start": { + "line": 3, + "column": 24 + }, + "end": { + "line": 3, + "column": 29 + } + } + }, + "range": [ + 57, + 69 + ], + "loc": { + "start": { + "line": 3, + "column": 17 + }, + "end": { + "line": 3, + "column": 29 + } + } + } + ], + "range": [ + 55, + 71 + ], + "loc": { + "start": { + "line": 3, + "column": 15 + }, + "end": { + "line": 3, + "column": 31 + } + } + }, + "range": [ + 47, + 71 + ], + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 31 + } + } + } + ], + "range": [ + 41, + 71 + ], + "loc": { + "start": { + "line": 3, + "column": 1 + }, + "end": { + "line": 3, + "column": 31 + } + } + }, + { + "type": "VariableDeclaration", + "kind": "let", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "componentValue", + "range": [ + 77, + 91 + ], + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 19 + } + } + }, + "init": null, + "range": [ + 77, + 91 + ], + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 19 + } + } + } + ], + "range": [ + 73, + 91 + ], + "loc": { + "start": { + "line": 4, + "column": 1 + }, + "end": { + "line": 4, + "column": 19 + } + } + }, + { + "type": "VariableDeclaration", + "kind": "let", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "metaData", + "range": [ + 97, + 105 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 13 + } + } + }, + "init": { + "type": "ObjectExpression", + "properties": [], + "range": [ + 108, + 110 + ], + "loc": { + "start": { + "line": 5, + "column": 16 + }, + "end": { + "line": 5, + "column": 18 + } + } + }, + "range": [ + 97, + 110 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 18 + } + } + } + ], + "range": [ + 93, + 110 + ], + "loc": { + "start": { + "line": 5, + "column": 1 + }, + "end": { + "line": 5, + "column": 18 + } + } + }, + { + "type": "FunctionDeclaration", + "async": false, + "body": { + "type": "BlockStatement", + "body": [], + "range": [ + 136, + 138 + ], + "loc": { + "start": { + "line": 6, + "column": 25 + }, + "end": { + "line": 6, + "column": 27 + } + } + }, + "expression": false, + "generator": false, + "id": { + "type": "Identifier", + "name": "handleChange", + "range": [ + 121, + 133 + ], + "loc": { + "start": { + "line": 6, + "column": 10 + }, + "end": { + "line": 6, + "column": 22 + } + } + }, + "params": [], + "range": [ + 112, + 138 + ], + "loc": { + "start": { + "line": 6, + "column": 1 + }, + "end": { + "line": 6, + "column": 27 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", + "range": [ + 139, + 148 + ], + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 9 + } + } + }, + "range": [ + 0, + 148 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 7, + "column": 9 + } + } + }, + { + "type": "SvelteText", + "value": "\n\n", + "range": [ + 148, + 150 + ], + "loc": { + "start": { + "line": 7, + "column": 9 + }, + "end": { + "line": 9, + "column": 0 + } + } + }, + { + "type": "SvelteElement", + "kind": "special", + "name": { + "type": "SvelteName", + "name": "svelte:component", + "range": [ + 151, + 167 + ], + "loc": { + "start": { + "line": 9, + "column": 1 + }, + "end": { + "line": 9, + "column": 17 + } + } + }, + "startTag": { + "type": "SvelteStartTag", + "attributes": [ + { + "type": "SvelteAttribute", + "key": { + "type": "SvelteName", + "name": "--style-props", + "range": [ + 169, + 182 + ], + "loc": { + "start": { + "line": 10, + "column": 1 + }, + "end": { + "line": 10, + "column": 14 + } + } + }, + "boolean": false, + "value": [ + { + "type": "SvelteMustacheTag", + "kind": "text", + "expression": { + "type": "Identifier", + "name": "style", + "range": [ + 184, + 189 + ], + "loc": { + "start": { + "line": 10, + "column": 16 + }, + "end": { + "line": 10, + "column": 21 + } + } + }, + "range": [ + 183, + 190 + ], + "loc": { + "start": { + "line": 10, + "column": 15 + }, + "end": { + "line": 10, + "column": 22 + } + } + } + ], + "range": [ + 169, + 190 + ], + "loc": { + "start": { + "line": 10, + "column": 1 + }, + "end": { + "line": 10, + "column": 22 + } + } + }, + { + "type": "SvelteDirective", + "kind": "Binding", + "key": { + "type": "SvelteDirectiveKey", + "name": { + "type": "SvelteName", + "name": "value", + "range": [ + 197, + 202 + ], + "loc": { + "start": { + "line": 11, + "column": 6 + }, + "end": { + "line": 11, + "column": 11 + } + } + }, + "modifiers": [], + "range": [ + 192, + 202 + ], + "loc": { + "start": { + "line": 11, + "column": 1 + }, + "end": { + "line": 11, + "column": 11 + } + } + }, + "expression": { + "type": "Identifier", + "name": "componentValue", + "range": [ + 204, + 218 + ], + "loc": { + "start": { + "line": 11, + "column": 13 + }, + "end": { + "line": 11, + "column": 27 + } + } + }, + "shorthand": false, + "range": [ + 192, + 219 + ], + "loc": { + "start": { + "line": 11, + "column": 1 + }, + "end": { + "line": 11, + "column": 28 + } + } + }, + { + "type": "SvelteDirective", + "kind": "EventHandler", + "key": { + "type": "SvelteDirectiveKey", + "name": { + "type": "SvelteName", + "name": "changeValue", + "range": [ + 224, + 235 + ], + "loc": { + "start": { + "line": 12, + "column": 4 + }, + "end": { + "line": 12, + "column": 15 + } + } + }, + "modifiers": [], + "range": [ + 221, + 235 + ], + "loc": { + "start": { + "line": 12, + "column": 1 + }, + "end": { + "line": 12, + "column": 15 + } + } + }, + "expression": { + "type": "Identifier", + "name": "handleChange", + "range": [ + 237, + 249 + ], + "loc": { + "start": { + "line": 12, + "column": 17 + }, + "end": { + "line": 12, + "column": 29 + } + } + }, + "range": [ + 221, + 250 + ], + "loc": { + "start": { + "line": 12, + "column": 1 + }, + "end": { + "line": 12, + "column": 30 + } + } + }, + { + "type": "SvelteDirective", + "kind": "Binding", + "key": { + "type": "SvelteDirectiveKey", + "name": { + "type": "SvelteName", + "name": "metaData", + "range": [ + 257, + 265 + ], + "loc": { + "start": { + "line": 13, + "column": 6 + }, + "end": { + "line": 13, + "column": 14 + } + } + }, + "modifiers": [], + "range": [ + 252, + 265 + ], + "loc": { + "start": { + "line": 13, + "column": 1 + }, + "end": { + "line": 13, + "column": 14 + } + } + }, + "expression": { + "type": "Identifier", + "name": "metaData", + "range": [ + 257, + 265 + ], + "loc": { + "start": { + "line": 13, + "column": 6 + }, + "end": { + "line": 13, + "column": 14 + } + } + }, + "shorthand": true, + "range": [ + 252, + 265 + ], + "loc": { + "start": { + "line": 13, + "column": 1 + }, + "end": { + "line": 13, + "column": 14 + } + } + }, + { + "type": "SvelteSpecialDirective", + "kind": "this", + "key": { + "type": "SvelteSpecialDirectiveKey", + "range": [ + 267, + 271 + ], + "loc": { + "start": { + "line": 14, + "column": 1 + }, + "end": { + "line": 14, + "column": 5 + } + } + }, + "expression": { + "type": "Identifier", + "name": "component", + "range": [ + 273, + 282 + ], + "loc": { + "start": { + "line": 14, + "column": 7 + }, + "end": { + "line": 14, + "column": 16 + } + } + }, + "range": [ + 267, + 283 + ], + "loc": { + "start": { + "line": 14, + "column": 1 + }, + "end": { + "line": 14, + "column": 17 + } + } + } + ], + "selfClosing": true, + "range": [ + 150, + 286 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 15, + "column": 2 + } + } + }, + "children": [], + "endTag": null, + "range": [ + 150, + 286 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 15, + "column": 2 + } + } + } + ], + "sourceType": "module", + "comments": [], + "tokens": [ + { + "type": "Punctuator", + "value": "<", + "range": [ + 0, + 1 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "script", + "range": [ + 1, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 7 + } + } + }, + { + "type": "Punctuator", + "value": ">", + "range": [ + 7, + 8 + ], + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + } + }, + { + "type": "Keyword", + "value": "import", + "range": [ + 10, + 16 + ], + "loc": { + "start": { + "line": 2, + "column": 1 + }, + "end": { + "line": 2, + "column": 7 + } + } + }, + { + "type": "Identifier", + "value": "component", + "range": [ + 17, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 17 + } + } + }, + { + "type": "Identifier", + "value": "from", + "range": [ + 27, + 31 + ], + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 22 + } + } + }, + { + "type": "String", + "value": "'./foo'", + "range": [ + 32, + 39 + ], + "loc": { + "start": { + "line": 2, + "column": 23 + }, + "end": { + "line": 2, + "column": 30 + } + } + }, + { + "type": "Keyword", + "value": "const", + "range": [ + 41, + 46 + ], + "loc": { + "start": { + "line": 3, + "column": 1 + }, + "end": { + "line": 3, + "column": 6 + } + } + }, + { + "type": "Identifier", + "value": "style", + "range": [ + 47, + 52 + ], + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 12 + } + } + }, + { + "type": "Punctuator", + "value": "=", + "range": [ + 53, + 54 + ], + "loc": { + "start": { + "line": 3, + "column": 13 + }, + "end": { + "line": 3, + "column": 14 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 55, + 56 + ], + "loc": { + "start": { + "line": 3, + "column": 15 + }, + "end": { + "line": 3, + "column": 16 + } + } + }, + { + "type": "Identifier", + "value": "color", + "range": [ + 57, + 62 + ], + "loc": { + "start": { + "line": 3, + "column": 17 + }, + "end": { + "line": 3, + "column": 22 + } + } + }, + { + "type": "Punctuator", + "value": ":", + "range": [ + 62, + 63 + ], + "loc": { + "start": { + "line": 3, + "column": 22 + }, + "end": { + "line": 3, + "column": 23 + } + } + }, + { + "type": "String", + "value": "'red'", + "range": [ + 64, + 69 + ], + "loc": { + "start": { + "line": 3, + "column": 24 + }, + "end": { + "line": 3, + "column": 29 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 70, + 71 + ], + "loc": { + "start": { + "line": 3, + "column": 30 + }, + "end": { + "line": 3, + "column": 31 + } + } + }, + { + "type": "Keyword", + "value": "let", + "range": [ + 73, + 76 + ], + "loc": { + "start": { + "line": 4, + "column": 1 + }, + "end": { + "line": 4, + "column": 4 + } + } + }, + { + "type": "Identifier", + "value": "componentValue", + "range": [ + 77, + 91 + ], + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 19 + } + } + }, + { + "type": "Keyword", + "value": "let", + "range": [ + 93, + 96 + ], + "loc": { + "start": { + "line": 5, + "column": 1 + }, + "end": { + "line": 5, + "column": 4 + } + } + }, + { + "type": "Identifier", + "value": "metaData", + "range": [ + 97, + 105 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 13 + } + } + }, + { + "type": "Punctuator", + "value": "=", + "range": [ + 106, + 107 + ], + "loc": { + "start": { + "line": 5, + "column": 14 + }, + "end": { + "line": 5, + "column": 15 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 108, + 109 + ], + "loc": { + "start": { + "line": 5, + "column": 16 + }, + "end": { + "line": 5, + "column": 17 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 109, + 110 + ], + "loc": { + "start": { + "line": 5, + "column": 17 + }, + "end": { + "line": 5, + "column": 18 + } + } + }, + { + "type": "Keyword", + "value": "function", + "range": [ + 112, + 120 + ], + "loc": { + "start": { + "line": 6, + "column": 1 + }, + "end": { + "line": 6, + "column": 9 + } + } + }, + { + "type": "Identifier", + "value": "handleChange", + "range": [ + 121, + 133 + ], + "loc": { + "start": { + "line": 6, + "column": 10 + }, + "end": { + "line": 6, + "column": 22 + } + } + }, + { + "type": "Punctuator", + "value": "(", + "range": [ + 133, + 134 + ], + "loc": { + "start": { + "line": 6, + "column": 22 + }, + "end": { + "line": 6, + "column": 23 + } + } + }, + { + "type": "Punctuator", + "value": ")", + "range": [ + 134, + 135 + ], + "loc": { + "start": { + "line": 6, + "column": 23 + }, + "end": { + "line": 6, + "column": 24 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 136, + 137 + ], + "loc": { + "start": { + "line": 6, + "column": 25 + }, + "end": { + "line": 6, + "column": 26 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 137, + 138 + ], + "loc": { + "start": { + "line": 6, + "column": 26 + }, + "end": { + "line": 6, + "column": 27 + } + } + }, + { + "type": "Punctuator", + "value": "<", + "range": [ + 139, + 140 + ], + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 1 + } + } + }, + { + "type": "Punctuator", + "value": "/", + "range": [ + 140, + 141 + ], + "loc": { + "start": { + "line": 7, + "column": 1 + }, + "end": { + "line": 7, + "column": 2 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "script", + "range": [ + 141, + 147 + ], + "loc": { + "start": { + "line": 7, + "column": 2 + }, + "end": { + "line": 7, + "column": 8 + } + } + }, + { + "type": "Punctuator", + "value": ">", + "range": [ + 147, + 148 + ], + "loc": { + "start": { + "line": 7, + "column": 8 + }, + "end": { + "line": 7, + "column": 9 + } + } + }, + { + "type": "HTMLText", + "value": "\n\n", + "range": [ + 148, + 150 + ], + "loc": { + "start": { + "line": 7, + "column": 9 + }, + "end": { + "line": 9, + "column": 0 + } + } + }, + { + "type": "Punctuator", + "value": "<", + "range": [ + 150, + 151 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 1 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "svelte:component", + "range": [ + 151, + 167 + ], + "loc": { + "start": { + "line": 9, + "column": 1 + }, + "end": { + "line": 9, + "column": 17 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "--style-props", + "range": [ + 169, + 182 + ], + "loc": { + "start": { + "line": 10, + "column": 1 + }, + "end": { + "line": 10, + "column": 14 + } + } + }, + { + "type": "Punctuator", + "value": "=", + "range": [ + 182, + 183 + ], + "loc": { + "start": { + "line": 10, + "column": 14 + }, + "end": { + "line": 10, + "column": 15 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 183, + 184 + ], + "loc": { + "start": { + "line": 10, + "column": 15 + }, + "end": { + "line": 10, + "column": 16 + } + } + }, + { + "type": "Identifier", + "value": "style", + "range": [ + 184, + 189 + ], + "loc": { + "start": { + "line": 10, + "column": 16 + }, + "end": { + "line": 10, + "column": 21 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 189, + 190 + ], + "loc": { + "start": { + "line": 10, + "column": 21 + }, + "end": { + "line": 10, + "column": 22 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "bind", + "range": [ + 192, + 196 + ], + "loc": { + "start": { + "line": 11, + "column": 1 + }, + "end": { + "line": 11, + "column": 5 + } + } + }, + { + "type": "Punctuator", + "value": ":", + "range": [ + 196, + 197 + ], + "loc": { + "start": { + "line": 11, + "column": 5 + }, + "end": { + "line": 11, + "column": 6 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "value", + "range": [ + 197, + 202 + ], + "loc": { + "start": { + "line": 11, + "column": 6 + }, + "end": { + "line": 11, + "column": 11 + } + } + }, + { + "type": "Punctuator", + "value": "=", + "range": [ + 202, + 203 + ], + "loc": { + "start": { + "line": 11, + "column": 11 + }, + "end": { + "line": 11, + "column": 12 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 203, + 204 + ], + "loc": { + "start": { + "line": 11, + "column": 12 + }, + "end": { + "line": 11, + "column": 13 + } + } + }, + { + "type": "Identifier", + "value": "componentValue", + "range": [ + 204, + 218 + ], + "loc": { + "start": { + "line": 11, + "column": 13 + }, + "end": { + "line": 11, + "column": 27 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 218, + 219 + ], + "loc": { + "start": { + "line": 11, + "column": 27 + }, + "end": { + "line": 11, + "column": 28 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "on", + "range": [ + 221, + 223 + ], + "loc": { + "start": { + "line": 12, + "column": 1 + }, + "end": { + "line": 12, + "column": 3 + } + } + }, + { + "type": "Punctuator", + "value": ":", + "range": [ + 223, + 224 + ], + "loc": { + "start": { + "line": 12, + "column": 3 + }, + "end": { + "line": 12, + "column": 4 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "changeValue", + "range": [ + 224, + 235 + ], + "loc": { + "start": { + "line": 12, + "column": 4 + }, + "end": { + "line": 12, + "column": 15 + } + } + }, + { + "type": "Punctuator", + "value": "=", + "range": [ + 235, + 236 + ], + "loc": { + "start": { + "line": 12, + "column": 15 + }, + "end": { + "line": 12, + "column": 16 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 236, + 237 + ], + "loc": { + "start": { + "line": 12, + "column": 16 + }, + "end": { + "line": 12, + "column": 17 + } + } + }, + { + "type": "Identifier", + "value": "handleChange", + "range": [ + 237, + 249 + ], + "loc": { + "start": { + "line": 12, + "column": 17 + }, + "end": { + "line": 12, + "column": 29 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 249, + 250 + ], + "loc": { + "start": { + "line": 12, + "column": 29 + }, + "end": { + "line": 12, + "column": 30 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "bind", + "range": [ + 252, + 256 + ], + "loc": { + "start": { + "line": 13, + "column": 1 + }, + "end": { + "line": 13, + "column": 5 + } + } + }, + { + "type": "Punctuator", + "value": ":", + "range": [ + 256, + 257 + ], + "loc": { + "start": { + "line": 13, + "column": 5 + }, + "end": { + "line": 13, + "column": 6 + } + } + }, + { + "type": "Identifier", + "value": "metaData", + "range": [ + 257, + 265 + ], + "loc": { + "start": { + "line": 13, + "column": 6 + }, + "end": { + "line": 13, + "column": 14 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "this", + "range": [ + 267, + 271 + ], + "loc": { + "start": { + "line": 14, + "column": 1 + }, + "end": { + "line": 14, + "column": 5 + } + } + }, + { + "type": "Punctuator", + "value": "=", + "range": [ + 271, + 272 + ], + "loc": { + "start": { + "line": 14, + "column": 5 + }, + "end": { + "line": 14, + "column": 6 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 272, + 273 + ], + "loc": { + "start": { + "line": 14, + "column": 6 + }, + "end": { + "line": 14, + "column": 7 + } + } + }, + { + "type": "Identifier", + "value": "component", + "range": [ + 273, + 282 + ], + "loc": { + "start": { + "line": 14, + "column": 7 + }, + "end": { + "line": 14, + "column": 16 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 282, + 283 + ], + "loc": { + "start": { + "line": 14, + "column": 16 + }, + "end": { + "line": 14, + "column": 17 + } + } + }, + { + "type": "Punctuator", + "value": "/", + "range": [ + 284, + 285 + ], + "loc": { + "start": { + "line": 15, + "column": 0 + }, + "end": { + "line": 15, + "column": 1 + } + } + }, + { + "type": "Punctuator", + "value": ">", + "range": [ + 285, + 286 + ], + "loc": { + "start": { + "line": 15, + "column": 1 + }, + "end": { + "line": 15, + "column": 2 + } + } + } + ], + "range": [ + 0, + 286 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 15, + "column": 2 + } + } +} \ No newline at end of file diff --git a/tests/fixtures/parser/ast/this-attr03-scope-output.json b/tests/fixtures/parser/ast/this-attr03-scope-output.json new file mode 100644 index 00000000..6507504a --- /dev/null +++ b/tests/fixtures/parser/ast/this-attr03-scope-output.json @@ -0,0 +1,1144 @@ +{ + "type": "global", + "variables": [ + { + "name": "$$slots", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$$props", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$$restProps", + "identifiers": [], + "defs": [], + "references": [] + } + ], + "references": [], + "childScopes": [ + { + "type": "module", + "variables": [ + { + "name": "component", + "identifiers": [ + { + "type": "Identifier", + "name": "component", + "range": [ + 17, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 17 + } + } + } + ], + "defs": [ + { + "type": "ImportBinding", + "name": { + "type": "Identifier", + "name": "component", + "range": [ + 17, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 17 + } + } + }, + "node": { + "type": "ImportDefaultSpecifier", + "local": { + "type": "Identifier", + "name": "component", + "range": [ + 17, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 17 + } + } + }, + "range": [ + 17, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 17 + } + } + } + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "component", + "range": [ + 273, + 282 + ], + "loc": { + "start": { + "line": 14, + "column": 7 + }, + "end": { + "line": 14, + "column": 16 + } + } + }, + "from": "module", + "init": null, + "resolved": { + "type": "Identifier", + "name": "component", + "range": [ + 17, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 17 + } + } + } + } + ] + }, + { + "name": "style", + "identifiers": [ + { + "type": "Identifier", + "name": "style", + "range": [ + 47, + 52 + ], + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 12 + } + } + } + ], + "defs": [ + { + "type": "Variable", + "name": { + "type": "Identifier", + "name": "style", + "range": [ + 47, + 52 + ], + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 12 + } + } + }, + "node": { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "style", + "range": [ + 47, + 52 + ], + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 12 + } + } + }, + "init": { + "type": "ObjectExpression", + "properties": [ + { + "type": "Property", + "kind": "init", + "computed": false, + "key": { + "type": "Identifier", + "name": "color", + "range": [ + 57, + 62 + ], + "loc": { + "start": { + "line": 3, + "column": 17 + }, + "end": { + "line": 3, + "column": 22 + } + } + }, + "method": false, + "shorthand": false, + "value": { + "type": "Literal", + "raw": "'red'", + "value": "red", + "range": [ + 64, + 69 + ], + "loc": { + "start": { + "line": 3, + "column": 24 + }, + "end": { + "line": 3, + "column": 29 + } + } + }, + "range": [ + 57, + 69 + ], + "loc": { + "start": { + "line": 3, + "column": 17 + }, + "end": { + "line": 3, + "column": 29 + } + } + } + ], + "range": [ + 55, + 71 + ], + "loc": { + "start": { + "line": 3, + "column": 15 + }, + "end": { + "line": 3, + "column": 31 + } + } + }, + "range": [ + 47, + 71 + ], + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 31 + } + } + } + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "style", + "range": [ + 47, + 52 + ], + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 12 + } + } + }, + "from": "module", + "init": true, + "resolved": { + "type": "Identifier", + "name": "style", + "range": [ + 47, + 52 + ], + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 12 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "style", + "range": [ + 184, + 189 + ], + "loc": { + "start": { + "line": 10, + "column": 16 + }, + "end": { + "line": 10, + "column": 21 + } + } + }, + "from": "module", + "init": null, + "resolved": { + "type": "Identifier", + "name": "style", + "range": [ + 47, + 52 + ], + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 12 + } + } + } + } + ] + }, + { + "name": "componentValue", + "identifiers": [ + { + "type": "Identifier", + "name": "componentValue", + "range": [ + 77, + 91 + ], + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 19 + } + } + } + ], + "defs": [ + { + "type": "Variable", + "name": { + "type": "Identifier", + "name": "componentValue", + "range": [ + 77, + 91 + ], + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 19 + } + } + }, + "node": { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "componentValue", + "range": [ + 77, + 91 + ], + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 19 + } + } + }, + "init": null, + "range": [ + 77, + 91 + ], + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 19 + } + } + } + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "componentValue", + "range": [ + 204, + 218 + ], + "loc": { + "start": { + "line": 11, + "column": 13 + }, + "end": { + "line": 11, + "column": 27 + } + } + }, + "from": "module", + "init": null, + "resolved": { + "type": "Identifier", + "name": "componentValue", + "range": [ + 77, + 91 + ], + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 19 + } + } + } + } + ] + }, + { + "name": "metaData", + "identifiers": [ + { + "type": "Identifier", + "name": "metaData", + "range": [ + 97, + 105 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 13 + } + } + } + ], + "defs": [ + { + "type": "Variable", + "name": { + "type": "Identifier", + "name": "metaData", + "range": [ + 97, + 105 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 13 + } + } + }, + "node": { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "metaData", + "range": [ + 97, + 105 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 13 + } + } + }, + "init": { + "type": "ObjectExpression", + "properties": [], + "range": [ + 108, + 110 + ], + "loc": { + "start": { + "line": 5, + "column": 16 + }, + "end": { + "line": 5, + "column": 18 + } + } + }, + "range": [ + 97, + 110 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 18 + } + } + } + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "metaData", + "range": [ + 97, + 105 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 13 + } + } + }, + "from": "module", + "init": true, + "resolved": { + "type": "Identifier", + "name": "metaData", + "range": [ + 97, + 105 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 13 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "metaData", + "range": [ + 257, + 265 + ], + "loc": { + "start": { + "line": 13, + "column": 6 + }, + "end": { + "line": 13, + "column": 14 + } + } + }, + "from": "module", + "init": null, + "resolved": { + "type": "Identifier", + "name": "metaData", + "range": [ + 97, + 105 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 13 + } + } + } + } + ] + }, + { + "name": "handleChange", + "identifiers": [ + { + "type": "Identifier", + "name": "handleChange", + "range": [ + 121, + 133 + ], + "loc": { + "start": { + "line": 6, + "column": 10 + }, + "end": { + "line": 6, + "column": 22 + } + } + } + ], + "defs": [ + { + "type": "FunctionName", + "name": { + "type": "Identifier", + "name": "handleChange", + "range": [ + 121, + 133 + ], + "loc": { + "start": { + "line": 6, + "column": 10 + }, + "end": { + "line": 6, + "column": 22 + } + } + }, + "node": { + "type": "FunctionDeclaration", + "async": false, + "body": { + "type": "BlockStatement", + "body": [], + "range": [ + 136, + 138 + ], + "loc": { + "start": { + "line": 6, + "column": 25 + }, + "end": { + "line": 6, + "column": 27 + } + } + }, + "expression": false, + "generator": false, + "id": { + "type": "Identifier", + "name": "handleChange", + "range": [ + 121, + 133 + ], + "loc": { + "start": { + "line": 6, + "column": 10 + }, + "end": { + "line": 6, + "column": 22 + } + } + }, + "params": [], + "range": [ + 112, + 138 + ], + "loc": { + "start": { + "line": 6, + "column": 1 + }, + "end": { + "line": 6, + "column": 27 + } + } + } + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "handleChange", + "range": [ + 237, + 249 + ], + "loc": { + "start": { + "line": 12, + "column": 17 + }, + "end": { + "line": 12, + "column": 29 + } + } + }, + "from": "module", + "init": null, + "resolved": { + "type": "Identifier", + "name": "handleChange", + "range": [ + 121, + 133 + ], + "loc": { + "start": { + "line": 6, + "column": 10 + }, + "end": { + "line": 6, + "column": 22 + } + } + } + } + ] + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "style", + "range": [ + 47, + 52 + ], + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 12 + } + } + }, + "from": "module", + "init": true, + "resolved": { + "type": "Identifier", + "name": "style", + "range": [ + 47, + 52 + ], + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 12 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "metaData", + "range": [ + 97, + 105 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 13 + } + } + }, + "from": "module", + "init": true, + "resolved": { + "type": "Identifier", + "name": "metaData", + "range": [ + 97, + 105 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 13 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "style", + "range": [ + 184, + 189 + ], + "loc": { + "start": { + "line": 10, + "column": 16 + }, + "end": { + "line": 10, + "column": 21 + } + } + }, + "from": "module", + "init": null, + "resolved": { + "type": "Identifier", + "name": "style", + "range": [ + 47, + 52 + ], + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 12 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "componentValue", + "range": [ + 204, + 218 + ], + "loc": { + "start": { + "line": 11, + "column": 13 + }, + "end": { + "line": 11, + "column": 27 + } + } + }, + "from": "module", + "init": null, + "resolved": { + "type": "Identifier", + "name": "componentValue", + "range": [ + 77, + 91 + ], + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 19 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "handleChange", + "range": [ + 237, + 249 + ], + "loc": { + "start": { + "line": 12, + "column": 17 + }, + "end": { + "line": 12, + "column": 29 + } + } + }, + "from": "module", + "init": null, + "resolved": { + "type": "Identifier", + "name": "handleChange", + "range": [ + 121, + 133 + ], + "loc": { + "start": { + "line": 6, + "column": 10 + }, + "end": { + "line": 6, + "column": 22 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "metaData", + "range": [ + 257, + 265 + ], + "loc": { + "start": { + "line": 13, + "column": 6 + }, + "end": { + "line": 13, + "column": 14 + } + } + }, + "from": "module", + "init": null, + "resolved": { + "type": "Identifier", + "name": "metaData", + "range": [ + 97, + 105 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 13 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "component", + "range": [ + 273, + 282 + ], + "loc": { + "start": { + "line": 14, + "column": 7 + }, + "end": { + "line": 14, + "column": 16 + } + } + }, + "from": "module", + "init": null, + "resolved": { + "type": "Identifier", + "name": "component", + "range": [ + 17, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 17 + } + } + } + } + ], + "childScopes": [ + { + "type": "function", + "variables": [ + { + "name": "arguments", + "identifiers": [], + "defs": [], + "references": [] + } + ], + "references": [], + "childScopes": [], + "through": [] + } + ], + "through": [] + } + ], + "through": [] +} \ No newline at end of file