diff --git a/tests/fixtures/parser/ast/svelte5/docs/event-handlers/01-input.svelte b/tests/fixtures/parser/ast/svelte5/docs/event-handlers/01-input.svelte new file mode 100644 index 00000000..ce9ad28e --- /dev/null +++ b/tests/fixtures/parser/ast/svelte5/docs/event-handlers/01-input.svelte @@ -0,0 +1,7 @@ + + + diff --git a/tests/fixtures/parser/ast/svelte5/docs/event-handlers/01-output.json b/tests/fixtures/parser/ast/svelte5/docs/event-handlers/01-output.json new file mode 100644 index 00000000..fe86c824 --- /dev/null +++ b/tests/fixtures/parser/ast/svelte5/docs/event-handlers/01-output.json @@ -0,0 +1,1190 @@ +{ + "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": "VariableDeclaration", + "kind": "let", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "count", + "range": [ + 14, + 19 + ], + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 10 + } + } + }, + "init": { + "type": "CallExpression", + "arguments": [ + { + "type": "Literal", + "raw": "0", + "value": 0, + "range": [ + 29, + 30 + ], + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 21 + } + } + } + ], + "callee": { + "type": "Identifier", + "name": "$state", + "range": [ + 22, + 28 + ], + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 19 + } + } + }, + "optional": false, + "range": [ + 22, + 31 + ], + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 22 + } + } + }, + "range": [ + 14, + 31 + ], + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 22 + } + } + } + ], + "range": [ + 10, + 32 + ], + "loc": { + "start": { + "line": 2, + "column": 1 + }, + "end": { + "line": 2, + "column": 23 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", + "range": [ + 33, + 42 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 9 + } + } + }, + "range": [ + 0, + 42 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 9 + } + } + }, + { + "type": "SvelteText", + "value": "\n\n", + "range": [ + 42, + 44 + ], + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 5, + "column": 0 + } + } + }, + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "button", + "range": [ + 45, + 51 + ], + "loc": { + "start": { + "line": 5, + "column": 1 + }, + "end": { + "line": 5, + "column": 7 + } + } + }, + "startTag": { + "type": "SvelteStartTag", + "attributes": [ + { + "type": "SvelteAttribute", + "key": { + "type": "SvelteName", + "name": "onclick", + "range": [ + 52, + 59 + ], + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 5, + "column": 15 + } + } + }, + "boolean": false, + "value": [ + { + "type": "SvelteMustacheTag", + "kind": "text", + "expression": { + "type": "ArrowFunctionExpression", + "async": false, + "body": { + "type": "UpdateExpression", + "argument": { + "type": "Identifier", + "name": "count", + "range": [ + 67, + 72 + ], + "loc": { + "start": { + "line": 5, + "column": 23 + }, + "end": { + "line": 5, + "column": 28 + } + } + }, + "operator": "++", + "prefix": false, + "range": [ + 67, + 74 + ], + "loc": { + "start": { + "line": 5, + "column": 23 + }, + "end": { + "line": 5, + "column": 30 + } + } + }, + "expression": true, + "generator": false, + "id": null, + "params": [], + "range": [ + 61, + 74 + ], + "loc": { + "start": { + "line": 5, + "column": 17 + }, + "end": { + "line": 5, + "column": 30 + } + } + }, + "range": [ + 60, + 75 + ], + "loc": { + "start": { + "line": 5, + "column": 16 + }, + "end": { + "line": 5, + "column": 31 + } + } + } + ], + "range": [ + 52, + 75 + ], + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 5, + "column": 31 + } + } + } + ], + "selfClosing": false, + "range": [ + 44, + 76 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 32 + } + } + }, + "children": [ + { + "type": "SvelteText", + "value": "\n\tclicks: ", + "range": [ + 76, + 86 + ], + "loc": { + "start": { + "line": 5, + "column": 32 + }, + "end": { + "line": 6, + "column": 9 + } + } + }, + { + "type": "SvelteMustacheTag", + "kind": "text", + "expression": { + "type": "Identifier", + "name": "count", + "range": [ + 87, + 92 + ], + "loc": { + "start": { + "line": 6, + "column": 10 + }, + "end": { + "line": 6, + "column": 15 + } + } + }, + "range": [ + 86, + 93 + ], + "loc": { + "start": { + "line": 6, + "column": 9 + }, + "end": { + "line": 6, + "column": 16 + } + } + }, + { + "type": "SvelteText", + "value": "\n", + "range": [ + 93, + 94 + ], + "loc": { + "start": { + "line": 6, + "column": 16 + }, + "end": { + "line": 7, + "column": 0 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", + "range": [ + 94, + 103 + ], + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 9 + } + } + }, + "range": [ + 44, + 103 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 7, + "column": 9 + } + } + } + ], + "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": "let", + "range": [ + 10, + 13 + ], + "loc": { + "start": { + "line": 2, + "column": 1 + }, + "end": { + "line": 2, + "column": 4 + } + } + }, + { + "type": "Identifier", + "value": "count", + "range": [ + 14, + 19 + ], + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 10 + } + } + }, + { + "type": "Punctuator", + "value": "=", + "range": [ + 20, + 21 + ], + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 12 + } + } + }, + { + "type": "Identifier", + "value": "$state", + "range": [ + 22, + 28 + ], + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 19 + } + } + }, + { + "type": "Punctuator", + "value": "(", + "range": [ + 28, + 29 + ], + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 20 + } + } + }, + { + "type": "Numeric", + "value": "0", + "range": [ + 29, + 30 + ], + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 21 + } + } + }, + { + "type": "Punctuator", + "value": ")", + "range": [ + 30, + 31 + ], + "loc": { + "start": { + "line": 2, + "column": 21 + }, + "end": { + "line": 2, + "column": 22 + } + } + }, + { + "type": "Punctuator", + "value": ";", + "range": [ + 31, + 32 + ], + "loc": { + "start": { + "line": 2, + "column": 22 + }, + "end": { + "line": 2, + "column": 23 + } + } + }, + { + "type": "Punctuator", + "value": "<", + "range": [ + 33, + 34 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + } + }, + { + "type": "Punctuator", + "value": "/", + "range": [ + 34, + 35 + ], + "loc": { + "start": { + "line": 3, + "column": 1 + }, + "end": { + "line": 3, + "column": 2 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "script", + "range": [ + 35, + 41 + ], + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 8 + } + } + }, + { + "type": "Punctuator", + "value": ">", + "range": [ + 41, + 42 + ], + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 9 + } + } + }, + { + "type": "HTMLText", + "value": "\n\n", + "range": [ + 42, + 44 + ], + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 5, + "column": 0 + } + } + }, + { + "type": "Punctuator", + "value": "<", + "range": [ + 44, + 45 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "button", + "range": [ + 45, + 51 + ], + "loc": { + "start": { + "line": 5, + "column": 1 + }, + "end": { + "line": 5, + "column": 7 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "onclick", + "range": [ + 52, + 59 + ], + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 5, + "column": 15 + } + } + }, + { + "type": "Punctuator", + "value": "=", + "range": [ + 59, + 60 + ], + "loc": { + "start": { + "line": 5, + "column": 15 + }, + "end": { + "line": 5, + "column": 16 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 60, + 61 + ], + "loc": { + "start": { + "line": 5, + "column": 16 + }, + "end": { + "line": 5, + "column": 17 + } + } + }, + { + "type": "Punctuator", + "value": "(", + "range": [ + 61, + 62 + ], + "loc": { + "start": { + "line": 5, + "column": 17 + }, + "end": { + "line": 5, + "column": 18 + } + } + }, + { + "type": "Punctuator", + "value": ")", + "range": [ + 62, + 63 + ], + "loc": { + "start": { + "line": 5, + "column": 18 + }, + "end": { + "line": 5, + "column": 19 + } + } + }, + { + "type": "Punctuator", + "value": "=>", + "range": [ + 64, + 66 + ], + "loc": { + "start": { + "line": 5, + "column": 20 + }, + "end": { + "line": 5, + "column": 22 + } + } + }, + { + "type": "Identifier", + "value": "count", + "range": [ + 67, + 72 + ], + "loc": { + "start": { + "line": 5, + "column": 23 + }, + "end": { + "line": 5, + "column": 28 + } + } + }, + { + "type": "Punctuator", + "value": "++", + "range": [ + 72, + 74 + ], + "loc": { + "start": { + "line": 5, + "column": 28 + }, + "end": { + "line": 5, + "column": 30 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 74, + 75 + ], + "loc": { + "start": { + "line": 5, + "column": 30 + }, + "end": { + "line": 5, + "column": 31 + } + } + }, + { + "type": "Punctuator", + "value": ">", + "range": [ + 75, + 76 + ], + "loc": { + "start": { + "line": 5, + "column": 31 + }, + "end": { + "line": 5, + "column": 32 + } + } + }, + { + "type": "HTMLText", + "value": "\n\t", + "range": [ + 76, + 78 + ], + "loc": { + "start": { + "line": 5, + "column": 32 + }, + "end": { + "line": 6, + "column": 1 + } + } + }, + { + "type": "HTMLText", + "value": "clicks:", + "range": [ + 78, + 85 + ], + "loc": { + "start": { + "line": 6, + "column": 1 + }, + "end": { + "line": 6, + "column": 8 + } + } + }, + { + "type": "HTMLText", + "value": " ", + "range": [ + 85, + 86 + ], + "loc": { + "start": { + "line": 6, + "column": 8 + }, + "end": { + "line": 6, + "column": 9 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 86, + 87 + ], + "loc": { + "start": { + "line": 6, + "column": 9 + }, + "end": { + "line": 6, + "column": 10 + } + } + }, + { + "type": "Identifier", + "value": "count", + "range": [ + 87, + 92 + ], + "loc": { + "start": { + "line": 6, + "column": 10 + }, + "end": { + "line": 6, + "column": 15 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 92, + 93 + ], + "loc": { + "start": { + "line": 6, + "column": 15 + }, + "end": { + "line": 6, + "column": 16 + } + } + }, + { + "type": "HTMLText", + "value": "\n", + "range": [ + 93, + 94 + ], + "loc": { + "start": { + "line": 6, + "column": 16 + }, + "end": { + "line": 7, + "column": 0 + } + } + }, + { + "type": "Punctuator", + "value": "<", + "range": [ + 94, + 95 + ], + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 1 + } + } + }, + { + "type": "Punctuator", + "value": "/", + "range": [ + 95, + 96 + ], + "loc": { + "start": { + "line": 7, + "column": 1 + }, + "end": { + "line": 7, + "column": 2 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "button", + "range": [ + 96, + 102 + ], + "loc": { + "start": { + "line": 7, + "column": 2 + }, + "end": { + "line": 7, + "column": 8 + } + } + }, + { + "type": "Punctuator", + "value": ">", + "range": [ + 102, + 103 + ], + "loc": { + "start": { + "line": 7, + "column": 8 + }, + "end": { + "line": 7, + "column": 9 + } + } + } + ], + "range": [ + 0, + 104 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 8, + "column": 0 + } + } +} \ No newline at end of file diff --git a/tests/fixtures/parser/ast/svelte5/docs/event-handlers/01-scope-output.json b/tests/fixtures/parser/ast/svelte5/docs/event-handlers/01-scope-output.json new file mode 100644 index 00000000..350aa64e --- /dev/null +++ b/tests/fixtures/parser/ast/svelte5/docs/event-handlers/01-scope-output.json @@ -0,0 +1,561 @@ +{ + "type": "global", + "variables": [ + { + "name": "$$slots", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$$props", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$$restProps", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$state", + "identifiers": [], + "defs": [], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "$state", + "range": [ + 22, + 28 + ], + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 19 + } + } + }, + "from": "module", + "init": null, + "resolved": null + } + ] + }, + { + "name": "$derived", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$effect", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$props", + "identifiers": [], + "defs": [], + "references": [] + } + ], + "references": [], + "childScopes": [ + { + "type": "module", + "variables": [ + { + "name": "count", + "identifiers": [ + { + "type": "Identifier", + "name": "count", + "range": [ + 14, + 19 + ], + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 10 + } + } + } + ], + "defs": [ + { + "type": "Variable", + "name": { + "type": "Identifier", + "name": "count", + "range": [ + 14, + 19 + ], + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 10 + } + } + }, + "node": { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "count", + "range": [ + 14, + 19 + ], + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 10 + } + } + }, + "init": { + "type": "CallExpression", + "arguments": [ + { + "type": "Literal", + "raw": "0", + "value": 0, + "range": [ + 29, + 30 + ], + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 21 + } + } + } + ], + "callee": { + "type": "Identifier", + "name": "$state", + "range": [ + 22, + 28 + ], + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 19 + } + } + }, + "optional": false, + "range": [ + 22, + 31 + ], + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 22 + } + } + }, + "range": [ + 14, + 31 + ], + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 22 + } + } + } + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "count", + "range": [ + 14, + 19 + ], + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 10 + } + } + }, + "from": "module", + "init": true, + "resolved": { + "type": "Identifier", + "name": "count", + "range": [ + 14, + 19 + ], + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 10 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "count", + "range": [ + 67, + 72 + ], + "loc": { + "start": { + "line": 5, + "column": 23 + }, + "end": { + "line": 5, + "column": 28 + } + } + }, + "from": "function", + "init": false, + "resolved": { + "type": "Identifier", + "name": "count", + "range": [ + 14, + 19 + ], + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 10 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "count", + "range": [ + 87, + 92 + ], + "loc": { + "start": { + "line": 6, + "column": 10 + }, + "end": { + "line": 6, + "column": 15 + } + } + }, + "from": "module", + "init": null, + "resolved": { + "type": "Identifier", + "name": "count", + "range": [ + 14, + 19 + ], + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 10 + } + } + } + } + ] + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "count", + "range": [ + 14, + 19 + ], + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 10 + } + } + }, + "from": "module", + "init": true, + "resolved": { + "type": "Identifier", + "name": "count", + "range": [ + 14, + 19 + ], + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 10 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "$state", + "range": [ + 22, + 28 + ], + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 19 + } + } + }, + "from": "module", + "init": null, + "resolved": null + }, + { + "identifier": { + "type": "Identifier", + "name": "count", + "range": [ + 87, + 92 + ], + "loc": { + "start": { + "line": 6, + "column": 10 + }, + "end": { + "line": 6, + "column": 15 + } + } + }, + "from": "module", + "init": null, + "resolved": { + "type": "Identifier", + "name": "count", + "range": [ + 14, + 19 + ], + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 10 + } + } + } + } + ], + "childScopes": [ + { + "type": "function", + "variables": [], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "count", + "range": [ + 67, + 72 + ], + "loc": { + "start": { + "line": 5, + "column": 23 + }, + "end": { + "line": 5, + "column": 28 + } + } + }, + "from": "function", + "init": false, + "resolved": { + "type": "Identifier", + "name": "count", + "range": [ + 14, + 19 + ], + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 10 + } + } + } + } + ], + "childScopes": [], + "through": [ + { + "identifier": { + "type": "Identifier", + "name": "count", + "range": [ + 67, + 72 + ], + "loc": { + "start": { + "line": 5, + "column": 23 + }, + "end": { + "line": 5, + "column": 28 + } + } + }, + "from": "function", + "init": false, + "resolved": { + "type": "Identifier", + "name": "count", + "range": [ + 14, + 19 + ], + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 10 + } + } + } + } + ] + } + ], + "through": [ + { + "identifier": { + "type": "Identifier", + "name": "$state", + "range": [ + 22, + 28 + ], + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 19 + } + } + }, + "from": "module", + "init": null, + "resolved": null + } + ] + } + ], + "through": [] +} \ No newline at end of file diff --git a/tests/fixtures/parser/ast/svelte5/docs/event-handlers/02-input.svelte b/tests/fixtures/parser/ast/svelte5/docs/event-handlers/02-input.svelte new file mode 100644 index 00000000..81fc01dc --- /dev/null +++ b/tests/fixtures/parser/ast/svelte5/docs/event-handlers/02-input.svelte @@ -0,0 +1,11 @@ + + + diff --git a/tests/fixtures/parser/ast/svelte5/docs/event-handlers/02-output.json b/tests/fixtures/parser/ast/svelte5/docs/event-handlers/02-output.json new file mode 100644 index 00000000..a7cc39d1 --- /dev/null +++ b/tests/fixtures/parser/ast/svelte5/docs/event-handlers/02-output.json @@ -0,0 +1,1294 @@ +{ + "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": "VariableDeclaration", + "kind": "let", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "count", + "range": [ + 14, + 19 + ], + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 10 + } + } + }, + "init": { + "type": "CallExpression", + "arguments": [ + { + "type": "Literal", + "raw": "0", + "value": 0, + "range": [ + 29, + 30 + ], + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 21 + } + } + } + ], + "callee": { + "type": "Identifier", + "name": "$state", + "range": [ + 22, + 28 + ], + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 19 + } + } + }, + "optional": false, + "range": [ + 22, + 31 + ], + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 22 + } + } + }, + "range": [ + 14, + 31 + ], + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 22 + } + } + } + ], + "range": [ + 10, + 32 + ], + "loc": { + "start": { + "line": 2, + "column": 1 + }, + "end": { + "line": 2, + "column": 23 + } + } + }, + { + "type": "FunctionDeclaration", + "async": false, + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "UpdateExpression", + "argument": { + "type": "Identifier", + "name": "count", + "range": [ + 58, + 63 + ], + "loc": { + "start": { + "line": 5, + "column": 2 + }, + "end": { + "line": 5, + "column": 7 + } + } + }, + "operator": "++", + "prefix": false, + "range": [ + 58, + 65 + ], + "loc": { + "start": { + "line": 5, + "column": 2 + }, + "end": { + "line": 5, + "column": 9 + } + } + }, + "range": [ + 58, + 66 + ], + "loc": { + "start": { + "line": 5, + "column": 2 + }, + "end": { + "line": 5, + "column": 10 + } + } + } + ], + "range": [ + 54, + 69 + ], + "loc": { + "start": { + "line": 4, + "column": 20 + }, + "end": { + "line": 6, + "column": 2 + } + } + }, + "expression": false, + "generator": false, + "id": { + "type": "Identifier", + "name": "onclick", + "range": [ + 44, + 51 + ], + "loc": { + "start": { + "line": 4, + "column": 10 + }, + "end": { + "line": 4, + "column": 17 + } + } + }, + "params": [], + "range": [ + 35, + 69 + ], + "loc": { + "start": { + "line": 4, + "column": 1 + }, + "end": { + "line": 6, + "column": 2 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", + "range": [ + 70, + 79 + ], + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 9 + } + } + }, + "range": [ + 0, + 79 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 7, + "column": 9 + } + } + }, + { + "type": "SvelteText", + "value": "\n\n", + "range": [ + 79, + 81 + ], + "loc": { + "start": { + "line": 7, + "column": 9 + }, + "end": { + "line": 9, + "column": 0 + } + } + }, + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "button", + "range": [ + 82, + 88 + ], + "loc": { + "start": { + "line": 9, + "column": 1 + }, + "end": { + "line": 9, + "column": 7 + } + } + }, + "startTag": { + "type": "SvelteStartTag", + "attributes": [ + { + "type": "SvelteShorthandAttribute", + "key": { + "type": "Identifier", + "name": "onclick", + "range": [ + 90, + 97 + ], + "loc": { + "start": { + "line": 9, + "column": 9 + }, + "end": { + "line": 9, + "column": 16 + } + } + }, + "value": { + "type": "Identifier", + "name": "onclick", + "range": [ + 90, + 97 + ], + "loc": { + "start": { + "line": 9, + "column": 9 + }, + "end": { + "line": 9, + "column": 16 + } + } + }, + "range": [ + 89, + 98 + ], + "loc": { + "start": { + "line": 9, + "column": 8 + }, + "end": { + "line": 9, + "column": 17 + } + } + } + ], + "selfClosing": false, + "range": [ + 81, + 99 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 18 + } + } + }, + "children": [ + { + "type": "SvelteText", + "value": "\n\tclicks: ", + "range": [ + 99, + 109 + ], + "loc": { + "start": { + "line": 9, + "column": 18 + }, + "end": { + "line": 10, + "column": 9 + } + } + }, + { + "type": "SvelteMustacheTag", + "kind": "text", + "expression": { + "type": "Identifier", + "name": "count", + "range": [ + 110, + 115 + ], + "loc": { + "start": { + "line": 10, + "column": 10 + }, + "end": { + "line": 10, + "column": 15 + } + } + }, + "range": [ + 109, + 116 + ], + "loc": { + "start": { + "line": 10, + "column": 9 + }, + "end": { + "line": 10, + "column": 16 + } + } + }, + { + "type": "SvelteText", + "value": "\n", + "range": [ + 116, + 117 + ], + "loc": { + "start": { + "line": 10, + "column": 16 + }, + "end": { + "line": 11, + "column": 0 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", + "range": [ + 117, + 126 + ], + "loc": { + "start": { + "line": 11, + "column": 0 + }, + "end": { + "line": 11, + "column": 9 + } + } + }, + "range": [ + 81, + 126 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 11, + "column": 9 + } + } + } + ], + "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": "let", + "range": [ + 10, + 13 + ], + "loc": { + "start": { + "line": 2, + "column": 1 + }, + "end": { + "line": 2, + "column": 4 + } + } + }, + { + "type": "Identifier", + "value": "count", + "range": [ + 14, + 19 + ], + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 10 + } + } + }, + { + "type": "Punctuator", + "value": "=", + "range": [ + 20, + 21 + ], + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 12 + } + } + }, + { + "type": "Identifier", + "value": "$state", + "range": [ + 22, + 28 + ], + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 19 + } + } + }, + { + "type": "Punctuator", + "value": "(", + "range": [ + 28, + 29 + ], + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 20 + } + } + }, + { + "type": "Numeric", + "value": "0", + "range": [ + 29, + 30 + ], + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 21 + } + } + }, + { + "type": "Punctuator", + "value": ")", + "range": [ + 30, + 31 + ], + "loc": { + "start": { + "line": 2, + "column": 21 + }, + "end": { + "line": 2, + "column": 22 + } + } + }, + { + "type": "Punctuator", + "value": ";", + "range": [ + 31, + 32 + ], + "loc": { + "start": { + "line": 2, + "column": 22 + }, + "end": { + "line": 2, + "column": 23 + } + } + }, + { + "type": "Keyword", + "value": "function", + "range": [ + 35, + 43 + ], + "loc": { + "start": { + "line": 4, + "column": 1 + }, + "end": { + "line": 4, + "column": 9 + } + } + }, + { + "type": "Identifier", + "value": "onclick", + "range": [ + 44, + 51 + ], + "loc": { + "start": { + "line": 4, + "column": 10 + }, + "end": { + "line": 4, + "column": 17 + } + } + }, + { + "type": "Punctuator", + "value": "(", + "range": [ + 51, + 52 + ], + "loc": { + "start": { + "line": 4, + "column": 17 + }, + "end": { + "line": 4, + "column": 18 + } + } + }, + { + "type": "Punctuator", + "value": ")", + "range": [ + 52, + 53 + ], + "loc": { + "start": { + "line": 4, + "column": 18 + }, + "end": { + "line": 4, + "column": 19 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 54, + 55 + ], + "loc": { + "start": { + "line": 4, + "column": 20 + }, + "end": { + "line": 4, + "column": 21 + } + } + }, + { + "type": "Identifier", + "value": "count", + "range": [ + 58, + 63 + ], + "loc": { + "start": { + "line": 5, + "column": 2 + }, + "end": { + "line": 5, + "column": 7 + } + } + }, + { + "type": "Punctuator", + "value": "++", + "range": [ + 63, + 65 + ], + "loc": { + "start": { + "line": 5, + "column": 7 + }, + "end": { + "line": 5, + "column": 9 + } + } + }, + { + "type": "Punctuator", + "value": ";", + "range": [ + 65, + 66 + ], + "loc": { + "start": { + "line": 5, + "column": 9 + }, + "end": { + "line": 5, + "column": 10 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 68, + 69 + ], + "loc": { + "start": { + "line": 6, + "column": 1 + }, + "end": { + "line": 6, + "column": 2 + } + } + }, + { + "type": "Punctuator", + "value": "<", + "range": [ + 70, + 71 + ], + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 1 + } + } + }, + { + "type": "Punctuator", + "value": "/", + "range": [ + 71, + 72 + ], + "loc": { + "start": { + "line": 7, + "column": 1 + }, + "end": { + "line": 7, + "column": 2 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "script", + "range": [ + 72, + 78 + ], + "loc": { + "start": { + "line": 7, + "column": 2 + }, + "end": { + "line": 7, + "column": 8 + } + } + }, + { + "type": "Punctuator", + "value": ">", + "range": [ + 78, + 79 + ], + "loc": { + "start": { + "line": 7, + "column": 8 + }, + "end": { + "line": 7, + "column": 9 + } + } + }, + { + "type": "HTMLText", + "value": "\n\n", + "range": [ + 79, + 81 + ], + "loc": { + "start": { + "line": 7, + "column": 9 + }, + "end": { + "line": 9, + "column": 0 + } + } + }, + { + "type": "Punctuator", + "value": "<", + "range": [ + 81, + 82 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 1 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "button", + "range": [ + 82, + 88 + ], + "loc": { + "start": { + "line": 9, + "column": 1 + }, + "end": { + "line": 9, + "column": 7 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 89, + 90 + ], + "loc": { + "start": { + "line": 9, + "column": 8 + }, + "end": { + "line": 9, + "column": 9 + } + } + }, + { + "type": "Identifier", + "value": "onclick", + "range": [ + 90, + 97 + ], + "loc": { + "start": { + "line": 9, + "column": 9 + }, + "end": { + "line": 9, + "column": 16 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 97, + 98 + ], + "loc": { + "start": { + "line": 9, + "column": 16 + }, + "end": { + "line": 9, + "column": 17 + } + } + }, + { + "type": "Punctuator", + "value": ">", + "range": [ + 98, + 99 + ], + "loc": { + "start": { + "line": 9, + "column": 17 + }, + "end": { + "line": 9, + "column": 18 + } + } + }, + { + "type": "HTMLText", + "value": "\n\t", + "range": [ + 99, + 101 + ], + "loc": { + "start": { + "line": 9, + "column": 18 + }, + "end": { + "line": 10, + "column": 1 + } + } + }, + { + "type": "HTMLText", + "value": "clicks:", + "range": [ + 101, + 108 + ], + "loc": { + "start": { + "line": 10, + "column": 1 + }, + "end": { + "line": 10, + "column": 8 + } + } + }, + { + "type": "HTMLText", + "value": " ", + "range": [ + 108, + 109 + ], + "loc": { + "start": { + "line": 10, + "column": 8 + }, + "end": { + "line": 10, + "column": 9 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 109, + 110 + ], + "loc": { + "start": { + "line": 10, + "column": 9 + }, + "end": { + "line": 10, + "column": 10 + } + } + }, + { + "type": "Identifier", + "value": "count", + "range": [ + 110, + 115 + ], + "loc": { + "start": { + "line": 10, + "column": 10 + }, + "end": { + "line": 10, + "column": 15 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 115, + 116 + ], + "loc": { + "start": { + "line": 10, + "column": 15 + }, + "end": { + "line": 10, + "column": 16 + } + } + }, + { + "type": "HTMLText", + "value": "\n", + "range": [ + 116, + 117 + ], + "loc": { + "start": { + "line": 10, + "column": 16 + }, + "end": { + "line": 11, + "column": 0 + } + } + }, + { + "type": "Punctuator", + "value": "<", + "range": [ + 117, + 118 + ], + "loc": { + "start": { + "line": 11, + "column": 0 + }, + "end": { + "line": 11, + "column": 1 + } + } + }, + { + "type": "Punctuator", + "value": "/", + "range": [ + 118, + 119 + ], + "loc": { + "start": { + "line": 11, + "column": 1 + }, + "end": { + "line": 11, + "column": 2 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "button", + "range": [ + 119, + 125 + ], + "loc": { + "start": { + "line": 11, + "column": 2 + }, + "end": { + "line": 11, + "column": 8 + } + } + }, + { + "type": "Punctuator", + "value": ">", + "range": [ + 125, + 126 + ], + "loc": { + "start": { + "line": 11, + "column": 8 + }, + "end": { + "line": 11, + "column": 9 + } + } + } + ], + "range": [ + 0, + 127 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 12, + "column": 0 + } + } +} \ No newline at end of file diff --git a/tests/fixtures/parser/ast/svelte5/docs/event-handlers/02-scope-output.json b/tests/fixtures/parser/ast/svelte5/docs/event-handlers/02-scope-output.json new file mode 100644 index 00000000..d287aad1 --- /dev/null +++ b/tests/fixtures/parser/ast/svelte5/docs/event-handlers/02-scope-output.json @@ -0,0 +1,808 @@ +{ + "type": "global", + "variables": [ + { + "name": "$$slots", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$$props", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$$restProps", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$state", + "identifiers": [], + "defs": [], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "$state", + "range": [ + 22, + 28 + ], + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 19 + } + } + }, + "from": "module", + "init": null, + "resolved": null + } + ] + }, + { + "name": "$derived", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$effect", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$props", + "identifiers": [], + "defs": [], + "references": [] + } + ], + "references": [], + "childScopes": [ + { + "type": "module", + "variables": [ + { + "name": "count", + "identifiers": [ + { + "type": "Identifier", + "name": "count", + "range": [ + 14, + 19 + ], + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 10 + } + } + } + ], + "defs": [ + { + "type": "Variable", + "name": { + "type": "Identifier", + "name": "count", + "range": [ + 14, + 19 + ], + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 10 + } + } + }, + "node": { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "count", + "range": [ + 14, + 19 + ], + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 10 + } + } + }, + "init": { + "type": "CallExpression", + "arguments": [ + { + "type": "Literal", + "raw": "0", + "value": 0, + "range": [ + 29, + 30 + ], + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 21 + } + } + } + ], + "callee": { + "type": "Identifier", + "name": "$state", + "range": [ + 22, + 28 + ], + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 19 + } + } + }, + "optional": false, + "range": [ + 22, + 31 + ], + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 22 + } + } + }, + "range": [ + 14, + 31 + ], + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 22 + } + } + } + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "count", + "range": [ + 14, + 19 + ], + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 10 + } + } + }, + "from": "module", + "init": true, + "resolved": { + "type": "Identifier", + "name": "count", + "range": [ + 14, + 19 + ], + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 10 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "count", + "range": [ + 58, + 63 + ], + "loc": { + "start": { + "line": 5, + "column": 2 + }, + "end": { + "line": 5, + "column": 7 + } + } + }, + "from": "function", + "init": false, + "resolved": { + "type": "Identifier", + "name": "count", + "range": [ + 14, + 19 + ], + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 10 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "count", + "range": [ + 110, + 115 + ], + "loc": { + "start": { + "line": 10, + "column": 10 + }, + "end": { + "line": 10, + "column": 15 + } + } + }, + "from": "module", + "init": null, + "resolved": { + "type": "Identifier", + "name": "count", + "range": [ + 14, + 19 + ], + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 10 + } + } + } + } + ] + }, + { + "name": "onclick", + "identifiers": [ + { + "type": "Identifier", + "name": "onclick", + "range": [ + 44, + 51 + ], + "loc": { + "start": { + "line": 4, + "column": 10 + }, + "end": { + "line": 4, + "column": 17 + } + } + } + ], + "defs": [ + { + "type": "FunctionName", + "name": { + "type": "Identifier", + "name": "onclick", + "range": [ + 44, + 51 + ], + "loc": { + "start": { + "line": 4, + "column": 10 + }, + "end": { + "line": 4, + "column": 17 + } + } + }, + "node": { + "type": "FunctionDeclaration", + "async": false, + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "UpdateExpression", + "argument": { + "type": "Identifier", + "name": "count", + "range": [ + 58, + 63 + ], + "loc": { + "start": { + "line": 5, + "column": 2 + }, + "end": { + "line": 5, + "column": 7 + } + } + }, + "operator": "++", + "prefix": false, + "range": [ + 58, + 65 + ], + "loc": { + "start": { + "line": 5, + "column": 2 + }, + "end": { + "line": 5, + "column": 9 + } + } + }, + "range": [ + 58, + 66 + ], + "loc": { + "start": { + "line": 5, + "column": 2 + }, + "end": { + "line": 5, + "column": 10 + } + } + } + ], + "range": [ + 54, + 69 + ], + "loc": { + "start": { + "line": 4, + "column": 20 + }, + "end": { + "line": 6, + "column": 2 + } + } + }, + "expression": false, + "generator": false, + "id": { + "type": "Identifier", + "name": "onclick", + "range": [ + 44, + 51 + ], + "loc": { + "start": { + "line": 4, + "column": 10 + }, + "end": { + "line": 4, + "column": 17 + } + } + }, + "params": [], + "range": [ + 35, + 69 + ], + "loc": { + "start": { + "line": 4, + "column": 1 + }, + "end": { + "line": 6, + "column": 2 + } + } + } + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "onclick", + "range": [ + 90, + 97 + ], + "loc": { + "start": { + "line": 9, + "column": 9 + }, + "end": { + "line": 9, + "column": 16 + } + } + }, + "from": "module", + "init": null, + "resolved": { + "type": "Identifier", + "name": "onclick", + "range": [ + 44, + 51 + ], + "loc": { + "start": { + "line": 4, + "column": 10 + }, + "end": { + "line": 4, + "column": 17 + } + } + } + } + ] + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "count", + "range": [ + 14, + 19 + ], + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 10 + } + } + }, + "from": "module", + "init": true, + "resolved": { + "type": "Identifier", + "name": "count", + "range": [ + 14, + 19 + ], + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 10 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "$state", + "range": [ + 22, + 28 + ], + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 19 + } + } + }, + "from": "module", + "init": null, + "resolved": null + }, + { + "identifier": { + "type": "Identifier", + "name": "onclick", + "range": [ + 90, + 97 + ], + "loc": { + "start": { + "line": 9, + "column": 9 + }, + "end": { + "line": 9, + "column": 16 + } + } + }, + "from": "module", + "init": null, + "resolved": { + "type": "Identifier", + "name": "onclick", + "range": [ + 44, + 51 + ], + "loc": { + "start": { + "line": 4, + "column": 10 + }, + "end": { + "line": 4, + "column": 17 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "count", + "range": [ + 110, + 115 + ], + "loc": { + "start": { + "line": 10, + "column": 10 + }, + "end": { + "line": 10, + "column": 15 + } + } + }, + "from": "module", + "init": null, + "resolved": { + "type": "Identifier", + "name": "count", + "range": [ + 14, + 19 + ], + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 10 + } + } + } + } + ], + "childScopes": [ + { + "type": "function", + "variables": [ + { + "name": "arguments", + "identifiers": [], + "defs": [], + "references": [] + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "count", + "range": [ + 58, + 63 + ], + "loc": { + "start": { + "line": 5, + "column": 2 + }, + "end": { + "line": 5, + "column": 7 + } + } + }, + "from": "function", + "init": false, + "resolved": { + "type": "Identifier", + "name": "count", + "range": [ + 14, + 19 + ], + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 10 + } + } + } + } + ], + "childScopes": [], + "through": [ + { + "identifier": { + "type": "Identifier", + "name": "count", + "range": [ + 58, + 63 + ], + "loc": { + "start": { + "line": 5, + "column": 2 + }, + "end": { + "line": 5, + "column": 7 + } + } + }, + "from": "function", + "init": false, + "resolved": { + "type": "Identifier", + "name": "count", + "range": [ + 14, + 19 + ], + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 10 + } + } + } + } + ] + } + ], + "through": [ + { + "identifier": { + "type": "Identifier", + "name": "$state", + "range": [ + 22, + 28 + ], + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 19 + } + } + }, + "from": "module", + "init": null, + "resolved": null + } + ] + } + ], + "through": [] +} \ No newline at end of file diff --git a/tests/fixtures/parser/ast/svelte5/docs/event-handlers/03-component-events-input.svelte b/tests/fixtures/parser/ast/svelte5/docs/event-handlers/03-component-events-input.svelte new file mode 100644 index 00000000..80e7dc0b --- /dev/null +++ b/tests/fixtures/parser/ast/svelte5/docs/event-handlers/03-component-events-input.svelte @@ -0,0 +1,30 @@ + + + { + size += 5; + if (size > 75) burst = true; + }} + deflate={() => { + if (size > 0) size -= 5; + }} +/> + +{#if burst} + + 💥 +{:else} + + 🎈 + +{/if} diff --git a/tests/fixtures/parser/ast/svelte5/docs/event-handlers/03-component-events-output.json b/tests/fixtures/parser/ast/svelte5/docs/event-handlers/03-component-events-output.json new file mode 100644 index 00000000..2b8ee84e --- /dev/null +++ b/tests/fixtures/parser/ast/svelte5/docs/event-handlers/03-component-events-output.json @@ -0,0 +1,4705 @@ +{ + "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": "'./Pump.svelte'", + "value": "./Pump.svelte", + "range": [ + 27, + 42 + ], + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 33 + } + } + }, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "local": { + "type": "Identifier", + "name": "Pump", + "range": [ + 17, + 21 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 12 + } + } + }, + "range": [ + 17, + 21 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 12 + } + } + } + ], + "range": [ + 10, + 43 + ], + "loc": { + "start": { + "line": 2, + "column": 1 + }, + "end": { + "line": 2, + "column": 34 + } + } + }, + { + "type": "VariableDeclaration", + "kind": "let", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "size", + "range": [ + 50, + 54 + ], + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 9 + } + } + }, + "init": { + "type": "CallExpression", + "arguments": [ + { + "type": "Literal", + "raw": "15", + "value": 15, + "range": [ + 64, + 66 + ], + "loc": { + "start": { + "line": 4, + "column": 19 + }, + "end": { + "line": 4, + "column": 21 + } + } + } + ], + "callee": { + "type": "Identifier", + "name": "$state", + "range": [ + 57, + 63 + ], + "loc": { + "start": { + "line": 4, + "column": 12 + }, + "end": { + "line": 4, + "column": 18 + } + } + }, + "optional": false, + "range": [ + 57, + 67 + ], + "loc": { + "start": { + "line": 4, + "column": 12 + }, + "end": { + "line": 4, + "column": 22 + } + } + }, + "range": [ + 50, + 67 + ], + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 22 + } + } + } + ], + "range": [ + 46, + 68 + ], + "loc": { + "start": { + "line": 4, + "column": 1 + }, + "end": { + "line": 4, + "column": 23 + } + } + }, + { + "type": "VariableDeclaration", + "kind": "let", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "burst", + "range": [ + 74, + 79 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 10 + } + } + }, + "init": { + "type": "CallExpression", + "arguments": [ + { + "type": "Literal", + "raw": "false", + "value": false, + "range": [ + 89, + 94 + ], + "loc": { + "start": { + "line": 5, + "column": 20 + }, + "end": { + "line": 5, + "column": 25 + } + } + } + ], + "callee": { + "type": "Identifier", + "name": "$state", + "range": [ + 82, + 88 + ], + "loc": { + "start": { + "line": 5, + "column": 13 + }, + "end": { + "line": 5, + "column": 19 + } + } + }, + "optional": false, + "range": [ + 82, + 95 + ], + "loc": { + "start": { + "line": 5, + "column": 13 + }, + "end": { + "line": 5, + "column": 26 + } + } + }, + "range": [ + 74, + 95 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 26 + } + } + } + ], + "range": [ + 70, + 96 + ], + "loc": { + "start": { + "line": 5, + "column": 1 + }, + "end": { + "line": 5, + "column": 27 + } + } + }, + { + "type": "FunctionDeclaration", + "async": false, + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "left": { + "type": "Identifier", + "name": "size", + "range": [ + 120, + 124 + ], + "loc": { + "start": { + "line": 8, + "column": 2 + }, + "end": { + "line": 8, + "column": 6 + } + } + }, + "operator": "=", + "right": { + "type": "Literal", + "raw": "15", + "value": 15, + "range": [ + 127, + 129 + ], + "loc": { + "start": { + "line": 8, + "column": 9 + }, + "end": { + "line": 8, + "column": 11 + } + } + }, + "range": [ + 120, + 129 + ], + "loc": { + "start": { + "line": 8, + "column": 2 + }, + "end": { + "line": 8, + "column": 11 + } + } + }, + "range": [ + 120, + 130 + ], + "loc": { + "start": { + "line": 8, + "column": 2 + }, + "end": { + "line": 8, + "column": 12 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "left": { + "type": "Identifier", + "name": "burst", + "range": [ + 133, + 138 + ], + "loc": { + "start": { + "line": 9, + "column": 2 + }, + "end": { + "line": 9, + "column": 7 + } + } + }, + "operator": "=", + "right": { + "type": "Literal", + "raw": "false", + "value": false, + "range": [ + 141, + 146 + ], + "loc": { + "start": { + "line": 9, + "column": 10 + }, + "end": { + "line": 9, + "column": 15 + } + } + }, + "range": [ + 133, + 146 + ], + "loc": { + "start": { + "line": 9, + "column": 2 + }, + "end": { + "line": 9, + "column": 15 + } + } + }, + "range": [ + 133, + 147 + ], + "loc": { + "start": { + "line": 9, + "column": 2 + }, + "end": { + "line": 9, + "column": 16 + } + } + } + ], + "range": [ + 116, + 150 + ], + "loc": { + "start": { + "line": 7, + "column": 18 + }, + "end": { + "line": 10, + "column": 2 + } + } + }, + "expression": false, + "generator": false, + "id": { + "type": "Identifier", + "name": "reset", + "range": [ + 108, + 113 + ], + "loc": { + "start": { + "line": 7, + "column": 10 + }, + "end": { + "line": 7, + "column": 15 + } + } + }, + "params": [], + "range": [ + 99, + 150 + ], + "loc": { + "start": { + "line": 7, + "column": 1 + }, + "end": { + "line": 10, + "column": 2 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", + "range": [ + 151, + 160 + ], + "loc": { + "start": { + "line": 11, + "column": 0 + }, + "end": { + "line": 11, + "column": 9 + } + } + }, + "range": [ + 0, + 160 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 11, + "column": 9 + } + } + }, + { + "type": "SvelteText", + "value": "\n\n", + "range": [ + 160, + 162 + ], + "loc": { + "start": { + "line": 11, + "column": 9 + }, + "end": { + "line": 13, + "column": 0 + } + } + }, + { + "type": "SvelteElement", + "kind": "component", + "name": { + "type": "Identifier", + "name": "Pump", + "range": [ + 163, + 167 + ], + "loc": { + "start": { + "line": 13, + "column": 1 + }, + "end": { + "line": 13, + "column": 5 + } + } + }, + "startTag": { + "type": "SvelteStartTag", + "attributes": [ + { + "type": "SvelteAttribute", + "key": { + "type": "SvelteName", + "name": "inflate", + "range": [ + 169, + 176 + ], + "loc": { + "start": { + "line": 14, + "column": 1 + }, + "end": { + "line": 14, + "column": 8 + } + } + }, + "boolean": false, + "value": [ + { + "type": "SvelteMustacheTag", + "kind": "text", + "expression": { + "type": "ArrowFunctionExpression", + "async": false, + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "left": { + "type": "Identifier", + "name": "size", + "range": [ + 188, + 192 + ], + "loc": { + "start": { + "line": 15, + "column": 2 + }, + "end": { + "line": 15, + "column": 6 + } + } + }, + "operator": "+=", + "right": { + "type": "Literal", + "raw": "5", + "value": 5, + "range": [ + 196, + 197 + ], + "loc": { + "start": { + "line": 15, + "column": 10 + }, + "end": { + "line": 15, + "column": 11 + } + } + }, + "range": [ + 188, + 197 + ], + "loc": { + "start": { + "line": 15, + "column": 2 + }, + "end": { + "line": 15, + "column": 11 + } + } + }, + "range": [ + 188, + 198 + ], + "loc": { + "start": { + "line": 15, + "column": 2 + }, + "end": { + "line": 15, + "column": 12 + } + } + }, + { + "type": "IfStatement", + "alternate": null, + "consequent": { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "left": { + "type": "Identifier", + "name": "burst", + "range": [ + 216, + 221 + ], + "loc": { + "start": { + "line": 16, + "column": 17 + }, + "end": { + "line": 16, + "column": 22 + } + } + }, + "operator": "=", + "right": { + "type": "Literal", + "raw": "true", + "value": true, + "range": [ + 224, + 228 + ], + "loc": { + "start": { + "line": 16, + "column": 25 + }, + "end": { + "line": 16, + "column": 29 + } + } + }, + "range": [ + 216, + 228 + ], + "loc": { + "start": { + "line": 16, + "column": 17 + }, + "end": { + "line": 16, + "column": 29 + } + } + }, + "range": [ + 216, + 229 + ], + "loc": { + "start": { + "line": 16, + "column": 17 + }, + "end": { + "line": 16, + "column": 30 + } + } + }, + "test": { + "type": "BinaryExpression", + "left": { + "type": "Identifier", + "name": "size", + "range": [ + 205, + 209 + ], + "loc": { + "start": { + "line": 16, + "column": 6 + }, + "end": { + "line": 16, + "column": 10 + } + } + }, + "operator": ">", + "right": { + "type": "Literal", + "raw": "75", + "value": 75, + "range": [ + 212, + 214 + ], + "loc": { + "start": { + "line": 16, + "column": 13 + }, + "end": { + "line": 16, + "column": 15 + } + } + }, + "range": [ + 205, + 214 + ], + "loc": { + "start": { + "line": 16, + "column": 6 + }, + "end": { + "line": 16, + "column": 15 + } + } + }, + "range": [ + 201, + 229 + ], + "loc": { + "start": { + "line": 16, + "column": 2 + }, + "end": { + "line": 16, + "column": 30 + } + } + } + ], + "range": [ + 184, + 232 + ], + "loc": { + "start": { + "line": 14, + "column": 16 + }, + "end": { + "line": 17, + "column": 2 + } + } + }, + "expression": false, + "generator": false, + "id": null, + "params": [], + "range": [ + 178, + 232 + ], + "loc": { + "start": { + "line": 14, + "column": 10 + }, + "end": { + "line": 17, + "column": 2 + } + } + }, + "range": [ + 177, + 233 + ], + "loc": { + "start": { + "line": 14, + "column": 9 + }, + "end": { + "line": 17, + "column": 3 + } + } + } + ], + "range": [ + 169, + 233 + ], + "loc": { + "start": { + "line": 14, + "column": 1 + }, + "end": { + "line": 17, + "column": 3 + } + } + }, + { + "type": "SvelteAttribute", + "key": { + "type": "SvelteName", + "name": "deflate", + "range": [ + 235, + 242 + ], + "loc": { + "start": { + "line": 18, + "column": 1 + }, + "end": { + "line": 18, + "column": 8 + } + } + }, + "boolean": false, + "value": [ + { + "type": "SvelteMustacheTag", + "kind": "text", + "expression": { + "type": "ArrowFunctionExpression", + "async": false, + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "alternate": null, + "consequent": { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "left": { + "type": "Identifier", + "name": "size", + "range": [ + 268, + 272 + ], + "loc": { + "start": { + "line": 19, + "column": 16 + }, + "end": { + "line": 19, + "column": 20 + } + } + }, + "operator": "-=", + "right": { + "type": "Literal", + "raw": "5", + "value": 5, + "range": [ + 276, + 277 + ], + "loc": { + "start": { + "line": 19, + "column": 24 + }, + "end": { + "line": 19, + "column": 25 + } + } + }, + "range": [ + 268, + 277 + ], + "loc": { + "start": { + "line": 19, + "column": 16 + }, + "end": { + "line": 19, + "column": 25 + } + } + }, + "range": [ + 268, + 278 + ], + "loc": { + "start": { + "line": 19, + "column": 16 + }, + "end": { + "line": 19, + "column": 26 + } + } + }, + "test": { + "type": "BinaryExpression", + "left": { + "type": "Identifier", + "name": "size", + "range": [ + 258, + 262 + ], + "loc": { + "start": { + "line": 19, + "column": 6 + }, + "end": { + "line": 19, + "column": 10 + } + } + }, + "operator": ">", + "right": { + "type": "Literal", + "raw": "0", + "value": 0, + "range": [ + 265, + 266 + ], + "loc": { + "start": { + "line": 19, + "column": 13 + }, + "end": { + "line": 19, + "column": 14 + } + } + }, + "range": [ + 258, + 266 + ], + "loc": { + "start": { + "line": 19, + "column": 6 + }, + "end": { + "line": 19, + "column": 14 + } + } + }, + "range": [ + 254, + 278 + ], + "loc": { + "start": { + "line": 19, + "column": 2 + }, + "end": { + "line": 19, + "column": 26 + } + } + } + ], + "range": [ + 250, + 281 + ], + "loc": { + "start": { + "line": 18, + "column": 16 + }, + "end": { + "line": 20, + "column": 2 + } + } + }, + "expression": false, + "generator": false, + "id": null, + "params": [], + "range": [ + 244, + 281 + ], + "loc": { + "start": { + "line": 18, + "column": 10 + }, + "end": { + "line": 20, + "column": 2 + } + } + }, + "range": [ + 243, + 282 + ], + "loc": { + "start": { + "line": 18, + "column": 9 + }, + "end": { + "line": 20, + "column": 3 + } + } + } + ], + "range": [ + 235, + 282 + ], + "loc": { + "start": { + "line": 18, + "column": 1 + }, + "end": { + "line": 20, + "column": 3 + } + } + } + ], + "selfClosing": true, + "range": [ + 162, + 285 + ], + "loc": { + "start": { + "line": 13, + "column": 0 + }, + "end": { + "line": 21, + "column": 2 + } + } + }, + "children": [], + "endTag": null, + "range": [ + 162, + 285 + ], + "loc": { + "start": { + "line": 13, + "column": 0 + }, + "end": { + "line": 21, + "column": 2 + } + } + }, + { + "type": "SvelteText", + "value": "\n\n", + "range": [ + 285, + 287 + ], + "loc": { + "start": { + "line": 21, + "column": 2 + }, + "end": { + "line": 23, + "column": 0 + } + } + }, + { + "type": "SvelteIfBlock", + "elseif": false, + "expression": { + "type": "Identifier", + "name": "burst", + "range": [ + 292, + 297 + ], + "loc": { + "start": { + "line": 23, + "column": 5 + }, + "end": { + "line": 23, + "column": 10 + } + } + }, + "children": [ + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "button", + "range": [ + 301, + 307 + ], + "loc": { + "start": { + "line": 24, + "column": 2 + }, + "end": { + "line": 24, + "column": 8 + } + } + }, + "startTag": { + "type": "SvelteStartTag", + "attributes": [ + { + "type": "SvelteAttribute", + "key": { + "type": "SvelteName", + "name": "onclick", + "range": [ + 308, + 315 + ], + "loc": { + "start": { + "line": 24, + "column": 9 + }, + "end": { + "line": 24, + "column": 16 + } + } + }, + "boolean": false, + "value": [ + { + "type": "SvelteMustacheTag", + "kind": "text", + "expression": { + "type": "Identifier", + "name": "reset", + "range": [ + 317, + 322 + ], + "loc": { + "start": { + "line": 24, + "column": 18 + }, + "end": { + "line": 24, + "column": 23 + } + } + }, + "range": [ + 316, + 323 + ], + "loc": { + "start": { + "line": 24, + "column": 17 + }, + "end": { + "line": 24, + "column": 24 + } + } + } + ], + "range": [ + 308, + 323 + ], + "loc": { + "start": { + "line": 24, + "column": 9 + }, + "end": { + "line": 24, + "column": 24 + } + } + } + ], + "selfClosing": false, + "range": [ + 300, + 324 + ], + "loc": { + "start": { + "line": 24, + "column": 1 + }, + "end": { + "line": 24, + "column": 25 + } + } + }, + "children": [ + { + "type": "SvelteText", + "value": "new balloon", + "range": [ + 324, + 335 + ], + "loc": { + "start": { + "line": 24, + "column": 25 + }, + "end": { + "line": 24, + "column": 36 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", + "range": [ + 335, + 344 + ], + "loc": { + "start": { + "line": 24, + "column": 36 + }, + "end": { + "line": 24, + "column": 45 + } + } + }, + "range": [ + 300, + 344 + ], + "loc": { + "start": { + "line": 24, + "column": 1 + }, + "end": { + "line": 24, + "column": 45 + } + } + }, + { + "type": "SvelteText", + "value": "\n\t", + "range": [ + 344, + 346 + ], + "loc": { + "start": { + "line": 24, + "column": 45 + }, + "end": { + "line": 25, + "column": 1 + } + } + }, + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "span", + "range": [ + 347, + 351 + ], + "loc": { + "start": { + "line": 25, + "column": 2 + }, + "end": { + "line": 25, + "column": 6 + } + } + }, + "startTag": { + "type": "SvelteStartTag", + "attributes": [ + { + "type": "SvelteAttribute", + "key": { + "type": "SvelteName", + "name": "class", + "range": [ + 352, + 357 + ], + "loc": { + "start": { + "line": 25, + "column": 7 + }, + "end": { + "line": 25, + "column": 12 + } + } + }, + "boolean": false, + "value": [ + { + "type": "SvelteLiteral", + "value": "boom", + "range": [ + 359, + 363 + ], + "loc": { + "start": { + "line": 25, + "column": 14 + }, + "end": { + "line": 25, + "column": 18 + } + } + } + ], + "range": [ + 352, + 364 + ], + "loc": { + "start": { + "line": 25, + "column": 7 + }, + "end": { + "line": 25, + "column": 19 + } + } + } + ], + "selfClosing": false, + "range": [ + 346, + 365 + ], + "loc": { + "start": { + "line": 25, + "column": 1 + }, + "end": { + "line": 25, + "column": 20 + } + } + }, + "children": [ + { + "type": "SvelteText", + "value": "💥", + "range": [ + 365, + 367 + ], + "loc": { + "start": { + "line": 25, + "column": 20 + }, + "end": { + "line": 25, + "column": 22 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", + "range": [ + 367, + 374 + ], + "loc": { + "start": { + "line": 25, + "column": 22 + }, + "end": { + "line": 25, + "column": 29 + } + } + }, + "range": [ + 346, + 374 + ], + "loc": { + "start": { + "line": 25, + "column": 1 + }, + "end": { + "line": 25, + "column": 29 + } + } + } + ], + "else": { + "type": "SvelteElseBlock", + "elseif": false, + "children": [ + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "span", + "range": [ + 385, + 389 + ], + "loc": { + "start": { + "line": 27, + "column": 2 + }, + "end": { + "line": 27, + "column": 6 + } + } + }, + "startTag": { + "type": "SvelteStartTag", + "attributes": [ + { + "type": "SvelteAttribute", + "key": { + "type": "SvelteName", + "name": "class", + "range": [ + 390, + 395 + ], + "loc": { + "start": { + "line": 27, + "column": 7 + }, + "end": { + "line": 27, + "column": 12 + } + } + }, + "boolean": false, + "value": [ + { + "type": "SvelteLiteral", + "value": "balloon", + "range": [ + 397, + 404 + ], + "loc": { + "start": { + "line": 27, + "column": 14 + }, + "end": { + "line": 27, + "column": 21 + } + } + } + ], + "range": [ + 390, + 405 + ], + "loc": { + "start": { + "line": 27, + "column": 7 + }, + "end": { + "line": 27, + "column": 22 + } + } + }, + { + "type": "SvelteAttribute", + "key": { + "type": "SvelteName", + "name": "style", + "range": [ + 406, + 411 + ], + "loc": { + "start": { + "line": 27, + "column": 23 + }, + "end": { + "line": 27, + "column": 28 + } + } + }, + "boolean": false, + "value": [ + { + "type": "SvelteLiteral", + "value": "scale: ", + "range": [ + 413, + 420 + ], + "loc": { + "start": { + "line": 27, + "column": 30 + }, + "end": { + "line": 27, + "column": 37 + } + } + }, + { + "type": "SvelteMustacheTag", + "kind": "text", + "expression": { + "type": "BinaryExpression", + "left": { + "type": "Literal", + "raw": "0.01", + "value": 0.01, + "range": [ + 421, + 425 + ], + "loc": { + "start": { + "line": 27, + "column": 38 + }, + "end": { + "line": 27, + "column": 42 + } + } + }, + "operator": "*", + "right": { + "type": "Identifier", + "name": "size", + "range": [ + 428, + 432 + ], + "loc": { + "start": { + "line": 27, + "column": 45 + }, + "end": { + "line": 27, + "column": 49 + } + } + }, + "range": [ + 421, + 432 + ], + "loc": { + "start": { + "line": 27, + "column": 38 + }, + "end": { + "line": 27, + "column": 49 + } + } + }, + "range": [ + 420, + 433 + ], + "loc": { + "start": { + "line": 27, + "column": 37 + }, + "end": { + "line": 27, + "column": 50 + } + } + } + ], + "range": [ + 406, + 434 + ], + "loc": { + "start": { + "line": 27, + "column": 23 + }, + "end": { + "line": 27, + "column": 51 + } + } + } + ], + "selfClosing": false, + "range": [ + 384, + 435 + ], + "loc": { + "start": { + "line": 27, + "column": 1 + }, + "end": { + "line": 27, + "column": 52 + } + } + }, + "children": [ + { + "type": "SvelteText", + "value": "\n\t\t🎈\n\t", + "range": [ + 435, + 442 + ], + "loc": { + "start": { + "line": 27, + "column": 52 + }, + "end": { + "line": 29, + "column": 1 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", + "range": [ + 442, + 449 + ], + "loc": { + "start": { + "line": 29, + "column": 1 + }, + "end": { + "line": 29, + "column": 8 + } + } + }, + "range": [ + 384, + 449 + ], + "loc": { + "start": { + "line": 27, + "column": 1 + }, + "end": { + "line": 29, + "column": 8 + } + } + } + ], + "range": [ + 375, + 450 + ], + "loc": { + "start": { + "line": 26, + "column": 0 + }, + "end": { + "line": 30, + "column": 0 + } + } + }, + "range": [ + 287, + 455 + ], + "loc": { + "start": { + "line": 23, + "column": 0 + }, + "end": { + "line": 30, + "column": 5 + } + } + } + ], + "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": "Pump", + "range": [ + 17, + 21 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 12 + } + } + }, + { + "type": "Identifier", + "value": "from", + "range": [ + 22, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 17 + } + } + }, + { + "type": "String", + "value": "'./Pump.svelte'", + "range": [ + 27, + 42 + ], + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 33 + } + } + }, + { + "type": "Punctuator", + "value": ";", + "range": [ + 42, + 43 + ], + "loc": { + "start": { + "line": 2, + "column": 33 + }, + "end": { + "line": 2, + "column": 34 + } + } + }, + { + "type": "Keyword", + "value": "let", + "range": [ + 46, + 49 + ], + "loc": { + "start": { + "line": 4, + "column": 1 + }, + "end": { + "line": 4, + "column": 4 + } + } + }, + { + "type": "Identifier", + "value": "size", + "range": [ + 50, + 54 + ], + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 9 + } + } + }, + { + "type": "Punctuator", + "value": "=", + "range": [ + 55, + 56 + ], + "loc": { + "start": { + "line": 4, + "column": 10 + }, + "end": { + "line": 4, + "column": 11 + } + } + }, + { + "type": "Identifier", + "value": "$state", + "range": [ + 57, + 63 + ], + "loc": { + "start": { + "line": 4, + "column": 12 + }, + "end": { + "line": 4, + "column": 18 + } + } + }, + { + "type": "Punctuator", + "value": "(", + "range": [ + 63, + 64 + ], + "loc": { + "start": { + "line": 4, + "column": 18 + }, + "end": { + "line": 4, + "column": 19 + } + } + }, + { + "type": "Numeric", + "value": "15", + "range": [ + 64, + 66 + ], + "loc": { + "start": { + "line": 4, + "column": 19 + }, + "end": { + "line": 4, + "column": 21 + } + } + }, + { + "type": "Punctuator", + "value": ")", + "range": [ + 66, + 67 + ], + "loc": { + "start": { + "line": 4, + "column": 21 + }, + "end": { + "line": 4, + "column": 22 + } + } + }, + { + "type": "Punctuator", + "value": ";", + "range": [ + 67, + 68 + ], + "loc": { + "start": { + "line": 4, + "column": 22 + }, + "end": { + "line": 4, + "column": 23 + } + } + }, + { + "type": "Keyword", + "value": "let", + "range": [ + 70, + 73 + ], + "loc": { + "start": { + "line": 5, + "column": 1 + }, + "end": { + "line": 5, + "column": 4 + } + } + }, + { + "type": "Identifier", + "value": "burst", + "range": [ + 74, + 79 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 10 + } + } + }, + { + "type": "Punctuator", + "value": "=", + "range": [ + 80, + 81 + ], + "loc": { + "start": { + "line": 5, + "column": 11 + }, + "end": { + "line": 5, + "column": 12 + } + } + }, + { + "type": "Identifier", + "value": "$state", + "range": [ + 82, + 88 + ], + "loc": { + "start": { + "line": 5, + "column": 13 + }, + "end": { + "line": 5, + "column": 19 + } + } + }, + { + "type": "Punctuator", + "value": "(", + "range": [ + 88, + 89 + ], + "loc": { + "start": { + "line": 5, + "column": 19 + }, + "end": { + "line": 5, + "column": 20 + } + } + }, + { + "type": "Boolean", + "value": "false", + "range": [ + 89, + 94 + ], + "loc": { + "start": { + "line": 5, + "column": 20 + }, + "end": { + "line": 5, + "column": 25 + } + } + }, + { + "type": "Punctuator", + "value": ")", + "range": [ + 94, + 95 + ], + "loc": { + "start": { + "line": 5, + "column": 25 + }, + "end": { + "line": 5, + "column": 26 + } + } + }, + { + "type": "Punctuator", + "value": ";", + "range": [ + 95, + 96 + ], + "loc": { + "start": { + "line": 5, + "column": 26 + }, + "end": { + "line": 5, + "column": 27 + } + } + }, + { + "type": "Keyword", + "value": "function", + "range": [ + 99, + 107 + ], + "loc": { + "start": { + "line": 7, + "column": 1 + }, + "end": { + "line": 7, + "column": 9 + } + } + }, + { + "type": "Identifier", + "value": "reset", + "range": [ + 108, + 113 + ], + "loc": { + "start": { + "line": 7, + "column": 10 + }, + "end": { + "line": 7, + "column": 15 + } + } + }, + { + "type": "Punctuator", + "value": "(", + "range": [ + 113, + 114 + ], + "loc": { + "start": { + "line": 7, + "column": 15 + }, + "end": { + "line": 7, + "column": 16 + } + } + }, + { + "type": "Punctuator", + "value": ")", + "range": [ + 114, + 115 + ], + "loc": { + "start": { + "line": 7, + "column": 16 + }, + "end": { + "line": 7, + "column": 17 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 116, + 117 + ], + "loc": { + "start": { + "line": 7, + "column": 18 + }, + "end": { + "line": 7, + "column": 19 + } + } + }, + { + "type": "Identifier", + "value": "size", + "range": [ + 120, + 124 + ], + "loc": { + "start": { + "line": 8, + "column": 2 + }, + "end": { + "line": 8, + "column": 6 + } + } + }, + { + "type": "Punctuator", + "value": "=", + "range": [ + 125, + 126 + ], + "loc": { + "start": { + "line": 8, + "column": 7 + }, + "end": { + "line": 8, + "column": 8 + } + } + }, + { + "type": "Numeric", + "value": "15", + "range": [ + 127, + 129 + ], + "loc": { + "start": { + "line": 8, + "column": 9 + }, + "end": { + "line": 8, + "column": 11 + } + } + }, + { + "type": "Punctuator", + "value": ";", + "range": [ + 129, + 130 + ], + "loc": { + "start": { + "line": 8, + "column": 11 + }, + "end": { + "line": 8, + "column": 12 + } + } + }, + { + "type": "Identifier", + "value": "burst", + "range": [ + 133, + 138 + ], + "loc": { + "start": { + "line": 9, + "column": 2 + }, + "end": { + "line": 9, + "column": 7 + } + } + }, + { + "type": "Punctuator", + "value": "=", + "range": [ + 139, + 140 + ], + "loc": { + "start": { + "line": 9, + "column": 8 + }, + "end": { + "line": 9, + "column": 9 + } + } + }, + { + "type": "Boolean", + "value": "false", + "range": [ + 141, + 146 + ], + "loc": { + "start": { + "line": 9, + "column": 10 + }, + "end": { + "line": 9, + "column": 15 + } + } + }, + { + "type": "Punctuator", + "value": ";", + "range": [ + 146, + 147 + ], + "loc": { + "start": { + "line": 9, + "column": 15 + }, + "end": { + "line": 9, + "column": 16 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 149, + 150 + ], + "loc": { + "start": { + "line": 10, + "column": 1 + }, + "end": { + "line": 10, + "column": 2 + } + } + }, + { + "type": "Punctuator", + "value": "<", + "range": [ + 151, + 152 + ], + "loc": { + "start": { + "line": 11, + "column": 0 + }, + "end": { + "line": 11, + "column": 1 + } + } + }, + { + "type": "Punctuator", + "value": "/", + "range": [ + 152, + 153 + ], + "loc": { + "start": { + "line": 11, + "column": 1 + }, + "end": { + "line": 11, + "column": 2 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "script", + "range": [ + 153, + 159 + ], + "loc": { + "start": { + "line": 11, + "column": 2 + }, + "end": { + "line": 11, + "column": 8 + } + } + }, + { + "type": "Punctuator", + "value": ">", + "range": [ + 159, + 160 + ], + "loc": { + "start": { + "line": 11, + "column": 8 + }, + "end": { + "line": 11, + "column": 9 + } + } + }, + { + "type": "HTMLText", + "value": "\n\n", + "range": [ + 160, + 162 + ], + "loc": { + "start": { + "line": 11, + "column": 9 + }, + "end": { + "line": 13, + "column": 0 + } + } + }, + { + "type": "Punctuator", + "value": "<", + "range": [ + 162, + 163 + ], + "loc": { + "start": { + "line": 13, + "column": 0 + }, + "end": { + "line": 13, + "column": 1 + } + } + }, + { + "type": "Identifier", + "value": "Pump", + "range": [ + 163, + 167 + ], + "loc": { + "start": { + "line": 13, + "column": 1 + }, + "end": { + "line": 13, + "column": 5 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "inflate", + "range": [ + 169, + 176 + ], + "loc": { + "start": { + "line": 14, + "column": 1 + }, + "end": { + "line": 14, + "column": 8 + } + } + }, + { + "type": "Punctuator", + "value": "=", + "range": [ + 176, + 177 + ], + "loc": { + "start": { + "line": 14, + "column": 8 + }, + "end": { + "line": 14, + "column": 9 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 177, + 178 + ], + "loc": { + "start": { + "line": 14, + "column": 9 + }, + "end": { + "line": 14, + "column": 10 + } + } + }, + { + "type": "Punctuator", + "value": "(", + "range": [ + 178, + 179 + ], + "loc": { + "start": { + "line": 14, + "column": 10 + }, + "end": { + "line": 14, + "column": 11 + } + } + }, + { + "type": "Punctuator", + "value": ")", + "range": [ + 179, + 180 + ], + "loc": { + "start": { + "line": 14, + "column": 11 + }, + "end": { + "line": 14, + "column": 12 + } + } + }, + { + "type": "Punctuator", + "value": "=>", + "range": [ + 181, + 183 + ], + "loc": { + "start": { + "line": 14, + "column": 13 + }, + "end": { + "line": 14, + "column": 15 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 184, + 185 + ], + "loc": { + "start": { + "line": 14, + "column": 16 + }, + "end": { + "line": 14, + "column": 17 + } + } + }, + { + "type": "Identifier", + "value": "size", + "range": [ + 188, + 192 + ], + "loc": { + "start": { + "line": 15, + "column": 2 + }, + "end": { + "line": 15, + "column": 6 + } + } + }, + { + "type": "Punctuator", + "value": "+=", + "range": [ + 193, + 195 + ], + "loc": { + "start": { + "line": 15, + "column": 7 + }, + "end": { + "line": 15, + "column": 9 + } + } + }, + { + "type": "Numeric", + "value": "5", + "range": [ + 196, + 197 + ], + "loc": { + "start": { + "line": 15, + "column": 10 + }, + "end": { + "line": 15, + "column": 11 + } + } + }, + { + "type": "Punctuator", + "value": ";", + "range": [ + 197, + 198 + ], + "loc": { + "start": { + "line": 15, + "column": 11 + }, + "end": { + "line": 15, + "column": 12 + } + } + }, + { + "type": "Keyword", + "value": "if", + "range": [ + 201, + 203 + ], + "loc": { + "start": { + "line": 16, + "column": 2 + }, + "end": { + "line": 16, + "column": 4 + } + } + }, + { + "type": "Punctuator", + "value": "(", + "range": [ + 204, + 205 + ], + "loc": { + "start": { + "line": 16, + "column": 5 + }, + "end": { + "line": 16, + "column": 6 + } + } + }, + { + "type": "Identifier", + "value": "size", + "range": [ + 205, + 209 + ], + "loc": { + "start": { + "line": 16, + "column": 6 + }, + "end": { + "line": 16, + "column": 10 + } + } + }, + { + "type": "Punctuator", + "value": ">", + "range": [ + 210, + 211 + ], + "loc": { + "start": { + "line": 16, + "column": 11 + }, + "end": { + "line": 16, + "column": 12 + } + } + }, + { + "type": "Numeric", + "value": "75", + "range": [ + 212, + 214 + ], + "loc": { + "start": { + "line": 16, + "column": 13 + }, + "end": { + "line": 16, + "column": 15 + } + } + }, + { + "type": "Punctuator", + "value": ")", + "range": [ + 214, + 215 + ], + "loc": { + "start": { + "line": 16, + "column": 15 + }, + "end": { + "line": 16, + "column": 16 + } + } + }, + { + "type": "Identifier", + "value": "burst", + "range": [ + 216, + 221 + ], + "loc": { + "start": { + "line": 16, + "column": 17 + }, + "end": { + "line": 16, + "column": 22 + } + } + }, + { + "type": "Punctuator", + "value": "=", + "range": [ + 222, + 223 + ], + "loc": { + "start": { + "line": 16, + "column": 23 + }, + "end": { + "line": 16, + "column": 24 + } + } + }, + { + "type": "Boolean", + "value": "true", + "range": [ + 224, + 228 + ], + "loc": { + "start": { + "line": 16, + "column": 25 + }, + "end": { + "line": 16, + "column": 29 + } + } + }, + { + "type": "Punctuator", + "value": ";", + "range": [ + 228, + 229 + ], + "loc": { + "start": { + "line": 16, + "column": 29 + }, + "end": { + "line": 16, + "column": 30 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 231, + 232 + ], + "loc": { + "start": { + "line": 17, + "column": 1 + }, + "end": { + "line": 17, + "column": 2 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 232, + 233 + ], + "loc": { + "start": { + "line": 17, + "column": 2 + }, + "end": { + "line": 17, + "column": 3 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "deflate", + "range": [ + 235, + 242 + ], + "loc": { + "start": { + "line": 18, + "column": 1 + }, + "end": { + "line": 18, + "column": 8 + } + } + }, + { + "type": "Punctuator", + "value": "=", + "range": [ + 242, + 243 + ], + "loc": { + "start": { + "line": 18, + "column": 8 + }, + "end": { + "line": 18, + "column": 9 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 243, + 244 + ], + "loc": { + "start": { + "line": 18, + "column": 9 + }, + "end": { + "line": 18, + "column": 10 + } + } + }, + { + "type": "Punctuator", + "value": "(", + "range": [ + 244, + 245 + ], + "loc": { + "start": { + "line": 18, + "column": 10 + }, + "end": { + "line": 18, + "column": 11 + } + } + }, + { + "type": "Punctuator", + "value": ")", + "range": [ + 245, + 246 + ], + "loc": { + "start": { + "line": 18, + "column": 11 + }, + "end": { + "line": 18, + "column": 12 + } + } + }, + { + "type": "Punctuator", + "value": "=>", + "range": [ + 247, + 249 + ], + "loc": { + "start": { + "line": 18, + "column": 13 + }, + "end": { + "line": 18, + "column": 15 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 250, + 251 + ], + "loc": { + "start": { + "line": 18, + "column": 16 + }, + "end": { + "line": 18, + "column": 17 + } + } + }, + { + "type": "Keyword", + "value": "if", + "range": [ + 254, + 256 + ], + "loc": { + "start": { + "line": 19, + "column": 2 + }, + "end": { + "line": 19, + "column": 4 + } + } + }, + { + "type": "Punctuator", + "value": "(", + "range": [ + 257, + 258 + ], + "loc": { + "start": { + "line": 19, + "column": 5 + }, + "end": { + "line": 19, + "column": 6 + } + } + }, + { + "type": "Identifier", + "value": "size", + "range": [ + 258, + 262 + ], + "loc": { + "start": { + "line": 19, + "column": 6 + }, + "end": { + "line": 19, + "column": 10 + } + } + }, + { + "type": "Punctuator", + "value": ">", + "range": [ + 263, + 264 + ], + "loc": { + "start": { + "line": 19, + "column": 11 + }, + "end": { + "line": 19, + "column": 12 + } + } + }, + { + "type": "Numeric", + "value": "0", + "range": [ + 265, + 266 + ], + "loc": { + "start": { + "line": 19, + "column": 13 + }, + "end": { + "line": 19, + "column": 14 + } + } + }, + { + "type": "Punctuator", + "value": ")", + "range": [ + 266, + 267 + ], + "loc": { + "start": { + "line": 19, + "column": 14 + }, + "end": { + "line": 19, + "column": 15 + } + } + }, + { + "type": "Identifier", + "value": "size", + "range": [ + 268, + 272 + ], + "loc": { + "start": { + "line": 19, + "column": 16 + }, + "end": { + "line": 19, + "column": 20 + } + } + }, + { + "type": "Punctuator", + "value": "-=", + "range": [ + 273, + 275 + ], + "loc": { + "start": { + "line": 19, + "column": 21 + }, + "end": { + "line": 19, + "column": 23 + } + } + }, + { + "type": "Numeric", + "value": "5", + "range": [ + 276, + 277 + ], + "loc": { + "start": { + "line": 19, + "column": 24 + }, + "end": { + "line": 19, + "column": 25 + } + } + }, + { + "type": "Punctuator", + "value": ";", + "range": [ + 277, + 278 + ], + "loc": { + "start": { + "line": 19, + "column": 25 + }, + "end": { + "line": 19, + "column": 26 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 280, + 281 + ], + "loc": { + "start": { + "line": 20, + "column": 1 + }, + "end": { + "line": 20, + "column": 2 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 281, + 282 + ], + "loc": { + "start": { + "line": 20, + "column": 2 + }, + "end": { + "line": 20, + "column": 3 + } + } + }, + { + "type": "Punctuator", + "value": "/", + "range": [ + 283, + 284 + ], + "loc": { + "start": { + "line": 21, + "column": 0 + }, + "end": { + "line": 21, + "column": 1 + } + } + }, + { + "type": "Punctuator", + "value": ">", + "range": [ + 284, + 285 + ], + "loc": { + "start": { + "line": 21, + "column": 1 + }, + "end": { + "line": 21, + "column": 2 + } + } + }, + { + "type": "HTMLText", + "value": "\n\n", + "range": [ + 285, + 287 + ], + "loc": { + "start": { + "line": 21, + "column": 2 + }, + "end": { + "line": 23, + "column": 0 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 287, + 288 + ], + "loc": { + "start": { + "line": 23, + "column": 0 + }, + "end": { + "line": 23, + "column": 1 + } + } + }, + { + "type": "MustacheKeyword", + "value": "#if", + "range": [ + 288, + 291 + ], + "loc": { + "start": { + "line": 23, + "column": 1 + }, + "end": { + "line": 23, + "column": 4 + } + } + }, + { + "type": "Identifier", + "value": "burst", + "range": [ + 292, + 297 + ], + "loc": { + "start": { + "line": 23, + "column": 5 + }, + "end": { + "line": 23, + "column": 10 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 297, + 298 + ], + "loc": { + "start": { + "line": 23, + "column": 10 + }, + "end": { + "line": 23, + "column": 11 + } + } + }, + { + "type": "Punctuator", + "value": "<", + "range": [ + 300, + 301 + ], + "loc": { + "start": { + "line": 24, + "column": 1 + }, + "end": { + "line": 24, + "column": 2 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "button", + "range": [ + 301, + 307 + ], + "loc": { + "start": { + "line": 24, + "column": 2 + }, + "end": { + "line": 24, + "column": 8 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "onclick", + "range": [ + 308, + 315 + ], + "loc": { + "start": { + "line": 24, + "column": 9 + }, + "end": { + "line": 24, + "column": 16 + } + } + }, + { + "type": "Punctuator", + "value": "=", + "range": [ + 315, + 316 + ], + "loc": { + "start": { + "line": 24, + "column": 16 + }, + "end": { + "line": 24, + "column": 17 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 316, + 317 + ], + "loc": { + "start": { + "line": 24, + "column": 17 + }, + "end": { + "line": 24, + "column": 18 + } + } + }, + { + "type": "Identifier", + "value": "reset", + "range": [ + 317, + 322 + ], + "loc": { + "start": { + "line": 24, + "column": 18 + }, + "end": { + "line": 24, + "column": 23 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 322, + 323 + ], + "loc": { + "start": { + "line": 24, + "column": 23 + }, + "end": { + "line": 24, + "column": 24 + } + } + }, + { + "type": "Punctuator", + "value": ">", + "range": [ + 323, + 324 + ], + "loc": { + "start": { + "line": 24, + "column": 24 + }, + "end": { + "line": 24, + "column": 25 + } + } + }, + { + "type": "HTMLText", + "value": "new", + "range": [ + 324, + 327 + ], + "loc": { + "start": { + "line": 24, + "column": 25 + }, + "end": { + "line": 24, + "column": 28 + } + } + }, + { + "type": "HTMLText", + "value": " ", + "range": [ + 327, + 328 + ], + "loc": { + "start": { + "line": 24, + "column": 28 + }, + "end": { + "line": 24, + "column": 29 + } + } + }, + { + "type": "HTMLText", + "value": "balloon", + "range": [ + 328, + 335 + ], + "loc": { + "start": { + "line": 24, + "column": 29 + }, + "end": { + "line": 24, + "column": 36 + } + } + }, + { + "type": "Punctuator", + "value": "<", + "range": [ + 335, + 336 + ], + "loc": { + "start": { + "line": 24, + "column": 36 + }, + "end": { + "line": 24, + "column": 37 + } + } + }, + { + "type": "Punctuator", + "value": "/", + "range": [ + 336, + 337 + ], + "loc": { + "start": { + "line": 24, + "column": 37 + }, + "end": { + "line": 24, + "column": 38 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "button", + "range": [ + 337, + 343 + ], + "loc": { + "start": { + "line": 24, + "column": 38 + }, + "end": { + "line": 24, + "column": 44 + } + } + }, + { + "type": "Punctuator", + "value": ">", + "range": [ + 343, + 344 + ], + "loc": { + "start": { + "line": 24, + "column": 44 + }, + "end": { + "line": 24, + "column": 45 + } + } + }, + { + "type": "HTMLText", + "value": "\n\t", + "range": [ + 344, + 346 + ], + "loc": { + "start": { + "line": 24, + "column": 45 + }, + "end": { + "line": 25, + "column": 1 + } + } + }, + { + "type": "Punctuator", + "value": "<", + "range": [ + 346, + 347 + ], + "loc": { + "start": { + "line": 25, + "column": 1 + }, + "end": { + "line": 25, + "column": 2 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "span", + "range": [ + 347, + 351 + ], + "loc": { + "start": { + "line": 25, + "column": 2 + }, + "end": { + "line": 25, + "column": 6 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "class", + "range": [ + 352, + 357 + ], + "loc": { + "start": { + "line": 25, + "column": 7 + }, + "end": { + "line": 25, + "column": 12 + } + } + }, + { + "type": "Punctuator", + "value": "=", + "range": [ + 357, + 358 + ], + "loc": { + "start": { + "line": 25, + "column": 12 + }, + "end": { + "line": 25, + "column": 13 + } + } + }, + { + "type": "Punctuator", + "value": "\"", + "range": [ + 358, + 359 + ], + "loc": { + "start": { + "line": 25, + "column": 13 + }, + "end": { + "line": 25, + "column": 14 + } + } + }, + { + "type": "HTMLText", + "value": "boom", + "range": [ + 359, + 363 + ], + "loc": { + "start": { + "line": 25, + "column": 14 + }, + "end": { + "line": 25, + "column": 18 + } + } + }, + { + "type": "Punctuator", + "value": "\"", + "range": [ + 363, + 364 + ], + "loc": { + "start": { + "line": 25, + "column": 18 + }, + "end": { + "line": 25, + "column": 19 + } + } + }, + { + "type": "Punctuator", + "value": ">", + "range": [ + 364, + 365 + ], + "loc": { + "start": { + "line": 25, + "column": 19 + }, + "end": { + "line": 25, + "column": 20 + } + } + }, + { + "type": "HTMLText", + "value": "💥", + "range": [ + 365, + 367 + ], + "loc": { + "start": { + "line": 25, + "column": 20 + }, + "end": { + "line": 25, + "column": 22 + } + } + }, + { + "type": "Punctuator", + "value": "<", + "range": [ + 367, + 368 + ], + "loc": { + "start": { + "line": 25, + "column": 22 + }, + "end": { + "line": 25, + "column": 23 + } + } + }, + { + "type": "Punctuator", + "value": "/", + "range": [ + 368, + 369 + ], + "loc": { + "start": { + "line": 25, + "column": 23 + }, + "end": { + "line": 25, + "column": 24 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "span", + "range": [ + 369, + 373 + ], + "loc": { + "start": { + "line": 25, + "column": 24 + }, + "end": { + "line": 25, + "column": 28 + } + } + }, + { + "type": "Punctuator", + "value": ">", + "range": [ + 373, + 374 + ], + "loc": { + "start": { + "line": 25, + "column": 28 + }, + "end": { + "line": 25, + "column": 29 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 375, + 376 + ], + "loc": { + "start": { + "line": 26, + "column": 0 + }, + "end": { + "line": 26, + "column": 1 + } + } + }, + { + "type": "MustacheKeyword", + "value": ":else", + "range": [ + 376, + 381 + ], + "loc": { + "start": { + "line": 26, + "column": 1 + }, + "end": { + "line": 26, + "column": 6 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 381, + 382 + ], + "loc": { + "start": { + "line": 26, + "column": 6 + }, + "end": { + "line": 26, + "column": 7 + } + } + }, + { + "type": "Punctuator", + "value": "<", + "range": [ + 384, + 385 + ], + "loc": { + "start": { + "line": 27, + "column": 1 + }, + "end": { + "line": 27, + "column": 2 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "span", + "range": [ + 385, + 389 + ], + "loc": { + "start": { + "line": 27, + "column": 2 + }, + "end": { + "line": 27, + "column": 6 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "class", + "range": [ + 390, + 395 + ], + "loc": { + "start": { + "line": 27, + "column": 7 + }, + "end": { + "line": 27, + "column": 12 + } + } + }, + { + "type": "Punctuator", + "value": "=", + "range": [ + 395, + 396 + ], + "loc": { + "start": { + "line": 27, + "column": 12 + }, + "end": { + "line": 27, + "column": 13 + } + } + }, + { + "type": "Punctuator", + "value": "\"", + "range": [ + 396, + 397 + ], + "loc": { + "start": { + "line": 27, + "column": 13 + }, + "end": { + "line": 27, + "column": 14 + } + } + }, + { + "type": "HTMLText", + "value": "balloon", + "range": [ + 397, + 404 + ], + "loc": { + "start": { + "line": 27, + "column": 14 + }, + "end": { + "line": 27, + "column": 21 + } + } + }, + { + "type": "Punctuator", + "value": "\"", + "range": [ + 404, + 405 + ], + "loc": { + "start": { + "line": 27, + "column": 21 + }, + "end": { + "line": 27, + "column": 22 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "style", + "range": [ + 406, + 411 + ], + "loc": { + "start": { + "line": 27, + "column": 23 + }, + "end": { + "line": 27, + "column": 28 + } + } + }, + { + "type": "Punctuator", + "value": "=", + "range": [ + 411, + 412 + ], + "loc": { + "start": { + "line": 27, + "column": 28 + }, + "end": { + "line": 27, + "column": 29 + } + } + }, + { + "type": "Punctuator", + "value": "\"", + "range": [ + 412, + 413 + ], + "loc": { + "start": { + "line": 27, + "column": 29 + }, + "end": { + "line": 27, + "column": 30 + } + } + }, + { + "type": "HTMLText", + "value": "scale:", + "range": [ + 413, + 419 + ], + "loc": { + "start": { + "line": 27, + "column": 30 + }, + "end": { + "line": 27, + "column": 36 + } + } + }, + { + "type": "HTMLText", + "value": " ", + "range": [ + 419, + 420 + ], + "loc": { + "start": { + "line": 27, + "column": 36 + }, + "end": { + "line": 27, + "column": 37 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 420, + 421 + ], + "loc": { + "start": { + "line": 27, + "column": 37 + }, + "end": { + "line": 27, + "column": 38 + } + } + }, + { + "type": "Numeric", + "value": "0.01", + "range": [ + 421, + 425 + ], + "loc": { + "start": { + "line": 27, + "column": 38 + }, + "end": { + "line": 27, + "column": 42 + } + } + }, + { + "type": "Punctuator", + "value": "*", + "range": [ + 426, + 427 + ], + "loc": { + "start": { + "line": 27, + "column": 43 + }, + "end": { + "line": 27, + "column": 44 + } + } + }, + { + "type": "Identifier", + "value": "size", + "range": [ + 428, + 432 + ], + "loc": { + "start": { + "line": 27, + "column": 45 + }, + "end": { + "line": 27, + "column": 49 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 432, + 433 + ], + "loc": { + "start": { + "line": 27, + "column": 49 + }, + "end": { + "line": 27, + "column": 50 + } + } + }, + { + "type": "Punctuator", + "value": "\"", + "range": [ + 433, + 434 + ], + "loc": { + "start": { + "line": 27, + "column": 50 + }, + "end": { + "line": 27, + "column": 51 + } + } + }, + { + "type": "Punctuator", + "value": ">", + "range": [ + 434, + 435 + ], + "loc": { + "start": { + "line": 27, + "column": 51 + }, + "end": { + "line": 27, + "column": 52 + } + } + }, + { + "type": "HTMLText", + "value": "\n\t\t", + "range": [ + 435, + 438 + ], + "loc": { + "start": { + "line": 27, + "column": 52 + }, + "end": { + "line": 28, + "column": 2 + } + } + }, + { + "type": "HTMLText", + "value": "🎈", + "range": [ + 438, + 440 + ], + "loc": { + "start": { + "line": 28, + "column": 2 + }, + "end": { + "line": 28, + "column": 4 + } + } + }, + { + "type": "HTMLText", + "value": "\n\t", + "range": [ + 440, + 442 + ], + "loc": { + "start": { + "line": 28, + "column": 4 + }, + "end": { + "line": 29, + "column": 1 + } + } + }, + { + "type": "Punctuator", + "value": "<", + "range": [ + 442, + 443 + ], + "loc": { + "start": { + "line": 29, + "column": 1 + }, + "end": { + "line": 29, + "column": 2 + } + } + }, + { + "type": "Punctuator", + "value": "/", + "range": [ + 443, + 444 + ], + "loc": { + "start": { + "line": 29, + "column": 2 + }, + "end": { + "line": 29, + "column": 3 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "span", + "range": [ + 444, + 448 + ], + "loc": { + "start": { + "line": 29, + "column": 3 + }, + "end": { + "line": 29, + "column": 7 + } + } + }, + { + "type": "Punctuator", + "value": ">", + "range": [ + 448, + 449 + ], + "loc": { + "start": { + "line": 29, + "column": 7 + }, + "end": { + "line": 29, + "column": 8 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 450, + 451 + ], + "loc": { + "start": { + "line": 30, + "column": 0 + }, + "end": { + "line": 30, + "column": 1 + } + } + }, + { + "type": "MustacheKeyword", + "value": "/if", + "range": [ + 451, + 454 + ], + "loc": { + "start": { + "line": 30, + "column": 1 + }, + "end": { + "line": 30, + "column": 4 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 454, + 455 + ], + "loc": { + "start": { + "line": 30, + "column": 4 + }, + "end": { + "line": 30, + "column": 5 + } + } + } + ], + "range": [ + 0, + 456 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 31, + "column": 0 + } + } +} \ No newline at end of file diff --git a/tests/fixtures/parser/ast/svelte5/docs/event-handlers/03-component-events-scope-output.json b/tests/fixtures/parser/ast/svelte5/docs/event-handlers/03-component-events-scope-output.json new file mode 100644 index 00000000..0e87172f --- /dev/null +++ b/tests/fixtures/parser/ast/svelte5/docs/event-handlers/03-component-events-scope-output.json @@ -0,0 +1,2266 @@ +{ + "type": "global", + "variables": [ + { + "name": "$$slots", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$$props", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$$restProps", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$state", + "identifiers": [], + "defs": [], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "$state", + "range": [ + 57, + 63 + ], + "loc": { + "start": { + "line": 4, + "column": 12 + }, + "end": { + "line": 4, + "column": 18 + } + } + }, + "from": "module", + "init": null, + "resolved": null + }, + { + "identifier": { + "type": "Identifier", + "name": "$state", + "range": [ + 82, + 88 + ], + "loc": { + "start": { + "line": 5, + "column": 13 + }, + "end": { + "line": 5, + "column": 19 + } + } + }, + "from": "module", + "init": null, + "resolved": null + } + ] + }, + { + "name": "$derived", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$effect", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$props", + "identifiers": [], + "defs": [], + "references": [] + } + ], + "references": [], + "childScopes": [ + { + "type": "module", + "variables": [ + { + "name": "Pump", + "identifiers": [ + { + "type": "Identifier", + "name": "Pump", + "range": [ + 17, + 21 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 12 + } + } + } + ], + "defs": [ + { + "type": "ImportBinding", + "name": { + "type": "Identifier", + "name": "Pump", + "range": [ + 17, + 21 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 12 + } + } + }, + "node": { + "type": "ImportDefaultSpecifier", + "local": { + "type": "Identifier", + "name": "Pump", + "range": [ + 17, + 21 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 12 + } + } + }, + "range": [ + 17, + 21 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 12 + } + } + } + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "Pump", + "range": [ + 163, + 167 + ], + "loc": { + "start": { + "line": 13, + "column": 1 + }, + "end": { + "line": 13, + "column": 5 + } + } + }, + "from": "module", + "init": null, + "resolved": { + "type": "Identifier", + "name": "Pump", + "range": [ + 17, + 21 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 12 + } + } + } + } + ] + }, + { + "name": "size", + "identifiers": [ + { + "type": "Identifier", + "name": "size", + "range": [ + 50, + 54 + ], + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 9 + } + } + } + ], + "defs": [ + { + "type": "Variable", + "name": { + "type": "Identifier", + "name": "size", + "range": [ + 50, + 54 + ], + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 9 + } + } + }, + "node": { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "size", + "range": [ + 50, + 54 + ], + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 9 + } + } + }, + "init": { + "type": "CallExpression", + "arguments": [ + { + "type": "Literal", + "raw": "15", + "value": 15, + "range": [ + 64, + 66 + ], + "loc": { + "start": { + "line": 4, + "column": 19 + }, + "end": { + "line": 4, + "column": 21 + } + } + } + ], + "callee": { + "type": "Identifier", + "name": "$state", + "range": [ + 57, + 63 + ], + "loc": { + "start": { + "line": 4, + "column": 12 + }, + "end": { + "line": 4, + "column": 18 + } + } + }, + "optional": false, + "range": [ + 57, + 67 + ], + "loc": { + "start": { + "line": 4, + "column": 12 + }, + "end": { + "line": 4, + "column": 22 + } + } + }, + "range": [ + 50, + 67 + ], + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 22 + } + } + } + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "size", + "range": [ + 50, + 54 + ], + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 9 + } + } + }, + "from": "module", + "init": true, + "resolved": { + "type": "Identifier", + "name": "size", + "range": [ + 50, + 54 + ], + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 9 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "size", + "range": [ + 120, + 124 + ], + "loc": { + "start": { + "line": 8, + "column": 2 + }, + "end": { + "line": 8, + "column": 6 + } + } + }, + "from": "function", + "init": false, + "resolved": { + "type": "Identifier", + "name": "size", + "range": [ + 50, + 54 + ], + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 9 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "size", + "range": [ + 188, + 192 + ], + "loc": { + "start": { + "line": 15, + "column": 2 + }, + "end": { + "line": 15, + "column": 6 + } + } + }, + "from": "function", + "init": false, + "resolved": { + "type": "Identifier", + "name": "size", + "range": [ + 50, + 54 + ], + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 9 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "size", + "range": [ + 205, + 209 + ], + "loc": { + "start": { + "line": 16, + "column": 6 + }, + "end": { + "line": 16, + "column": 10 + } + } + }, + "from": "function", + "init": null, + "resolved": { + "type": "Identifier", + "name": "size", + "range": [ + 50, + 54 + ], + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 9 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "size", + "range": [ + 258, + 262 + ], + "loc": { + "start": { + "line": 19, + "column": 6 + }, + "end": { + "line": 19, + "column": 10 + } + } + }, + "from": "function", + "init": null, + "resolved": { + "type": "Identifier", + "name": "size", + "range": [ + 50, + 54 + ], + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 9 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "size", + "range": [ + 268, + 272 + ], + "loc": { + "start": { + "line": 19, + "column": 16 + }, + "end": { + "line": 19, + "column": 20 + } + } + }, + "from": "function", + "init": false, + "resolved": { + "type": "Identifier", + "name": "size", + "range": [ + 50, + 54 + ], + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 9 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "size", + "range": [ + 428, + 432 + ], + "loc": { + "start": { + "line": 27, + "column": 45 + }, + "end": { + "line": 27, + "column": 49 + } + } + }, + "from": "block", + "init": null, + "resolved": { + "type": "Identifier", + "name": "size", + "range": [ + 50, + 54 + ], + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 9 + } + } + } + } + ] + }, + { + "name": "burst", + "identifiers": [ + { + "type": "Identifier", + "name": "burst", + "range": [ + 74, + 79 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 10 + } + } + } + ], + "defs": [ + { + "type": "Variable", + "name": { + "type": "Identifier", + "name": "burst", + "range": [ + 74, + 79 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 10 + } + } + }, + "node": { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "burst", + "range": [ + 74, + 79 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 10 + } + } + }, + "init": { + "type": "CallExpression", + "arguments": [ + { + "type": "Literal", + "raw": "false", + "value": false, + "range": [ + 89, + 94 + ], + "loc": { + "start": { + "line": 5, + "column": 20 + }, + "end": { + "line": 5, + "column": 25 + } + } + } + ], + "callee": { + "type": "Identifier", + "name": "$state", + "range": [ + 82, + 88 + ], + "loc": { + "start": { + "line": 5, + "column": 13 + }, + "end": { + "line": 5, + "column": 19 + } + } + }, + "optional": false, + "range": [ + 82, + 95 + ], + "loc": { + "start": { + "line": 5, + "column": 13 + }, + "end": { + "line": 5, + "column": 26 + } + } + }, + "range": [ + 74, + 95 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 26 + } + } + } + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "burst", + "range": [ + 74, + 79 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 10 + } + } + }, + "from": "module", + "init": true, + "resolved": { + "type": "Identifier", + "name": "burst", + "range": [ + 74, + 79 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 10 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "burst", + "range": [ + 133, + 138 + ], + "loc": { + "start": { + "line": 9, + "column": 2 + }, + "end": { + "line": 9, + "column": 7 + } + } + }, + "from": "function", + "init": false, + "resolved": { + "type": "Identifier", + "name": "burst", + "range": [ + 74, + 79 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 10 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "burst", + "range": [ + 216, + 221 + ], + "loc": { + "start": { + "line": 16, + "column": 17 + }, + "end": { + "line": 16, + "column": 22 + } + } + }, + "from": "function", + "init": false, + "resolved": { + "type": "Identifier", + "name": "burst", + "range": [ + 74, + 79 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 10 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "burst", + "range": [ + 292, + 297 + ], + "loc": { + "start": { + "line": 23, + "column": 5 + }, + "end": { + "line": 23, + "column": 10 + } + } + }, + "from": "module", + "init": null, + "resolved": { + "type": "Identifier", + "name": "burst", + "range": [ + 74, + 79 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 10 + } + } + } + } + ] + }, + { + "name": "reset", + "identifiers": [ + { + "type": "Identifier", + "name": "reset", + "range": [ + 108, + 113 + ], + "loc": { + "start": { + "line": 7, + "column": 10 + }, + "end": { + "line": 7, + "column": 15 + } + } + } + ], + "defs": [ + { + "type": "FunctionName", + "name": { + "type": "Identifier", + "name": "reset", + "range": [ + 108, + 113 + ], + "loc": { + "start": { + "line": 7, + "column": 10 + }, + "end": { + "line": 7, + "column": 15 + } + } + }, + "node": { + "type": "FunctionDeclaration", + "async": false, + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "left": { + "type": "Identifier", + "name": "size", + "range": [ + 120, + 124 + ], + "loc": { + "start": { + "line": 8, + "column": 2 + }, + "end": { + "line": 8, + "column": 6 + } + } + }, + "operator": "=", + "right": { + "type": "Literal", + "raw": "15", + "value": 15, + "range": [ + 127, + 129 + ], + "loc": { + "start": { + "line": 8, + "column": 9 + }, + "end": { + "line": 8, + "column": 11 + } + } + }, + "range": [ + 120, + 129 + ], + "loc": { + "start": { + "line": 8, + "column": 2 + }, + "end": { + "line": 8, + "column": 11 + } + } + }, + "range": [ + 120, + 130 + ], + "loc": { + "start": { + "line": 8, + "column": 2 + }, + "end": { + "line": 8, + "column": 12 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "left": { + "type": "Identifier", + "name": "burst", + "range": [ + 133, + 138 + ], + "loc": { + "start": { + "line": 9, + "column": 2 + }, + "end": { + "line": 9, + "column": 7 + } + } + }, + "operator": "=", + "right": { + "type": "Literal", + "raw": "false", + "value": false, + "range": [ + 141, + 146 + ], + "loc": { + "start": { + "line": 9, + "column": 10 + }, + "end": { + "line": 9, + "column": 15 + } + } + }, + "range": [ + 133, + 146 + ], + "loc": { + "start": { + "line": 9, + "column": 2 + }, + "end": { + "line": 9, + "column": 15 + } + } + }, + "range": [ + 133, + 147 + ], + "loc": { + "start": { + "line": 9, + "column": 2 + }, + "end": { + "line": 9, + "column": 16 + } + } + } + ], + "range": [ + 116, + 150 + ], + "loc": { + "start": { + "line": 7, + "column": 18 + }, + "end": { + "line": 10, + "column": 2 + } + } + }, + "expression": false, + "generator": false, + "id": { + "type": "Identifier", + "name": "reset", + "range": [ + 108, + 113 + ], + "loc": { + "start": { + "line": 7, + "column": 10 + }, + "end": { + "line": 7, + "column": 15 + } + } + }, + "params": [], + "range": [ + 99, + 150 + ], + "loc": { + "start": { + "line": 7, + "column": 1 + }, + "end": { + "line": 10, + "column": 2 + } + } + } + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "reset", + "range": [ + 317, + 322 + ], + "loc": { + "start": { + "line": 24, + "column": 18 + }, + "end": { + "line": 24, + "column": 23 + } + } + }, + "from": "block", + "init": null, + "resolved": { + "type": "Identifier", + "name": "reset", + "range": [ + 108, + 113 + ], + "loc": { + "start": { + "line": 7, + "column": 10 + }, + "end": { + "line": 7, + "column": 15 + } + } + } + } + ] + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "size", + "range": [ + 50, + 54 + ], + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 9 + } + } + }, + "from": "module", + "init": true, + "resolved": { + "type": "Identifier", + "name": "size", + "range": [ + 50, + 54 + ], + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 9 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "$state", + "range": [ + 57, + 63 + ], + "loc": { + "start": { + "line": 4, + "column": 12 + }, + "end": { + "line": 4, + "column": 18 + } + } + }, + "from": "module", + "init": null, + "resolved": null + }, + { + "identifier": { + "type": "Identifier", + "name": "burst", + "range": [ + 74, + 79 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 10 + } + } + }, + "from": "module", + "init": true, + "resolved": { + "type": "Identifier", + "name": "burst", + "range": [ + 74, + 79 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 10 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "$state", + "range": [ + 82, + 88 + ], + "loc": { + "start": { + "line": 5, + "column": 13 + }, + "end": { + "line": 5, + "column": 19 + } + } + }, + "from": "module", + "init": null, + "resolved": null + }, + { + "identifier": { + "type": "Identifier", + "name": "Pump", + "range": [ + 163, + 167 + ], + "loc": { + "start": { + "line": 13, + "column": 1 + }, + "end": { + "line": 13, + "column": 5 + } + } + }, + "from": "module", + "init": null, + "resolved": { + "type": "Identifier", + "name": "Pump", + "range": [ + 17, + 21 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 12 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "burst", + "range": [ + 292, + 297 + ], + "loc": { + "start": { + "line": 23, + "column": 5 + }, + "end": { + "line": 23, + "column": 10 + } + } + }, + "from": "module", + "init": null, + "resolved": { + "type": "Identifier", + "name": "burst", + "range": [ + 74, + 79 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 10 + } + } + } + } + ], + "childScopes": [ + { + "type": "function", + "variables": [ + { + "name": "arguments", + "identifiers": [], + "defs": [], + "references": [] + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "size", + "range": [ + 120, + 124 + ], + "loc": { + "start": { + "line": 8, + "column": 2 + }, + "end": { + "line": 8, + "column": 6 + } + } + }, + "from": "function", + "init": false, + "resolved": { + "type": "Identifier", + "name": "size", + "range": [ + 50, + 54 + ], + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 9 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "burst", + "range": [ + 133, + 138 + ], + "loc": { + "start": { + "line": 9, + "column": 2 + }, + "end": { + "line": 9, + "column": 7 + } + } + }, + "from": "function", + "init": false, + "resolved": { + "type": "Identifier", + "name": "burst", + "range": [ + 74, + 79 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 10 + } + } + } + } + ], + "childScopes": [], + "through": [ + { + "identifier": { + "type": "Identifier", + "name": "size", + "range": [ + 120, + 124 + ], + "loc": { + "start": { + "line": 8, + "column": 2 + }, + "end": { + "line": 8, + "column": 6 + } + } + }, + "from": "function", + "init": false, + "resolved": { + "type": "Identifier", + "name": "size", + "range": [ + 50, + 54 + ], + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 9 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "burst", + "range": [ + 133, + 138 + ], + "loc": { + "start": { + "line": 9, + "column": 2 + }, + "end": { + "line": 9, + "column": 7 + } + } + }, + "from": "function", + "init": false, + "resolved": { + "type": "Identifier", + "name": "burst", + "range": [ + 74, + 79 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 10 + } + } + } + } + ] + }, + { + "type": "function", + "variables": [], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "size", + "range": [ + 188, + 192 + ], + "loc": { + "start": { + "line": 15, + "column": 2 + }, + "end": { + "line": 15, + "column": 6 + } + } + }, + "from": "function", + "init": false, + "resolved": { + "type": "Identifier", + "name": "size", + "range": [ + 50, + 54 + ], + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 9 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "size", + "range": [ + 205, + 209 + ], + "loc": { + "start": { + "line": 16, + "column": 6 + }, + "end": { + "line": 16, + "column": 10 + } + } + }, + "from": "function", + "init": null, + "resolved": { + "type": "Identifier", + "name": "size", + "range": [ + 50, + 54 + ], + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 9 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "burst", + "range": [ + 216, + 221 + ], + "loc": { + "start": { + "line": 16, + "column": 17 + }, + "end": { + "line": 16, + "column": 22 + } + } + }, + "from": "function", + "init": false, + "resolved": { + "type": "Identifier", + "name": "burst", + "range": [ + 74, + 79 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 10 + } + } + } + } + ], + "childScopes": [], + "through": [ + { + "identifier": { + "type": "Identifier", + "name": "size", + "range": [ + 188, + 192 + ], + "loc": { + "start": { + "line": 15, + "column": 2 + }, + "end": { + "line": 15, + "column": 6 + } + } + }, + "from": "function", + "init": false, + "resolved": { + "type": "Identifier", + "name": "size", + "range": [ + 50, + 54 + ], + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 9 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "size", + "range": [ + 205, + 209 + ], + "loc": { + "start": { + "line": 16, + "column": 6 + }, + "end": { + "line": 16, + "column": 10 + } + } + }, + "from": "function", + "init": null, + "resolved": { + "type": "Identifier", + "name": "size", + "range": [ + 50, + 54 + ], + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 9 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "burst", + "range": [ + 216, + 221 + ], + "loc": { + "start": { + "line": 16, + "column": 17 + }, + "end": { + "line": 16, + "column": 22 + } + } + }, + "from": "function", + "init": false, + "resolved": { + "type": "Identifier", + "name": "burst", + "range": [ + 74, + 79 + ], + "loc": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 10 + } + } + } + } + ] + }, + { + "type": "function", + "variables": [], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "size", + "range": [ + 258, + 262 + ], + "loc": { + "start": { + "line": 19, + "column": 6 + }, + "end": { + "line": 19, + "column": 10 + } + } + }, + "from": "function", + "init": null, + "resolved": { + "type": "Identifier", + "name": "size", + "range": [ + 50, + 54 + ], + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 9 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "size", + "range": [ + 268, + 272 + ], + "loc": { + "start": { + "line": 19, + "column": 16 + }, + "end": { + "line": 19, + "column": 20 + } + } + }, + "from": "function", + "init": false, + "resolved": { + "type": "Identifier", + "name": "size", + "range": [ + 50, + 54 + ], + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 9 + } + } + } + } + ], + "childScopes": [], + "through": [ + { + "identifier": { + "type": "Identifier", + "name": "size", + "range": [ + 258, + 262 + ], + "loc": { + "start": { + "line": 19, + "column": 6 + }, + "end": { + "line": 19, + "column": 10 + } + } + }, + "from": "function", + "init": null, + "resolved": { + "type": "Identifier", + "name": "size", + "range": [ + 50, + 54 + ], + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 9 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "size", + "range": [ + 268, + 272 + ], + "loc": { + "start": { + "line": 19, + "column": 16 + }, + "end": { + "line": 19, + "column": 20 + } + } + }, + "from": "function", + "init": false, + "resolved": { + "type": "Identifier", + "name": "size", + "range": [ + 50, + 54 + ], + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 9 + } + } + } + } + ] + }, + { + "type": "block", + "variables": [], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "reset", + "range": [ + 317, + 322 + ], + "loc": { + "start": { + "line": 24, + "column": 18 + }, + "end": { + "line": 24, + "column": 23 + } + } + }, + "from": "block", + "init": null, + "resolved": { + "type": "Identifier", + "name": "reset", + "range": [ + 108, + 113 + ], + "loc": { + "start": { + "line": 7, + "column": 10 + }, + "end": { + "line": 7, + "column": 15 + } + } + } + } + ], + "childScopes": [], + "through": [ + { + "identifier": { + "type": "Identifier", + "name": "reset", + "range": [ + 317, + 322 + ], + "loc": { + "start": { + "line": 24, + "column": 18 + }, + "end": { + "line": 24, + "column": 23 + } + } + }, + "from": "block", + "init": null, + "resolved": { + "type": "Identifier", + "name": "reset", + "range": [ + 108, + 113 + ], + "loc": { + "start": { + "line": 7, + "column": 10 + }, + "end": { + "line": 7, + "column": 15 + } + } + } + } + ] + }, + { + "type": "block", + "variables": [], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "size", + "range": [ + 428, + 432 + ], + "loc": { + "start": { + "line": 27, + "column": 45 + }, + "end": { + "line": 27, + "column": 49 + } + } + }, + "from": "block", + "init": null, + "resolved": { + "type": "Identifier", + "name": "size", + "range": [ + 50, + 54 + ], + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 9 + } + } + } + } + ], + "childScopes": [], + "through": [ + { + "identifier": { + "type": "Identifier", + "name": "size", + "range": [ + 428, + 432 + ], + "loc": { + "start": { + "line": 27, + "column": 45 + }, + "end": { + "line": 27, + "column": 49 + } + } + }, + "from": "block", + "init": null, + "resolved": { + "type": "Identifier", + "name": "size", + "range": [ + 50, + 54 + ], + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 9 + } + } + } + } + ] + } + ], + "through": [ + { + "identifier": { + "type": "Identifier", + "name": "$state", + "range": [ + 57, + 63 + ], + "loc": { + "start": { + "line": 4, + "column": 12 + }, + "end": { + "line": 4, + "column": 18 + } + } + }, + "from": "module", + "init": null, + "resolved": null + }, + { + "identifier": { + "type": "Identifier", + "name": "$state", + "range": [ + 82, + 88 + ], + "loc": { + "start": { + "line": 5, + "column": 13 + }, + "end": { + "line": 5, + "column": 19 + } + } + }, + "from": "module", + "init": null, + "resolved": null + } + ] + } + ], + "through": [] +} \ No newline at end of file diff --git a/tests/fixtures/parser/ast/svelte5/docs/event-handlers/04-component-events-input.svelte b/tests/fixtures/parser/ast/svelte5/docs/event-handlers/04-component-events-input.svelte new file mode 100644 index 00000000..9c0d635b --- /dev/null +++ b/tests/fixtures/parser/ast/svelte5/docs/event-handlers/04-component-events-input.svelte @@ -0,0 +1,6 @@ + + + + diff --git a/tests/fixtures/parser/ast/svelte5/docs/event-handlers/04-component-events-output.json b/tests/fixtures/parser/ast/svelte5/docs/event-handlers/04-component-events-output.json new file mode 100644 index 00000000..3ecf7af3 --- /dev/null +++ b/tests/fixtures/parser/ast/svelte5/docs/event-handlers/04-component-events-output.json @@ -0,0 +1,1501 @@ +{ + "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": "VariableDeclaration", + "kind": "let", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "ObjectPattern", + "properties": [ + { + "type": "Property", + "kind": "init", + "computed": false, + "key": { + "type": "Identifier", + "name": "inflate", + "range": [ + 16, + 23 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 14 + } + } + }, + "method": false, + "shorthand": true, + "value": { + "type": "Identifier", + "name": "inflate", + "range": [ + 16, + 23 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 14 + } + } + }, + "range": [ + 16, + 23 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 14 + } + } + }, + { + "type": "Property", + "kind": "init", + "computed": false, + "key": { + "type": "Identifier", + "name": "deflate", + "range": [ + 25, + 32 + ], + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 23 + } + } + }, + "method": false, + "shorthand": true, + "value": { + "type": "Identifier", + "name": "deflate", + "range": [ + 25, + 32 + ], + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 23 + } + } + }, + "range": [ + 25, + 32 + ], + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 23 + } + } + } + ], + "range": [ + 14, + 34 + ], + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 25 + } + } + }, + "init": { + "type": "CallExpression", + "arguments": [], + "callee": { + "type": "Identifier", + "name": "$props", + "range": [ + 37, + 43 + ], + "loc": { + "start": { + "line": 2, + "column": 28 + }, + "end": { + "line": 2, + "column": 34 + } + } + }, + "optional": false, + "range": [ + 37, + 45 + ], + "loc": { + "start": { + "line": 2, + "column": 28 + }, + "end": { + "line": 2, + "column": 36 + } + } + }, + "range": [ + 14, + 45 + ], + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 36 + } + } + } + ], + "range": [ + 10, + 46 + ], + "loc": { + "start": { + "line": 2, + "column": 1 + }, + "end": { + "line": 2, + "column": 37 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", + "range": [ + 47, + 56 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 9 + } + } + }, + "range": [ + 0, + 56 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 9 + } + } + }, + { + "type": "SvelteText", + "value": "\n\n", + "range": [ + 56, + 58 + ], + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 5, + "column": 0 + } + } + }, + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "button", + "range": [ + 59, + 65 + ], + "loc": { + "start": { + "line": 5, + "column": 1 + }, + "end": { + "line": 5, + "column": 7 + } + } + }, + "startTag": { + "type": "SvelteStartTag", + "attributes": [ + { + "type": "SvelteAttribute", + "key": { + "type": "SvelteName", + "name": "onclick", + "range": [ + 66, + 73 + ], + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 5, + "column": 15 + } + } + }, + "boolean": false, + "value": [ + { + "type": "SvelteMustacheTag", + "kind": "text", + "expression": { + "type": "Identifier", + "name": "inflate", + "range": [ + 75, + 82 + ], + "loc": { + "start": { + "line": 5, + "column": 17 + }, + "end": { + "line": 5, + "column": 24 + } + } + }, + "range": [ + 74, + 83 + ], + "loc": { + "start": { + "line": 5, + "column": 16 + }, + "end": { + "line": 5, + "column": 25 + } + } + } + ], + "range": [ + 66, + 83 + ], + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 5, + "column": 25 + } + } + } + ], + "selfClosing": false, + "range": [ + 58, + 84 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 26 + } + } + }, + "children": [ + { + "type": "SvelteText", + "value": "inflate", + "range": [ + 84, + 91 + ], + "loc": { + "start": { + "line": 5, + "column": 26 + }, + "end": { + "line": 5, + "column": 33 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", + "range": [ + 91, + 100 + ], + "loc": { + "start": { + "line": 5, + "column": 33 + }, + "end": { + "line": 5, + "column": 42 + } + } + }, + "range": [ + 58, + 100 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 42 + } + } + }, + { + "type": "SvelteText", + "value": "\n", + "range": [ + 100, + 101 + ], + "loc": { + "start": { + "line": 5, + "column": 42 + }, + "end": { + "line": 6, + "column": 0 + } + } + }, + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "button", + "range": [ + 102, + 108 + ], + "loc": { + "start": { + "line": 6, + "column": 1 + }, + "end": { + "line": 6, + "column": 7 + } + } + }, + "startTag": { + "type": "SvelteStartTag", + "attributes": [ + { + "type": "SvelteAttribute", + "key": { + "type": "SvelteName", + "name": "onclick", + "range": [ + 109, + 116 + ], + "loc": { + "start": { + "line": 6, + "column": 8 + }, + "end": { + "line": 6, + "column": 15 + } + } + }, + "boolean": false, + "value": [ + { + "type": "SvelteMustacheTag", + "kind": "text", + "expression": { + "type": "Identifier", + "name": "deflate", + "range": [ + 118, + 125 + ], + "loc": { + "start": { + "line": 6, + "column": 17 + }, + "end": { + "line": 6, + "column": 24 + } + } + }, + "range": [ + 117, + 126 + ], + "loc": { + "start": { + "line": 6, + "column": 16 + }, + "end": { + "line": 6, + "column": 25 + } + } + } + ], + "range": [ + 109, + 126 + ], + "loc": { + "start": { + "line": 6, + "column": 8 + }, + "end": { + "line": 6, + "column": 25 + } + } + } + ], + "selfClosing": false, + "range": [ + 101, + 127 + ], + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 26 + } + } + }, + "children": [ + { + "type": "SvelteText", + "value": "deflate", + "range": [ + 127, + 134 + ], + "loc": { + "start": { + "line": 6, + "column": 26 + }, + "end": { + "line": 6, + "column": 33 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", + "range": [ + 134, + 143 + ], + "loc": { + "start": { + "line": 6, + "column": 33 + }, + "end": { + "line": 6, + "column": 42 + } + } + }, + "range": [ + 101, + 143 + ], + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 42 + } + } + } + ], + "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": "let", + "range": [ + 10, + 13 + ], + "loc": { + "start": { + "line": 2, + "column": 1 + }, + "end": { + "line": 2, + "column": 4 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 14, + 15 + ], + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 6 + } + } + }, + { + "type": "Identifier", + "value": "inflate", + "range": [ + 16, + 23 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 14 + } + } + }, + { + "type": "Punctuator", + "value": ",", + "range": [ + 23, + 24 + ], + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 15 + } + } + }, + { + "type": "Identifier", + "value": "deflate", + "range": [ + 25, + 32 + ], + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 23 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 33, + 34 + ], + "loc": { + "start": { + "line": 2, + "column": 24 + }, + "end": { + "line": 2, + "column": 25 + } + } + }, + { + "type": "Punctuator", + "value": "=", + "range": [ + 35, + 36 + ], + "loc": { + "start": { + "line": 2, + "column": 26 + }, + "end": { + "line": 2, + "column": 27 + } + } + }, + { + "type": "Identifier", + "value": "$props", + "range": [ + 37, + 43 + ], + "loc": { + "start": { + "line": 2, + "column": 28 + }, + "end": { + "line": 2, + "column": 34 + } + } + }, + { + "type": "Punctuator", + "value": "(", + "range": [ + 43, + 44 + ], + "loc": { + "start": { + "line": 2, + "column": 34 + }, + "end": { + "line": 2, + "column": 35 + } + } + }, + { + "type": "Punctuator", + "value": ")", + "range": [ + 44, + 45 + ], + "loc": { + "start": { + "line": 2, + "column": 35 + }, + "end": { + "line": 2, + "column": 36 + } + } + }, + { + "type": "Punctuator", + "value": ";", + "range": [ + 45, + 46 + ], + "loc": { + "start": { + "line": 2, + "column": 36 + }, + "end": { + "line": 2, + "column": 37 + } + } + }, + { + "type": "Punctuator", + "value": "<", + "range": [ + 47, + 48 + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + } + }, + { + "type": "Punctuator", + "value": "/", + "range": [ + 48, + 49 + ], + "loc": { + "start": { + "line": 3, + "column": 1 + }, + "end": { + "line": 3, + "column": 2 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "script", + "range": [ + 49, + 55 + ], + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 8 + } + } + }, + { + "type": "Punctuator", + "value": ">", + "range": [ + 55, + 56 + ], + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 9 + } + } + }, + { + "type": "HTMLText", + "value": "\n\n", + "range": [ + 56, + 58 + ], + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 5, + "column": 0 + } + } + }, + { + "type": "Punctuator", + "value": "<", + "range": [ + 58, + 59 + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "button", + "range": [ + 59, + 65 + ], + "loc": { + "start": { + "line": 5, + "column": 1 + }, + "end": { + "line": 5, + "column": 7 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "onclick", + "range": [ + 66, + 73 + ], + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 5, + "column": 15 + } + } + }, + { + "type": "Punctuator", + "value": "=", + "range": [ + 73, + 74 + ], + "loc": { + "start": { + "line": 5, + "column": 15 + }, + "end": { + "line": 5, + "column": 16 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 74, + 75 + ], + "loc": { + "start": { + "line": 5, + "column": 16 + }, + "end": { + "line": 5, + "column": 17 + } + } + }, + { + "type": "Identifier", + "value": "inflate", + "range": [ + 75, + 82 + ], + "loc": { + "start": { + "line": 5, + "column": 17 + }, + "end": { + "line": 5, + "column": 24 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 82, + 83 + ], + "loc": { + "start": { + "line": 5, + "column": 24 + }, + "end": { + "line": 5, + "column": 25 + } + } + }, + { + "type": "Punctuator", + "value": ">", + "range": [ + 83, + 84 + ], + "loc": { + "start": { + "line": 5, + "column": 25 + }, + "end": { + "line": 5, + "column": 26 + } + } + }, + { + "type": "HTMLText", + "value": "inflate", + "range": [ + 84, + 91 + ], + "loc": { + "start": { + "line": 5, + "column": 26 + }, + "end": { + "line": 5, + "column": 33 + } + } + }, + { + "type": "Punctuator", + "value": "<", + "range": [ + 91, + 92 + ], + "loc": { + "start": { + "line": 5, + "column": 33 + }, + "end": { + "line": 5, + "column": 34 + } + } + }, + { + "type": "Punctuator", + "value": "/", + "range": [ + 92, + 93 + ], + "loc": { + "start": { + "line": 5, + "column": 34 + }, + "end": { + "line": 5, + "column": 35 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "button", + "range": [ + 93, + 99 + ], + "loc": { + "start": { + "line": 5, + "column": 35 + }, + "end": { + "line": 5, + "column": 41 + } + } + }, + { + "type": "Punctuator", + "value": ">", + "range": [ + 99, + 100 + ], + "loc": { + "start": { + "line": 5, + "column": 41 + }, + "end": { + "line": 5, + "column": 42 + } + } + }, + { + "type": "HTMLText", + "value": "\n", + "range": [ + 100, + 101 + ], + "loc": { + "start": { + "line": 5, + "column": 42 + }, + "end": { + "line": 6, + "column": 0 + } + } + }, + { + "type": "Punctuator", + "value": "<", + "range": [ + 101, + 102 + ], + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 1 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "button", + "range": [ + 102, + 108 + ], + "loc": { + "start": { + "line": 6, + "column": 1 + }, + "end": { + "line": 6, + "column": 7 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "onclick", + "range": [ + 109, + 116 + ], + "loc": { + "start": { + "line": 6, + "column": 8 + }, + "end": { + "line": 6, + "column": 15 + } + } + }, + { + "type": "Punctuator", + "value": "=", + "range": [ + 116, + 117 + ], + "loc": { + "start": { + "line": 6, + "column": 15 + }, + "end": { + "line": 6, + "column": 16 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 117, + 118 + ], + "loc": { + "start": { + "line": 6, + "column": 16 + }, + "end": { + "line": 6, + "column": 17 + } + } + }, + { + "type": "Identifier", + "value": "deflate", + "range": [ + 118, + 125 + ], + "loc": { + "start": { + "line": 6, + "column": 17 + }, + "end": { + "line": 6, + "column": 24 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 125, + 126 + ], + "loc": { + "start": { + "line": 6, + "column": 24 + }, + "end": { + "line": 6, + "column": 25 + } + } + }, + { + "type": "Punctuator", + "value": ">", + "range": [ + 126, + 127 + ], + "loc": { + "start": { + "line": 6, + "column": 25 + }, + "end": { + "line": 6, + "column": 26 + } + } + }, + { + "type": "HTMLText", + "value": "deflate", + "range": [ + 127, + 134 + ], + "loc": { + "start": { + "line": 6, + "column": 26 + }, + "end": { + "line": 6, + "column": 33 + } + } + }, + { + "type": "Punctuator", + "value": "<", + "range": [ + 134, + 135 + ], + "loc": { + "start": { + "line": 6, + "column": 33 + }, + "end": { + "line": 6, + "column": 34 + } + } + }, + { + "type": "Punctuator", + "value": "/", + "range": [ + 135, + 136 + ], + "loc": { + "start": { + "line": 6, + "column": 34 + }, + "end": { + "line": 6, + "column": 35 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "button", + "range": [ + 136, + 142 + ], + "loc": { + "start": { + "line": 6, + "column": 35 + }, + "end": { + "line": 6, + "column": 41 + } + } + }, + { + "type": "Punctuator", + "value": ">", + "range": [ + 142, + 143 + ], + "loc": { + "start": { + "line": 6, + "column": 41 + }, + "end": { + "line": 6, + "column": 42 + } + } + } + ], + "range": [ + 0, + 144 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 7, + "column": 0 + } + } +} \ No newline at end of file diff --git a/tests/fixtures/parser/ast/svelte5/docs/event-handlers/04-component-events-prefer-const-result.json b/tests/fixtures/parser/ast/svelte5/docs/event-handlers/04-component-events-prefer-const-result.json new file mode 100644 index 00000000..8b389876 --- /dev/null +++ b/tests/fixtures/parser/ast/svelte5/docs/event-handlers/04-component-events-prefer-const-result.json @@ -0,0 +1,14 @@ +[ + { + "ruleId": "prefer-const", + "code": "inflate", + "line": 2, + "column": 8 + }, + { + "ruleId": "prefer-const", + "code": "deflate", + "line": 2, + "column": 17 + } +] \ No newline at end of file diff --git a/tests/fixtures/parser/ast/svelte5/docs/event-handlers/04-component-events-scope-output.json b/tests/fixtures/parser/ast/svelte5/docs/event-handlers/04-component-events-scope-output.json new file mode 100644 index 00000000..43b3d486 --- /dev/null +++ b/tests/fixtures/parser/ast/svelte5/docs/event-handlers/04-component-events-scope-output.json @@ -0,0 +1,921 @@ +{ + "type": "global", + "variables": [ + { + "name": "$$slots", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$$props", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$$restProps", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$state", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$derived", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$effect", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$props", + "identifiers": [], + "defs": [], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "$props", + "range": [ + 37, + 43 + ], + "loc": { + "start": { + "line": 2, + "column": 28 + }, + "end": { + "line": 2, + "column": 34 + } + } + }, + "from": "module", + "init": null, + "resolved": null + } + ] + } + ], + "references": [], + "childScopes": [ + { + "type": "module", + "variables": [ + { + "name": "inflate", + "identifiers": [ + { + "type": "Identifier", + "name": "inflate", + "range": [ + 16, + 23 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 14 + } + } + } + ], + "defs": [ + { + "type": "Variable", + "name": { + "type": "Identifier", + "name": "inflate", + "range": [ + 16, + 23 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 14 + } + } + }, + "node": { + "type": "VariableDeclarator", + "id": { + "type": "ObjectPattern", + "properties": [ + { + "type": "Property", + "kind": "init", + "computed": false, + "key": { + "type": "Identifier", + "name": "inflate", + "range": [ + 16, + 23 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 14 + } + } + }, + "method": false, + "shorthand": true, + "value": { + "type": "Identifier", + "name": "inflate", + "range": [ + 16, + 23 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 14 + } + } + }, + "range": [ + 16, + 23 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 14 + } + } + }, + { + "type": "Property", + "kind": "init", + "computed": false, + "key": { + "type": "Identifier", + "name": "deflate", + "range": [ + 25, + 32 + ], + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 23 + } + } + }, + "method": false, + "shorthand": true, + "value": { + "type": "Identifier", + "name": "deflate", + "range": [ + 25, + 32 + ], + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 23 + } + } + }, + "range": [ + 25, + 32 + ], + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 23 + } + } + } + ], + "range": [ + 14, + 34 + ], + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 25 + } + } + }, + "init": { + "type": "CallExpression", + "arguments": [], + "callee": { + "type": "Identifier", + "name": "$props", + "range": [ + 37, + 43 + ], + "loc": { + "start": { + "line": 2, + "column": 28 + }, + "end": { + "line": 2, + "column": 34 + } + } + }, + "optional": false, + "range": [ + 37, + 45 + ], + "loc": { + "start": { + "line": 2, + "column": 28 + }, + "end": { + "line": 2, + "column": 36 + } + } + }, + "range": [ + 14, + 45 + ], + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 36 + } + } + } + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "inflate", + "range": [ + 16, + 23 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 14 + } + } + }, + "from": "module", + "init": true, + "resolved": { + "type": "Identifier", + "name": "inflate", + "range": [ + 16, + 23 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 14 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "inflate", + "range": [ + 75, + 82 + ], + "loc": { + "start": { + "line": 5, + "column": 17 + }, + "end": { + "line": 5, + "column": 24 + } + } + }, + "from": "module", + "init": null, + "resolved": { + "type": "Identifier", + "name": "inflate", + "range": [ + 16, + 23 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 14 + } + } + } + } + ] + }, + { + "name": "deflate", + "identifiers": [ + { + "type": "Identifier", + "name": "deflate", + "range": [ + 25, + 32 + ], + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 23 + } + } + } + ], + "defs": [ + { + "type": "Variable", + "name": { + "type": "Identifier", + "name": "deflate", + "range": [ + 25, + 32 + ], + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 23 + } + } + }, + "node": { + "type": "VariableDeclarator", + "id": { + "type": "ObjectPattern", + "properties": [ + { + "type": "Property", + "kind": "init", + "computed": false, + "key": { + "type": "Identifier", + "name": "inflate", + "range": [ + 16, + 23 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 14 + } + } + }, + "method": false, + "shorthand": true, + "value": { + "type": "Identifier", + "name": "inflate", + "range": [ + 16, + 23 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 14 + } + } + }, + "range": [ + 16, + 23 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 14 + } + } + }, + { + "type": "Property", + "kind": "init", + "computed": false, + "key": { + "type": "Identifier", + "name": "deflate", + "range": [ + 25, + 32 + ], + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 23 + } + } + }, + "method": false, + "shorthand": true, + "value": { + "type": "Identifier", + "name": "deflate", + "range": [ + 25, + 32 + ], + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 23 + } + } + }, + "range": [ + 25, + 32 + ], + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 23 + } + } + } + ], + "range": [ + 14, + 34 + ], + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 25 + } + } + }, + "init": { + "type": "CallExpression", + "arguments": [], + "callee": { + "type": "Identifier", + "name": "$props", + "range": [ + 37, + 43 + ], + "loc": { + "start": { + "line": 2, + "column": 28 + }, + "end": { + "line": 2, + "column": 34 + } + } + }, + "optional": false, + "range": [ + 37, + 45 + ], + "loc": { + "start": { + "line": 2, + "column": 28 + }, + "end": { + "line": 2, + "column": 36 + } + } + }, + "range": [ + 14, + 45 + ], + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 36 + } + } + } + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "deflate", + "range": [ + 25, + 32 + ], + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 23 + } + } + }, + "from": "module", + "init": true, + "resolved": { + "type": "Identifier", + "name": "deflate", + "range": [ + 25, + 32 + ], + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 23 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "deflate", + "range": [ + 118, + 125 + ], + "loc": { + "start": { + "line": 6, + "column": 17 + }, + "end": { + "line": 6, + "column": 24 + } + } + }, + "from": "module", + "init": null, + "resolved": { + "type": "Identifier", + "name": "deflate", + "range": [ + 25, + 32 + ], + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 23 + } + } + } + } + ] + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "inflate", + "range": [ + 16, + 23 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 14 + } + } + }, + "from": "module", + "init": true, + "resolved": { + "type": "Identifier", + "name": "inflate", + "range": [ + 16, + 23 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 14 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "deflate", + "range": [ + 25, + 32 + ], + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 23 + } + } + }, + "from": "module", + "init": true, + "resolved": { + "type": "Identifier", + "name": "deflate", + "range": [ + 25, + 32 + ], + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 23 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "$props", + "range": [ + 37, + 43 + ], + "loc": { + "start": { + "line": 2, + "column": 28 + }, + "end": { + "line": 2, + "column": 34 + } + } + }, + "from": "module", + "init": null, + "resolved": null + }, + { + "identifier": { + "type": "Identifier", + "name": "inflate", + "range": [ + 75, + 82 + ], + "loc": { + "start": { + "line": 5, + "column": 17 + }, + "end": { + "line": 5, + "column": 24 + } + } + }, + "from": "module", + "init": null, + "resolved": { + "type": "Identifier", + "name": "inflate", + "range": [ + 16, + 23 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 14 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "deflate", + "range": [ + 118, + 125 + ], + "loc": { + "start": { + "line": 6, + "column": 17 + }, + "end": { + "line": 6, + "column": 24 + } + } + }, + "from": "module", + "init": null, + "resolved": { + "type": "Identifier", + "name": "deflate", + "range": [ + 25, + 32 + ], + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 23 + } + } + } + } + ], + "childScopes": [], + "through": [ + { + "identifier": { + "type": "Identifier", + "name": "$props", + "range": [ + 37, + 43 + ], + "loc": { + "start": { + "line": 2, + "column": 28 + }, + "end": { + "line": 2, + "column": 34 + } + } + }, + "from": "module", + "init": null, + "resolved": null + } + ] + } + ], + "through": [] +} \ No newline at end of file diff --git a/tests/fixtures/parser/ast/svelte5/docs/event-handlers/05-bubbling-events-input.svelte b/tests/fixtures/parser/ast/svelte5/docs/event-handlers/05-bubbling-events-input.svelte new file mode 100644 index 00000000..c8bab813 --- /dev/null +++ b/tests/fixtures/parser/ast/svelte5/docs/event-handlers/05-bubbling-events-input.svelte @@ -0,0 +1,7 @@ + + + diff --git a/tests/fixtures/parser/ast/svelte5/docs/event-handlers/06-bubbling-events-input.svelte b/tests/fixtures/parser/ast/svelte5/docs/event-handlers/06-bubbling-events-input.svelte new file mode 100644 index 00000000..856553ba --- /dev/null +++ b/tests/fixtures/parser/ast/svelte5/docs/event-handlers/06-bubbling-events-input.svelte @@ -0,0 +1,7 @@ + + + diff --git a/tests/fixtures/parser/ast/svelte5/docs/event-handlers/07-event-modifiers-input.svelte b/tests/fixtures/parser/ast/svelte5/docs/event-handlers/07-event-modifiers-input.svelte new file mode 100644 index 00000000..95158b19 --- /dev/null +++ b/tests/fixtures/parser/ast/svelte5/docs/event-handlers/07-event-modifiers-input.svelte @@ -0,0 +1,17 @@ + + + diff --git a/tests/fixtures/parser/ast/svelte5/docs/event-handlers/07-event-modifiers-no-undef-result.json b/tests/fixtures/parser/ast/svelte5/docs/event-handlers/07-event-modifiers-no-undef-result.json new file mode 100644 index 00000000..cdf33d1a --- /dev/null +++ b/tests/fixtures/parser/ast/svelte5/docs/event-handlers/07-event-modifiers-no-undef-result.json @@ -0,0 +1,8 @@ +[ + { + "ruleId": "no-undef", + "code": "handler", + "line": 17, + "column": 38 + } +] \ No newline at end of file diff --git a/tests/fixtures/parser/ast/svelte5/docs/event-handlers/07-event-modifiers-output.json b/tests/fixtures/parser/ast/svelte5/docs/event-handlers/07-event-modifiers-output.json new file mode 100644 index 00000000..e610f2bb --- /dev/null +++ b/tests/fixtures/parser/ast/svelte5/docs/event-handlers/07-event-modifiers-output.json @@ -0,0 +1,2720 @@ +{ + "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": "FunctionDeclaration", + "async": false, + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "ReturnStatement", + "argument": { + "type": "FunctionExpression", + "async": false, + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "alternate": null, + "consequent": { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "arguments": [ + { + "type": "ThisExpression", + "range": [ + 77, + 81 + ], + "loc": { + "start": { + "line": 4, + "column": 19 + }, + "end": { + "line": 4, + "column": 23 + } + } + }, + { + "type": "Identifier", + "name": "event", + "range": [ + 83, + 88 + ], + "loc": { + "start": { + "line": 4, + "column": 25 + }, + "end": { + "line": 4, + "column": 30 + } + } + } + ], + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "fn", + "range": [ + 69, + 71 + ], + "loc": { + "start": { + "line": 4, + "column": 11 + }, + "end": { + "line": 4, + "column": 13 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "name": "call", + "range": [ + 72, + 76 + ], + "loc": { + "start": { + "line": 4, + "column": 14 + }, + "end": { + "line": 4, + "column": 18 + } + } + }, + "range": [ + 69, + 76 + ], + "loc": { + "start": { + "line": 4, + "column": 11 + }, + "end": { + "line": 4, + "column": 18 + } + } + }, + "optional": false, + "range": [ + 69, + 89 + ], + "loc": { + "start": { + "line": 4, + "column": 11 + }, + "end": { + "line": 4, + "column": 31 + } + } + }, + "range": [ + 69, + 90 + ], + "loc": { + "start": { + "line": 4, + "column": 11 + }, + "end": { + "line": 4, + "column": 32 + } + } + }, + "test": { + "type": "Identifier", + "name": "fn", + "range": [ + 65, + 67 + ], + "loc": { + "start": { + "line": 4, + "column": 7 + }, + "end": { + "line": 4, + "column": 9 + } + } + }, + "range": [ + 61, + 90 + ], + "loc": { + "start": { + "line": 4, + "column": 3 + }, + "end": { + "line": 4, + "column": 32 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "left": { + "type": "Identifier", + "name": "fn", + "range": [ + 94, + 96 + ], + "loc": { + "start": { + "line": 5, + "column": 3 + }, + "end": { + "line": 5, + "column": 5 + } + } + }, + "operator": "=", + "right": { + "type": "Literal", + "raw": "null", + "value": null, + "range": [ + 99, + 103 + ], + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 5, + "column": 12 + } + } + }, + "range": [ + 94, + 103 + ], + "loc": { + "start": { + "line": 5, + "column": 3 + }, + "end": { + "line": 5, + "column": 12 + } + } + }, + "range": [ + 94, + 104 + ], + "loc": { + "start": { + "line": 5, + "column": 3 + }, + "end": { + "line": 5, + "column": 13 + } + } + } + ], + "range": [ + 56, + 108 + ], + "loc": { + "start": { + "line": 3, + "column": 26 + }, + "end": { + "line": 6, + "column": 3 + } + } + }, + "expression": false, + "generator": false, + "id": null, + "params": [ + { + "type": "Identifier", + "name": "event", + "range": [ + 49, + 54 + ], + "loc": { + "start": { + "line": 3, + "column": 19 + }, + "end": { + "line": 3, + "column": 24 + } + } + } + ], + "range": [ + 39, + 108 + ], + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 6, + "column": 3 + } + } + }, + "range": [ + 32, + 109 + ], + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 6, + "column": 4 + } + } + } + ], + "range": [ + 28, + 112 + ], + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 7, + "column": 2 + } + } + }, + "expression": false, + "generator": false, + "id": { + "type": "Identifier", + "name": "once", + "range": [ + 19, + 23 + ], + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 14 + } + } + }, + "params": [ + { + "type": "Identifier", + "name": "fn", + "range": [ + 24, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 17 + } + } + } + ], + "range": [ + 10, + 112 + ], + "loc": { + "start": { + "line": 2, + "column": 1 + }, + "end": { + "line": 7, + "column": 2 + } + } + }, + { + "type": "FunctionDeclaration", + "async": false, + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "ReturnStatement", + "argument": { + "type": "FunctionExpression", + "async": false, + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "arguments": [], + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "event", + "range": [ + 176, + 181 + ], + "loc": { + "start": { + "line": 11, + "column": 3 + }, + "end": { + "line": 11, + "column": 8 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "name": "preventDefault", + "range": [ + 182, + 196 + ], + "loc": { + "start": { + "line": 11, + "column": 9 + }, + "end": { + "line": 11, + "column": 23 + } + } + }, + "range": [ + 176, + 196 + ], + "loc": { + "start": { + "line": 11, + "column": 3 + }, + "end": { + "line": 11, + "column": 23 + } + } + }, + "optional": false, + "range": [ + 176, + 198 + ], + "loc": { + "start": { + "line": 11, + "column": 3 + }, + "end": { + "line": 11, + "column": 25 + } + } + }, + "range": [ + 176, + 199 + ], + "loc": { + "start": { + "line": 11, + "column": 3 + }, + "end": { + "line": 11, + "column": 26 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "arguments": [ + { + "type": "ThisExpression", + "range": [ + 211, + 215 + ], + "loc": { + "start": { + "line": 12, + "column": 11 + }, + "end": { + "line": 12, + "column": 15 + } + } + }, + { + "type": "Identifier", + "name": "event", + "range": [ + 217, + 222 + ], + "loc": { + "start": { + "line": 12, + "column": 17 + }, + "end": { + "line": 12, + "column": 22 + } + } + } + ], + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "fn", + "range": [ + 203, + 205 + ], + "loc": { + "start": { + "line": 12, + "column": 3 + }, + "end": { + "line": 12, + "column": 5 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "name": "call", + "range": [ + 206, + 210 + ], + "loc": { + "start": { + "line": 12, + "column": 6 + }, + "end": { + "line": 12, + "column": 10 + } + } + }, + "range": [ + 203, + 210 + ], + "loc": { + "start": { + "line": 12, + "column": 3 + }, + "end": { + "line": 12, + "column": 10 + } + } + }, + "optional": false, + "range": [ + 203, + 223 + ], + "loc": { + "start": { + "line": 12, + "column": 3 + }, + "end": { + "line": 12, + "column": 23 + } + } + }, + "range": [ + 203, + 224 + ], + "loc": { + "start": { + "line": 12, + "column": 3 + }, + "end": { + "line": 12, + "column": 24 + } + } + } + ], + "range": [ + 171, + 228 + ], + "loc": { + "start": { + "line": 10, + "column": 26 + }, + "end": { + "line": 13, + "column": 3 + } + } + }, + "expression": false, + "generator": false, + "id": null, + "params": [ + { + "type": "Identifier", + "name": "event", + "range": [ + 164, + 169 + ], + "loc": { + "start": { + "line": 10, + "column": 19 + }, + "end": { + "line": 10, + "column": 24 + } + } + } + ], + "range": [ + 154, + 228 + ], + "loc": { + "start": { + "line": 10, + "column": 9 + }, + "end": { + "line": 13, + "column": 3 + } + } + }, + "range": [ + 147, + 229 + ], + "loc": { + "start": { + "line": 10, + "column": 2 + }, + "end": { + "line": 13, + "column": 4 + } + } + } + ], + "range": [ + 143, + 232 + ], + "loc": { + "start": { + "line": 9, + "column": 29 + }, + "end": { + "line": 14, + "column": 2 + } + } + }, + "expression": false, + "generator": false, + "id": { + "type": "Identifier", + "name": "preventDefault", + "range": [ + 124, + 138 + ], + "loc": { + "start": { + "line": 9, + "column": 10 + }, + "end": { + "line": 9, + "column": 24 + } + } + }, + "params": [ + { + "type": "Identifier", + "name": "fn", + "range": [ + 139, + 141 + ], + "loc": { + "start": { + "line": 9, + "column": 25 + }, + "end": { + "line": 9, + "column": 27 + } + } + } + ], + "range": [ + 115, + 232 + ], + "loc": { + "start": { + "line": 9, + "column": 1 + }, + "end": { + "line": 14, + "column": 2 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", + "range": [ + 233, + 242 + ], + "loc": { + "start": { + "line": 15, + "column": 0 + }, + "end": { + "line": 15, + "column": 9 + } + } + }, + "range": [ + 0, + 242 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 15, + "column": 9 + } + } + }, + { + "type": "SvelteText", + "value": "\n\n", + "range": [ + 242, + 244 + ], + "loc": { + "start": { + "line": 15, + "column": 9 + }, + "end": { + "line": 17, + "column": 0 + } + } + }, + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "button", + "range": [ + 245, + 251 + ], + "loc": { + "start": { + "line": 17, + "column": 1 + }, + "end": { + "line": 17, + "column": 7 + } + } + }, + "startTag": { + "type": "SvelteStartTag", + "attributes": [ + { + "type": "SvelteAttribute", + "key": { + "type": "SvelteName", + "name": "onclick", + "range": [ + 252, + 259 + ], + "loc": { + "start": { + "line": 17, + "column": 8 + }, + "end": { + "line": 17, + "column": 15 + } + } + }, + "boolean": false, + "value": [ + { + "type": "SvelteMustacheTag", + "kind": "text", + "expression": { + "type": "CallExpression", + "arguments": [ + { + "type": "CallExpression", + "arguments": [ + { + "type": "Identifier", + "name": "handler", + "range": [ + 281, + 288 + ], + "loc": { + "start": { + "line": 17, + "column": 37 + }, + "end": { + "line": 17, + "column": 44 + } + } + } + ], + "callee": { + "type": "Identifier", + "name": "preventDefault", + "range": [ + 266, + 280 + ], + "loc": { + "start": { + "line": 17, + "column": 22 + }, + "end": { + "line": 17, + "column": 36 + } + } + }, + "optional": false, + "range": [ + 266, + 289 + ], + "loc": { + "start": { + "line": 17, + "column": 22 + }, + "end": { + "line": 17, + "column": 45 + } + } + } + ], + "callee": { + "type": "Identifier", + "name": "once", + "range": [ + 261, + 265 + ], + "loc": { + "start": { + "line": 17, + "column": 17 + }, + "end": { + "line": 17, + "column": 21 + } + } + }, + "optional": false, + "range": [ + 261, + 290 + ], + "loc": { + "start": { + "line": 17, + "column": 17 + }, + "end": { + "line": 17, + "column": 46 + } + } + }, + "range": [ + 260, + 291 + ], + "loc": { + "start": { + "line": 17, + "column": 16 + }, + "end": { + "line": 17, + "column": 47 + } + } + } + ], + "range": [ + 252, + 291 + ], + "loc": { + "start": { + "line": 17, + "column": 8 + }, + "end": { + "line": 17, + "column": 47 + } + } + } + ], + "selfClosing": false, + "range": [ + 244, + 292 + ], + "loc": { + "start": { + "line": 17, + "column": 0 + }, + "end": { + "line": 17, + "column": 48 + } + } + }, + "children": [ + { + "type": "SvelteText", + "value": "...", + "range": [ + 292, + 295 + ], + "loc": { + "start": { + "line": 17, + "column": 48 + }, + "end": { + "line": 17, + "column": 51 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", + "range": [ + 295, + 304 + ], + "loc": { + "start": { + "line": 17, + "column": 51 + }, + "end": { + "line": 17, + "column": 60 + } + } + }, + "range": [ + 244, + 304 + ], + "loc": { + "start": { + "line": 17, + "column": 0 + }, + "end": { + "line": 17, + "column": 60 + } + } + } + ], + "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": "function", + "range": [ + 10, + 18 + ], + "loc": { + "start": { + "line": 2, + "column": 1 + }, + "end": { + "line": 2, + "column": 9 + } + } + }, + { + "type": "Identifier", + "value": "once", + "range": [ + 19, + 23 + ], + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 14 + } + } + }, + { + "type": "Punctuator", + "value": "(", + "range": [ + 23, + 24 + ], + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 15 + } + } + }, + { + "type": "Identifier", + "value": "fn", + "range": [ + 24, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 17 + } + } + }, + { + "type": "Punctuator", + "value": ")", + "range": [ + 26, + 27 + ], + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 18 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 28, + 29 + ], + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 2, + "column": 20 + } + } + }, + { + "type": "Keyword", + "value": "return", + "range": [ + 32, + 38 + ], + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 8 + } + } + }, + { + "type": "Keyword", + "value": "function", + "range": [ + 39, + 47 + ], + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 3, + "column": 17 + } + } + }, + { + "type": "Punctuator", + "value": "(", + "range": [ + 48, + 49 + ], + "loc": { + "start": { + "line": 3, + "column": 18 + }, + "end": { + "line": 3, + "column": 19 + } + } + }, + { + "type": "Identifier", + "value": "event", + "range": [ + 49, + 54 + ], + "loc": { + "start": { + "line": 3, + "column": 19 + }, + "end": { + "line": 3, + "column": 24 + } + } + }, + { + "type": "Punctuator", + "value": ")", + "range": [ + 54, + 55 + ], + "loc": { + "start": { + "line": 3, + "column": 24 + }, + "end": { + "line": 3, + "column": 25 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 56, + 57 + ], + "loc": { + "start": { + "line": 3, + "column": 26 + }, + "end": { + "line": 3, + "column": 27 + } + } + }, + { + "type": "Keyword", + "value": "if", + "range": [ + 61, + 63 + ], + "loc": { + "start": { + "line": 4, + "column": 3 + }, + "end": { + "line": 4, + "column": 5 + } + } + }, + { + "type": "Punctuator", + "value": "(", + "range": [ + 64, + 65 + ], + "loc": { + "start": { + "line": 4, + "column": 6 + }, + "end": { + "line": 4, + "column": 7 + } + } + }, + { + "type": "Identifier", + "value": "fn", + "range": [ + 65, + 67 + ], + "loc": { + "start": { + "line": 4, + "column": 7 + }, + "end": { + "line": 4, + "column": 9 + } + } + }, + { + "type": "Punctuator", + "value": ")", + "range": [ + 67, + 68 + ], + "loc": { + "start": { + "line": 4, + "column": 9 + }, + "end": { + "line": 4, + "column": 10 + } + } + }, + { + "type": "Identifier", + "value": "fn", + "range": [ + 69, + 71 + ], + "loc": { + "start": { + "line": 4, + "column": 11 + }, + "end": { + "line": 4, + "column": 13 + } + } + }, + { + "type": "Punctuator", + "value": ".", + "range": [ + 71, + 72 + ], + "loc": { + "start": { + "line": 4, + "column": 13 + }, + "end": { + "line": 4, + "column": 14 + } + } + }, + { + "type": "Identifier", + "value": "call", + "range": [ + 72, + 76 + ], + "loc": { + "start": { + "line": 4, + "column": 14 + }, + "end": { + "line": 4, + "column": 18 + } + } + }, + { + "type": "Punctuator", + "value": "(", + "range": [ + 76, + 77 + ], + "loc": { + "start": { + "line": 4, + "column": 18 + }, + "end": { + "line": 4, + "column": 19 + } + } + }, + { + "type": "Keyword", + "value": "this", + "range": [ + 77, + 81 + ], + "loc": { + "start": { + "line": 4, + "column": 19 + }, + "end": { + "line": 4, + "column": 23 + } + } + }, + { + "type": "Punctuator", + "value": ",", + "range": [ + 81, + 82 + ], + "loc": { + "start": { + "line": 4, + "column": 23 + }, + "end": { + "line": 4, + "column": 24 + } + } + }, + { + "type": "Identifier", + "value": "event", + "range": [ + 83, + 88 + ], + "loc": { + "start": { + "line": 4, + "column": 25 + }, + "end": { + "line": 4, + "column": 30 + } + } + }, + { + "type": "Punctuator", + "value": ")", + "range": [ + 88, + 89 + ], + "loc": { + "start": { + "line": 4, + "column": 30 + }, + "end": { + "line": 4, + "column": 31 + } + } + }, + { + "type": "Punctuator", + "value": ";", + "range": [ + 89, + 90 + ], + "loc": { + "start": { + "line": 4, + "column": 31 + }, + "end": { + "line": 4, + "column": 32 + } + } + }, + { + "type": "Identifier", + "value": "fn", + "range": [ + 94, + 96 + ], + "loc": { + "start": { + "line": 5, + "column": 3 + }, + "end": { + "line": 5, + "column": 5 + } + } + }, + { + "type": "Punctuator", + "value": "=", + "range": [ + 97, + 98 + ], + "loc": { + "start": { + "line": 5, + "column": 6 + }, + "end": { + "line": 5, + "column": 7 + } + } + }, + { + "type": "Null", + "value": "null", + "range": [ + 99, + 103 + ], + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 5, + "column": 12 + } + } + }, + { + "type": "Punctuator", + "value": ";", + "range": [ + 103, + 104 + ], + "loc": { + "start": { + "line": 5, + "column": 12 + }, + "end": { + "line": 5, + "column": 13 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 107, + 108 + ], + "loc": { + "start": { + "line": 6, + "column": 2 + }, + "end": { + "line": 6, + "column": 3 + } + } + }, + { + "type": "Punctuator", + "value": ";", + "range": [ + 108, + 109 + ], + "loc": { + "start": { + "line": 6, + "column": 3 + }, + "end": { + "line": 6, + "column": 4 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 111, + 112 + ], + "loc": { + "start": { + "line": 7, + "column": 1 + }, + "end": { + "line": 7, + "column": 2 + } + } + }, + { + "type": "Keyword", + "value": "function", + "range": [ + 115, + 123 + ], + "loc": { + "start": { + "line": 9, + "column": 1 + }, + "end": { + "line": 9, + "column": 9 + } + } + }, + { + "type": "Identifier", + "value": "preventDefault", + "range": [ + 124, + 138 + ], + "loc": { + "start": { + "line": 9, + "column": 10 + }, + "end": { + "line": 9, + "column": 24 + } + } + }, + { + "type": "Punctuator", + "value": "(", + "range": [ + 138, + 139 + ], + "loc": { + "start": { + "line": 9, + "column": 24 + }, + "end": { + "line": 9, + "column": 25 + } + } + }, + { + "type": "Identifier", + "value": "fn", + "range": [ + 139, + 141 + ], + "loc": { + "start": { + "line": 9, + "column": 25 + }, + "end": { + "line": 9, + "column": 27 + } + } + }, + { + "type": "Punctuator", + "value": ")", + "range": [ + 141, + 142 + ], + "loc": { + "start": { + "line": 9, + "column": 27 + }, + "end": { + "line": 9, + "column": 28 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 143, + 144 + ], + "loc": { + "start": { + "line": 9, + "column": 29 + }, + "end": { + "line": 9, + "column": 30 + } + } + }, + { + "type": "Keyword", + "value": "return", + "range": [ + 147, + 153 + ], + "loc": { + "start": { + "line": 10, + "column": 2 + }, + "end": { + "line": 10, + "column": 8 + } + } + }, + { + "type": "Keyword", + "value": "function", + "range": [ + 154, + 162 + ], + "loc": { + "start": { + "line": 10, + "column": 9 + }, + "end": { + "line": 10, + "column": 17 + } + } + }, + { + "type": "Punctuator", + "value": "(", + "range": [ + 163, + 164 + ], + "loc": { + "start": { + "line": 10, + "column": 18 + }, + "end": { + "line": 10, + "column": 19 + } + } + }, + { + "type": "Identifier", + "value": "event", + "range": [ + 164, + 169 + ], + "loc": { + "start": { + "line": 10, + "column": 19 + }, + "end": { + "line": 10, + "column": 24 + } + } + }, + { + "type": "Punctuator", + "value": ")", + "range": [ + 169, + 170 + ], + "loc": { + "start": { + "line": 10, + "column": 24 + }, + "end": { + "line": 10, + "column": 25 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 171, + 172 + ], + "loc": { + "start": { + "line": 10, + "column": 26 + }, + "end": { + "line": 10, + "column": 27 + } + } + }, + { + "type": "Identifier", + "value": "event", + "range": [ + 176, + 181 + ], + "loc": { + "start": { + "line": 11, + "column": 3 + }, + "end": { + "line": 11, + "column": 8 + } + } + }, + { + "type": "Punctuator", + "value": ".", + "range": [ + 181, + 182 + ], + "loc": { + "start": { + "line": 11, + "column": 8 + }, + "end": { + "line": 11, + "column": 9 + } + } + }, + { + "type": "Identifier", + "value": "preventDefault", + "range": [ + 182, + 196 + ], + "loc": { + "start": { + "line": 11, + "column": 9 + }, + "end": { + "line": 11, + "column": 23 + } + } + }, + { + "type": "Punctuator", + "value": "(", + "range": [ + 196, + 197 + ], + "loc": { + "start": { + "line": 11, + "column": 23 + }, + "end": { + "line": 11, + "column": 24 + } + } + }, + { + "type": "Punctuator", + "value": ")", + "range": [ + 197, + 198 + ], + "loc": { + "start": { + "line": 11, + "column": 24 + }, + "end": { + "line": 11, + "column": 25 + } + } + }, + { + "type": "Punctuator", + "value": ";", + "range": [ + 198, + 199 + ], + "loc": { + "start": { + "line": 11, + "column": 25 + }, + "end": { + "line": 11, + "column": 26 + } + } + }, + { + "type": "Identifier", + "value": "fn", + "range": [ + 203, + 205 + ], + "loc": { + "start": { + "line": 12, + "column": 3 + }, + "end": { + "line": 12, + "column": 5 + } + } + }, + { + "type": "Punctuator", + "value": ".", + "range": [ + 205, + 206 + ], + "loc": { + "start": { + "line": 12, + "column": 5 + }, + "end": { + "line": 12, + "column": 6 + } + } + }, + { + "type": "Identifier", + "value": "call", + "range": [ + 206, + 210 + ], + "loc": { + "start": { + "line": 12, + "column": 6 + }, + "end": { + "line": 12, + "column": 10 + } + } + }, + { + "type": "Punctuator", + "value": "(", + "range": [ + 210, + 211 + ], + "loc": { + "start": { + "line": 12, + "column": 10 + }, + "end": { + "line": 12, + "column": 11 + } + } + }, + { + "type": "Keyword", + "value": "this", + "range": [ + 211, + 215 + ], + "loc": { + "start": { + "line": 12, + "column": 11 + }, + "end": { + "line": 12, + "column": 15 + } + } + }, + { + "type": "Punctuator", + "value": ",", + "range": [ + 215, + 216 + ], + "loc": { + "start": { + "line": 12, + "column": 15 + }, + "end": { + "line": 12, + "column": 16 + } + } + }, + { + "type": "Identifier", + "value": "event", + "range": [ + 217, + 222 + ], + "loc": { + "start": { + "line": 12, + "column": 17 + }, + "end": { + "line": 12, + "column": 22 + } + } + }, + { + "type": "Punctuator", + "value": ")", + "range": [ + 222, + 223 + ], + "loc": { + "start": { + "line": 12, + "column": 22 + }, + "end": { + "line": 12, + "column": 23 + } + } + }, + { + "type": "Punctuator", + "value": ";", + "range": [ + 223, + 224 + ], + "loc": { + "start": { + "line": 12, + "column": 23 + }, + "end": { + "line": 12, + "column": 24 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 227, + 228 + ], + "loc": { + "start": { + "line": 13, + "column": 2 + }, + "end": { + "line": 13, + "column": 3 + } + } + }, + { + "type": "Punctuator", + "value": ";", + "range": [ + 228, + 229 + ], + "loc": { + "start": { + "line": 13, + "column": 3 + }, + "end": { + "line": 13, + "column": 4 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 231, + 232 + ], + "loc": { + "start": { + "line": 14, + "column": 1 + }, + "end": { + "line": 14, + "column": 2 + } + } + }, + { + "type": "Punctuator", + "value": "<", + "range": [ + 233, + 234 + ], + "loc": { + "start": { + "line": 15, + "column": 0 + }, + "end": { + "line": 15, + "column": 1 + } + } + }, + { + "type": "Punctuator", + "value": "/", + "range": [ + 234, + 235 + ], + "loc": { + "start": { + "line": 15, + "column": 1 + }, + "end": { + "line": 15, + "column": 2 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "script", + "range": [ + 235, + 241 + ], + "loc": { + "start": { + "line": 15, + "column": 2 + }, + "end": { + "line": 15, + "column": 8 + } + } + }, + { + "type": "Punctuator", + "value": ">", + "range": [ + 241, + 242 + ], + "loc": { + "start": { + "line": 15, + "column": 8 + }, + "end": { + "line": 15, + "column": 9 + } + } + }, + { + "type": "HTMLText", + "value": "\n\n", + "range": [ + 242, + 244 + ], + "loc": { + "start": { + "line": 15, + "column": 9 + }, + "end": { + "line": 17, + "column": 0 + } + } + }, + { + "type": "Punctuator", + "value": "<", + "range": [ + 244, + 245 + ], + "loc": { + "start": { + "line": 17, + "column": 0 + }, + "end": { + "line": 17, + "column": 1 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "button", + "range": [ + 245, + 251 + ], + "loc": { + "start": { + "line": 17, + "column": 1 + }, + "end": { + "line": 17, + "column": 7 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "onclick", + "range": [ + 252, + 259 + ], + "loc": { + "start": { + "line": 17, + "column": 8 + }, + "end": { + "line": 17, + "column": 15 + } + } + }, + { + "type": "Punctuator", + "value": "=", + "range": [ + 259, + 260 + ], + "loc": { + "start": { + "line": 17, + "column": 15 + }, + "end": { + "line": 17, + "column": 16 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 260, + 261 + ], + "loc": { + "start": { + "line": 17, + "column": 16 + }, + "end": { + "line": 17, + "column": 17 + } + } + }, + { + "type": "Identifier", + "value": "once", + "range": [ + 261, + 265 + ], + "loc": { + "start": { + "line": 17, + "column": 17 + }, + "end": { + "line": 17, + "column": 21 + } + } + }, + { + "type": "Punctuator", + "value": "(", + "range": [ + 265, + 266 + ], + "loc": { + "start": { + "line": 17, + "column": 21 + }, + "end": { + "line": 17, + "column": 22 + } + } + }, + { + "type": "Identifier", + "value": "preventDefault", + "range": [ + 266, + 280 + ], + "loc": { + "start": { + "line": 17, + "column": 22 + }, + "end": { + "line": 17, + "column": 36 + } + } + }, + { + "type": "Punctuator", + "value": "(", + "range": [ + 280, + 281 + ], + "loc": { + "start": { + "line": 17, + "column": 36 + }, + "end": { + "line": 17, + "column": 37 + } + } + }, + { + "type": "Identifier", + "value": "handler", + "range": [ + 281, + 288 + ], + "loc": { + "start": { + "line": 17, + "column": 37 + }, + "end": { + "line": 17, + "column": 44 + } + } + }, + { + "type": "Punctuator", + "value": ")", + "range": [ + 288, + 289 + ], + "loc": { + "start": { + "line": 17, + "column": 44 + }, + "end": { + "line": 17, + "column": 45 + } + } + }, + { + "type": "Punctuator", + "value": ")", + "range": [ + 289, + 290 + ], + "loc": { + "start": { + "line": 17, + "column": 45 + }, + "end": { + "line": 17, + "column": 46 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 290, + 291 + ], + "loc": { + "start": { + "line": 17, + "column": 46 + }, + "end": { + "line": 17, + "column": 47 + } + } + }, + { + "type": "Punctuator", + "value": ">", + "range": [ + 291, + 292 + ], + "loc": { + "start": { + "line": 17, + "column": 47 + }, + "end": { + "line": 17, + "column": 48 + } + } + }, + { + "type": "HTMLText", + "value": "...", + "range": [ + 292, + 295 + ], + "loc": { + "start": { + "line": 17, + "column": 48 + }, + "end": { + "line": 17, + "column": 51 + } + } + }, + { + "type": "Punctuator", + "value": "<", + "range": [ + 295, + 296 + ], + "loc": { + "start": { + "line": 17, + "column": 51 + }, + "end": { + "line": 17, + "column": 52 + } + } + }, + { + "type": "Punctuator", + "value": "/", + "range": [ + 296, + 297 + ], + "loc": { + "start": { + "line": 17, + "column": 52 + }, + "end": { + "line": 17, + "column": 53 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "button", + "range": [ + 297, + 303 + ], + "loc": { + "start": { + "line": 17, + "column": 53 + }, + "end": { + "line": 17, + "column": 59 + } + } + }, + { + "type": "Punctuator", + "value": ">", + "range": [ + 303, + 304 + ], + "loc": { + "start": { + "line": 17, + "column": 59 + }, + "end": { + "line": 17, + "column": 60 + } + } + } + ], + "range": [ + 0, + 305 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 18, + "column": 0 + } + } +} \ No newline at end of file diff --git a/tests/fixtures/parser/ast/svelte5/docs/event-handlers/07-event-modifiers-scope-output.json b/tests/fixtures/parser/ast/svelte5/docs/event-handlers/07-event-modifiers-scope-output.json new file mode 100644 index 00000000..55e1f438 --- /dev/null +++ b/tests/fixtures/parser/ast/svelte5/docs/event-handlers/07-event-modifiers-scope-output.json @@ -0,0 +1,3457 @@ +{ + "type": "global", + "variables": [ + { + "name": "$$slots", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$$props", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$$restProps", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$state", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$derived", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$effect", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$props", + "identifiers": [], + "defs": [], + "references": [] + } + ], + "references": [], + "childScopes": [ + { + "type": "module", + "variables": [ + { + "name": "once", + "identifiers": [ + { + "type": "Identifier", + "name": "once", + "range": [ + 19, + 23 + ], + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 14 + } + } + } + ], + "defs": [ + { + "type": "FunctionName", + "name": { + "type": "Identifier", + "name": "once", + "range": [ + 19, + 23 + ], + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 14 + } + } + }, + "node": { + "type": "FunctionDeclaration", + "async": false, + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "ReturnStatement", + "argument": { + "type": "FunctionExpression", + "async": false, + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "alternate": null, + "consequent": { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "arguments": [ + { + "type": "ThisExpression", + "range": [ + 77, + 81 + ], + "loc": { + "start": { + "line": 4, + "column": 19 + }, + "end": { + "line": 4, + "column": 23 + } + } + }, + { + "type": "Identifier", + "name": "event", + "range": [ + 83, + 88 + ], + "loc": { + "start": { + "line": 4, + "column": 25 + }, + "end": { + "line": 4, + "column": 30 + } + } + } + ], + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "fn", + "range": [ + 69, + 71 + ], + "loc": { + "start": { + "line": 4, + "column": 11 + }, + "end": { + "line": 4, + "column": 13 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "name": "call", + "range": [ + 72, + 76 + ], + "loc": { + "start": { + "line": 4, + "column": 14 + }, + "end": { + "line": 4, + "column": 18 + } + } + }, + "range": [ + 69, + 76 + ], + "loc": { + "start": { + "line": 4, + "column": 11 + }, + "end": { + "line": 4, + "column": 18 + } + } + }, + "optional": false, + "range": [ + 69, + 89 + ], + "loc": { + "start": { + "line": 4, + "column": 11 + }, + "end": { + "line": 4, + "column": 31 + } + } + }, + "range": [ + 69, + 90 + ], + "loc": { + "start": { + "line": 4, + "column": 11 + }, + "end": { + "line": 4, + "column": 32 + } + } + }, + "test": { + "type": "Identifier", + "name": "fn", + "range": [ + 65, + 67 + ], + "loc": { + "start": { + "line": 4, + "column": 7 + }, + "end": { + "line": 4, + "column": 9 + } + } + }, + "range": [ + 61, + 90 + ], + "loc": { + "start": { + "line": 4, + "column": 3 + }, + "end": { + "line": 4, + "column": 32 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "left": { + "type": "Identifier", + "name": "fn", + "range": [ + 94, + 96 + ], + "loc": { + "start": { + "line": 5, + "column": 3 + }, + "end": { + "line": 5, + "column": 5 + } + } + }, + "operator": "=", + "right": { + "type": "Literal", + "raw": "null", + "value": null, + "range": [ + 99, + 103 + ], + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 5, + "column": 12 + } + } + }, + "range": [ + 94, + 103 + ], + "loc": { + "start": { + "line": 5, + "column": 3 + }, + "end": { + "line": 5, + "column": 12 + } + } + }, + "range": [ + 94, + 104 + ], + "loc": { + "start": { + "line": 5, + "column": 3 + }, + "end": { + "line": 5, + "column": 13 + } + } + } + ], + "range": [ + 56, + 108 + ], + "loc": { + "start": { + "line": 3, + "column": 26 + }, + "end": { + "line": 6, + "column": 3 + } + } + }, + "expression": false, + "generator": false, + "id": null, + "params": [ + { + "type": "Identifier", + "name": "event", + "range": [ + 49, + 54 + ], + "loc": { + "start": { + "line": 3, + "column": 19 + }, + "end": { + "line": 3, + "column": 24 + } + } + } + ], + "range": [ + 39, + 108 + ], + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 6, + "column": 3 + } + } + }, + "range": [ + 32, + 109 + ], + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 6, + "column": 4 + } + } + } + ], + "range": [ + 28, + 112 + ], + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 7, + "column": 2 + } + } + }, + "expression": false, + "generator": false, + "id": { + "type": "Identifier", + "name": "once", + "range": [ + 19, + 23 + ], + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 14 + } + } + }, + "params": [ + { + "type": "Identifier", + "name": "fn", + "range": [ + 24, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 17 + } + } + } + ], + "range": [ + 10, + 112 + ], + "loc": { + "start": { + "line": 2, + "column": 1 + }, + "end": { + "line": 7, + "column": 2 + } + } + } + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "once", + "range": [ + 261, + 265 + ], + "loc": { + "start": { + "line": 17, + "column": 17 + }, + "end": { + "line": 17, + "column": 21 + } + } + }, + "from": "module", + "init": null, + "resolved": { + "type": "Identifier", + "name": "once", + "range": [ + 19, + 23 + ], + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 14 + } + } + } + } + ] + }, + { + "name": "preventDefault", + "identifiers": [ + { + "type": "Identifier", + "name": "preventDefault", + "range": [ + 124, + 138 + ], + "loc": { + "start": { + "line": 9, + "column": 10 + }, + "end": { + "line": 9, + "column": 24 + } + } + } + ], + "defs": [ + { + "type": "FunctionName", + "name": { + "type": "Identifier", + "name": "preventDefault", + "range": [ + 124, + 138 + ], + "loc": { + "start": { + "line": 9, + "column": 10 + }, + "end": { + "line": 9, + "column": 24 + } + } + }, + "node": { + "type": "FunctionDeclaration", + "async": false, + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "ReturnStatement", + "argument": { + "type": "FunctionExpression", + "async": false, + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "arguments": [], + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "event", + "range": [ + 176, + 181 + ], + "loc": { + "start": { + "line": 11, + "column": 3 + }, + "end": { + "line": 11, + "column": 8 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "name": "preventDefault", + "range": [ + 182, + 196 + ], + "loc": { + "start": { + "line": 11, + "column": 9 + }, + "end": { + "line": 11, + "column": 23 + } + } + }, + "range": [ + 176, + 196 + ], + "loc": { + "start": { + "line": 11, + "column": 3 + }, + "end": { + "line": 11, + "column": 23 + } + } + }, + "optional": false, + "range": [ + 176, + 198 + ], + "loc": { + "start": { + "line": 11, + "column": 3 + }, + "end": { + "line": 11, + "column": 25 + } + } + }, + "range": [ + 176, + 199 + ], + "loc": { + "start": { + "line": 11, + "column": 3 + }, + "end": { + "line": 11, + "column": 26 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "arguments": [ + { + "type": "ThisExpression", + "range": [ + 211, + 215 + ], + "loc": { + "start": { + "line": 12, + "column": 11 + }, + "end": { + "line": 12, + "column": 15 + } + } + }, + { + "type": "Identifier", + "name": "event", + "range": [ + 217, + 222 + ], + "loc": { + "start": { + "line": 12, + "column": 17 + }, + "end": { + "line": 12, + "column": 22 + } + } + } + ], + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "fn", + "range": [ + 203, + 205 + ], + "loc": { + "start": { + "line": 12, + "column": 3 + }, + "end": { + "line": 12, + "column": 5 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "name": "call", + "range": [ + 206, + 210 + ], + "loc": { + "start": { + "line": 12, + "column": 6 + }, + "end": { + "line": 12, + "column": 10 + } + } + }, + "range": [ + 203, + 210 + ], + "loc": { + "start": { + "line": 12, + "column": 3 + }, + "end": { + "line": 12, + "column": 10 + } + } + }, + "optional": false, + "range": [ + 203, + 223 + ], + "loc": { + "start": { + "line": 12, + "column": 3 + }, + "end": { + "line": 12, + "column": 23 + } + } + }, + "range": [ + 203, + 224 + ], + "loc": { + "start": { + "line": 12, + "column": 3 + }, + "end": { + "line": 12, + "column": 24 + } + } + } + ], + "range": [ + 171, + 228 + ], + "loc": { + "start": { + "line": 10, + "column": 26 + }, + "end": { + "line": 13, + "column": 3 + } + } + }, + "expression": false, + "generator": false, + "id": null, + "params": [ + { + "type": "Identifier", + "name": "event", + "range": [ + 164, + 169 + ], + "loc": { + "start": { + "line": 10, + "column": 19 + }, + "end": { + "line": 10, + "column": 24 + } + } + } + ], + "range": [ + 154, + 228 + ], + "loc": { + "start": { + "line": 10, + "column": 9 + }, + "end": { + "line": 13, + "column": 3 + } + } + }, + "range": [ + 147, + 229 + ], + "loc": { + "start": { + "line": 10, + "column": 2 + }, + "end": { + "line": 13, + "column": 4 + } + } + } + ], + "range": [ + 143, + 232 + ], + "loc": { + "start": { + "line": 9, + "column": 29 + }, + "end": { + "line": 14, + "column": 2 + } + } + }, + "expression": false, + "generator": false, + "id": { + "type": "Identifier", + "name": "preventDefault", + "range": [ + 124, + 138 + ], + "loc": { + "start": { + "line": 9, + "column": 10 + }, + "end": { + "line": 9, + "column": 24 + } + } + }, + "params": [ + { + "type": "Identifier", + "name": "fn", + "range": [ + 139, + 141 + ], + "loc": { + "start": { + "line": 9, + "column": 25 + }, + "end": { + "line": 9, + "column": 27 + } + } + } + ], + "range": [ + 115, + 232 + ], + "loc": { + "start": { + "line": 9, + "column": 1 + }, + "end": { + "line": 14, + "column": 2 + } + } + } + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "preventDefault", + "range": [ + 266, + 280 + ], + "loc": { + "start": { + "line": 17, + "column": 22 + }, + "end": { + "line": 17, + "column": 36 + } + } + }, + "from": "module", + "init": null, + "resolved": { + "type": "Identifier", + "name": "preventDefault", + "range": [ + 124, + 138 + ], + "loc": { + "start": { + "line": 9, + "column": 10 + }, + "end": { + "line": 9, + "column": 24 + } + } + } + } + ] + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "once", + "range": [ + 261, + 265 + ], + "loc": { + "start": { + "line": 17, + "column": 17 + }, + "end": { + "line": 17, + "column": 21 + } + } + }, + "from": "module", + "init": null, + "resolved": { + "type": "Identifier", + "name": "once", + "range": [ + 19, + 23 + ], + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 14 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "preventDefault", + "range": [ + 266, + 280 + ], + "loc": { + "start": { + "line": 17, + "column": 22 + }, + "end": { + "line": 17, + "column": 36 + } + } + }, + "from": "module", + "init": null, + "resolved": { + "type": "Identifier", + "name": "preventDefault", + "range": [ + 124, + 138 + ], + "loc": { + "start": { + "line": 9, + "column": 10 + }, + "end": { + "line": 9, + "column": 24 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "handler", + "range": [ + 281, + 288 + ], + "loc": { + "start": { + "line": 17, + "column": 37 + }, + "end": { + "line": 17, + "column": 44 + } + } + }, + "from": "module", + "init": null, + "resolved": null + } + ], + "childScopes": [ + { + "type": "function", + "variables": [ + { + "name": "arguments", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "fn", + "identifiers": [ + { + "type": "Identifier", + "name": "fn", + "range": [ + 24, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 17 + } + } + } + ], + "defs": [ + { + "type": "Parameter", + "name": { + "type": "Identifier", + "name": "fn", + "range": [ + 24, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 17 + } + } + }, + "node": { + "type": "FunctionDeclaration", + "async": false, + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "ReturnStatement", + "argument": { + "type": "FunctionExpression", + "async": false, + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "alternate": null, + "consequent": { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "arguments": [ + { + "type": "ThisExpression", + "range": [ + 77, + 81 + ], + "loc": { + "start": { + "line": 4, + "column": 19 + }, + "end": { + "line": 4, + "column": 23 + } + } + }, + { + "type": "Identifier", + "name": "event", + "range": [ + 83, + 88 + ], + "loc": { + "start": { + "line": 4, + "column": 25 + }, + "end": { + "line": 4, + "column": 30 + } + } + } + ], + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "fn", + "range": [ + 69, + 71 + ], + "loc": { + "start": { + "line": 4, + "column": 11 + }, + "end": { + "line": 4, + "column": 13 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "name": "call", + "range": [ + 72, + 76 + ], + "loc": { + "start": { + "line": 4, + "column": 14 + }, + "end": { + "line": 4, + "column": 18 + } + } + }, + "range": [ + 69, + 76 + ], + "loc": { + "start": { + "line": 4, + "column": 11 + }, + "end": { + "line": 4, + "column": 18 + } + } + }, + "optional": false, + "range": [ + 69, + 89 + ], + "loc": { + "start": { + "line": 4, + "column": 11 + }, + "end": { + "line": 4, + "column": 31 + } + } + }, + "range": [ + 69, + 90 + ], + "loc": { + "start": { + "line": 4, + "column": 11 + }, + "end": { + "line": 4, + "column": 32 + } + } + }, + "test": { + "type": "Identifier", + "name": "fn", + "range": [ + 65, + 67 + ], + "loc": { + "start": { + "line": 4, + "column": 7 + }, + "end": { + "line": 4, + "column": 9 + } + } + }, + "range": [ + 61, + 90 + ], + "loc": { + "start": { + "line": 4, + "column": 3 + }, + "end": { + "line": 4, + "column": 32 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "left": { + "type": "Identifier", + "name": "fn", + "range": [ + 94, + 96 + ], + "loc": { + "start": { + "line": 5, + "column": 3 + }, + "end": { + "line": 5, + "column": 5 + } + } + }, + "operator": "=", + "right": { + "type": "Literal", + "raw": "null", + "value": null, + "range": [ + 99, + 103 + ], + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 5, + "column": 12 + } + } + }, + "range": [ + 94, + 103 + ], + "loc": { + "start": { + "line": 5, + "column": 3 + }, + "end": { + "line": 5, + "column": 12 + } + } + }, + "range": [ + 94, + 104 + ], + "loc": { + "start": { + "line": 5, + "column": 3 + }, + "end": { + "line": 5, + "column": 13 + } + } + } + ], + "range": [ + 56, + 108 + ], + "loc": { + "start": { + "line": 3, + "column": 26 + }, + "end": { + "line": 6, + "column": 3 + } + } + }, + "expression": false, + "generator": false, + "id": null, + "params": [ + { + "type": "Identifier", + "name": "event", + "range": [ + 49, + 54 + ], + "loc": { + "start": { + "line": 3, + "column": 19 + }, + "end": { + "line": 3, + "column": 24 + } + } + } + ], + "range": [ + 39, + 108 + ], + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 6, + "column": 3 + } + } + }, + "range": [ + 32, + 109 + ], + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 6, + "column": 4 + } + } + } + ], + "range": [ + 28, + 112 + ], + "loc": { + "start": { + "line": 2, + "column": 19 + }, + "end": { + "line": 7, + "column": 2 + } + } + }, + "expression": false, + "generator": false, + "id": { + "type": "Identifier", + "name": "once", + "range": [ + 19, + 23 + ], + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 14 + } + } + }, + "params": [ + { + "type": "Identifier", + "name": "fn", + "range": [ + 24, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 17 + } + } + } + ], + "range": [ + 10, + 112 + ], + "loc": { + "start": { + "line": 2, + "column": 1 + }, + "end": { + "line": 7, + "column": 2 + } + } + } + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "fn", + "range": [ + 65, + 67 + ], + "loc": { + "start": { + "line": 4, + "column": 7 + }, + "end": { + "line": 4, + "column": 9 + } + } + }, + "from": "function", + "init": null, + "resolved": { + "type": "Identifier", + "name": "fn", + "range": [ + 24, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 17 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "fn", + "range": [ + 69, + 71 + ], + "loc": { + "start": { + "line": 4, + "column": 11 + }, + "end": { + "line": 4, + "column": 13 + } + } + }, + "from": "function", + "init": null, + "resolved": { + "type": "Identifier", + "name": "fn", + "range": [ + 24, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 17 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "fn", + "range": [ + 94, + 96 + ], + "loc": { + "start": { + "line": 5, + "column": 3 + }, + "end": { + "line": 5, + "column": 5 + } + } + }, + "from": "function", + "init": false, + "resolved": { + "type": "Identifier", + "name": "fn", + "range": [ + 24, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 17 + } + } + } + } + ] + } + ], + "references": [], + "childScopes": [ + { + "type": "function", + "variables": [ + { + "name": "arguments", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "event", + "identifiers": [ + { + "type": "Identifier", + "name": "event", + "range": [ + 49, + 54 + ], + "loc": { + "start": { + "line": 3, + "column": 19 + }, + "end": { + "line": 3, + "column": 24 + } + } + } + ], + "defs": [ + { + "type": "Parameter", + "name": { + "type": "Identifier", + "name": "event", + "range": [ + 49, + 54 + ], + "loc": { + "start": { + "line": 3, + "column": 19 + }, + "end": { + "line": 3, + "column": 24 + } + } + }, + "node": { + "type": "FunctionExpression", + "async": false, + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "IfStatement", + "alternate": null, + "consequent": { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "arguments": [ + { + "type": "ThisExpression", + "range": [ + 77, + 81 + ], + "loc": { + "start": { + "line": 4, + "column": 19 + }, + "end": { + "line": 4, + "column": 23 + } + } + }, + { + "type": "Identifier", + "name": "event", + "range": [ + 83, + 88 + ], + "loc": { + "start": { + "line": 4, + "column": 25 + }, + "end": { + "line": 4, + "column": 30 + } + } + } + ], + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "fn", + "range": [ + 69, + 71 + ], + "loc": { + "start": { + "line": 4, + "column": 11 + }, + "end": { + "line": 4, + "column": 13 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "name": "call", + "range": [ + 72, + 76 + ], + "loc": { + "start": { + "line": 4, + "column": 14 + }, + "end": { + "line": 4, + "column": 18 + } + } + }, + "range": [ + 69, + 76 + ], + "loc": { + "start": { + "line": 4, + "column": 11 + }, + "end": { + "line": 4, + "column": 18 + } + } + }, + "optional": false, + "range": [ + 69, + 89 + ], + "loc": { + "start": { + "line": 4, + "column": 11 + }, + "end": { + "line": 4, + "column": 31 + } + } + }, + "range": [ + 69, + 90 + ], + "loc": { + "start": { + "line": 4, + "column": 11 + }, + "end": { + "line": 4, + "column": 32 + } + } + }, + "test": { + "type": "Identifier", + "name": "fn", + "range": [ + 65, + 67 + ], + "loc": { + "start": { + "line": 4, + "column": 7 + }, + "end": { + "line": 4, + "column": 9 + } + } + }, + "range": [ + 61, + 90 + ], + "loc": { + "start": { + "line": 4, + "column": 3 + }, + "end": { + "line": 4, + "column": 32 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "left": { + "type": "Identifier", + "name": "fn", + "range": [ + 94, + 96 + ], + "loc": { + "start": { + "line": 5, + "column": 3 + }, + "end": { + "line": 5, + "column": 5 + } + } + }, + "operator": "=", + "right": { + "type": "Literal", + "raw": "null", + "value": null, + "range": [ + 99, + 103 + ], + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 5, + "column": 12 + } + } + }, + "range": [ + 94, + 103 + ], + "loc": { + "start": { + "line": 5, + "column": 3 + }, + "end": { + "line": 5, + "column": 12 + } + } + }, + "range": [ + 94, + 104 + ], + "loc": { + "start": { + "line": 5, + "column": 3 + }, + "end": { + "line": 5, + "column": 13 + } + } + } + ], + "range": [ + 56, + 108 + ], + "loc": { + "start": { + "line": 3, + "column": 26 + }, + "end": { + "line": 6, + "column": 3 + } + } + }, + "expression": false, + "generator": false, + "id": null, + "params": [ + { + "type": "Identifier", + "name": "event", + "range": [ + 49, + 54 + ], + "loc": { + "start": { + "line": 3, + "column": 19 + }, + "end": { + "line": 3, + "column": 24 + } + } + } + ], + "range": [ + 39, + 108 + ], + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 6, + "column": 3 + } + } + } + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "event", + "range": [ + 83, + 88 + ], + "loc": { + "start": { + "line": 4, + "column": 25 + }, + "end": { + "line": 4, + "column": 30 + } + } + }, + "from": "function", + "init": null, + "resolved": { + "type": "Identifier", + "name": "event", + "range": [ + 49, + 54 + ], + "loc": { + "start": { + "line": 3, + "column": 19 + }, + "end": { + "line": 3, + "column": 24 + } + } + } + } + ] + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "fn", + "range": [ + 65, + 67 + ], + "loc": { + "start": { + "line": 4, + "column": 7 + }, + "end": { + "line": 4, + "column": 9 + } + } + }, + "from": "function", + "init": null, + "resolved": { + "type": "Identifier", + "name": "fn", + "range": [ + 24, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 17 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "fn", + "range": [ + 69, + 71 + ], + "loc": { + "start": { + "line": 4, + "column": 11 + }, + "end": { + "line": 4, + "column": 13 + } + } + }, + "from": "function", + "init": null, + "resolved": { + "type": "Identifier", + "name": "fn", + "range": [ + 24, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 17 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "event", + "range": [ + 83, + 88 + ], + "loc": { + "start": { + "line": 4, + "column": 25 + }, + "end": { + "line": 4, + "column": 30 + } + } + }, + "from": "function", + "init": null, + "resolved": { + "type": "Identifier", + "name": "event", + "range": [ + 49, + 54 + ], + "loc": { + "start": { + "line": 3, + "column": 19 + }, + "end": { + "line": 3, + "column": 24 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "fn", + "range": [ + 94, + 96 + ], + "loc": { + "start": { + "line": 5, + "column": 3 + }, + "end": { + "line": 5, + "column": 5 + } + } + }, + "from": "function", + "init": false, + "resolved": { + "type": "Identifier", + "name": "fn", + "range": [ + 24, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 17 + } + } + } + } + ], + "childScopes": [], + "through": [ + { + "identifier": { + "type": "Identifier", + "name": "fn", + "range": [ + 65, + 67 + ], + "loc": { + "start": { + "line": 4, + "column": 7 + }, + "end": { + "line": 4, + "column": 9 + } + } + }, + "from": "function", + "init": null, + "resolved": { + "type": "Identifier", + "name": "fn", + "range": [ + 24, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 17 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "fn", + "range": [ + 69, + 71 + ], + "loc": { + "start": { + "line": 4, + "column": 11 + }, + "end": { + "line": 4, + "column": 13 + } + } + }, + "from": "function", + "init": null, + "resolved": { + "type": "Identifier", + "name": "fn", + "range": [ + 24, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 17 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "fn", + "range": [ + 94, + 96 + ], + "loc": { + "start": { + "line": 5, + "column": 3 + }, + "end": { + "line": 5, + "column": 5 + } + } + }, + "from": "function", + "init": false, + "resolved": { + "type": "Identifier", + "name": "fn", + "range": [ + 24, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 17 + } + } + } + } + ] + } + ], + "through": [] + }, + { + "type": "function", + "variables": [ + { + "name": "arguments", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "fn", + "identifiers": [ + { + "type": "Identifier", + "name": "fn", + "range": [ + 139, + 141 + ], + "loc": { + "start": { + "line": 9, + "column": 25 + }, + "end": { + "line": 9, + "column": 27 + } + } + } + ], + "defs": [ + { + "type": "Parameter", + "name": { + "type": "Identifier", + "name": "fn", + "range": [ + 139, + 141 + ], + "loc": { + "start": { + "line": 9, + "column": 25 + }, + "end": { + "line": 9, + "column": 27 + } + } + }, + "node": { + "type": "FunctionDeclaration", + "async": false, + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "ReturnStatement", + "argument": { + "type": "FunctionExpression", + "async": false, + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "arguments": [], + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "event", + "range": [ + 176, + 181 + ], + "loc": { + "start": { + "line": 11, + "column": 3 + }, + "end": { + "line": 11, + "column": 8 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "name": "preventDefault", + "range": [ + 182, + 196 + ], + "loc": { + "start": { + "line": 11, + "column": 9 + }, + "end": { + "line": 11, + "column": 23 + } + } + }, + "range": [ + 176, + 196 + ], + "loc": { + "start": { + "line": 11, + "column": 3 + }, + "end": { + "line": 11, + "column": 23 + } + } + }, + "optional": false, + "range": [ + 176, + 198 + ], + "loc": { + "start": { + "line": 11, + "column": 3 + }, + "end": { + "line": 11, + "column": 25 + } + } + }, + "range": [ + 176, + 199 + ], + "loc": { + "start": { + "line": 11, + "column": 3 + }, + "end": { + "line": 11, + "column": 26 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "arguments": [ + { + "type": "ThisExpression", + "range": [ + 211, + 215 + ], + "loc": { + "start": { + "line": 12, + "column": 11 + }, + "end": { + "line": 12, + "column": 15 + } + } + }, + { + "type": "Identifier", + "name": "event", + "range": [ + 217, + 222 + ], + "loc": { + "start": { + "line": 12, + "column": 17 + }, + "end": { + "line": 12, + "column": 22 + } + } + } + ], + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "fn", + "range": [ + 203, + 205 + ], + "loc": { + "start": { + "line": 12, + "column": 3 + }, + "end": { + "line": 12, + "column": 5 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "name": "call", + "range": [ + 206, + 210 + ], + "loc": { + "start": { + "line": 12, + "column": 6 + }, + "end": { + "line": 12, + "column": 10 + } + } + }, + "range": [ + 203, + 210 + ], + "loc": { + "start": { + "line": 12, + "column": 3 + }, + "end": { + "line": 12, + "column": 10 + } + } + }, + "optional": false, + "range": [ + 203, + 223 + ], + "loc": { + "start": { + "line": 12, + "column": 3 + }, + "end": { + "line": 12, + "column": 23 + } + } + }, + "range": [ + 203, + 224 + ], + "loc": { + "start": { + "line": 12, + "column": 3 + }, + "end": { + "line": 12, + "column": 24 + } + } + } + ], + "range": [ + 171, + 228 + ], + "loc": { + "start": { + "line": 10, + "column": 26 + }, + "end": { + "line": 13, + "column": 3 + } + } + }, + "expression": false, + "generator": false, + "id": null, + "params": [ + { + "type": "Identifier", + "name": "event", + "range": [ + 164, + 169 + ], + "loc": { + "start": { + "line": 10, + "column": 19 + }, + "end": { + "line": 10, + "column": 24 + } + } + } + ], + "range": [ + 154, + 228 + ], + "loc": { + "start": { + "line": 10, + "column": 9 + }, + "end": { + "line": 13, + "column": 3 + } + } + }, + "range": [ + 147, + 229 + ], + "loc": { + "start": { + "line": 10, + "column": 2 + }, + "end": { + "line": 13, + "column": 4 + } + } + } + ], + "range": [ + 143, + 232 + ], + "loc": { + "start": { + "line": 9, + "column": 29 + }, + "end": { + "line": 14, + "column": 2 + } + } + }, + "expression": false, + "generator": false, + "id": { + "type": "Identifier", + "name": "preventDefault", + "range": [ + 124, + 138 + ], + "loc": { + "start": { + "line": 9, + "column": 10 + }, + "end": { + "line": 9, + "column": 24 + } + } + }, + "params": [ + { + "type": "Identifier", + "name": "fn", + "range": [ + 139, + 141 + ], + "loc": { + "start": { + "line": 9, + "column": 25 + }, + "end": { + "line": 9, + "column": 27 + } + } + } + ], + "range": [ + 115, + 232 + ], + "loc": { + "start": { + "line": 9, + "column": 1 + }, + "end": { + "line": 14, + "column": 2 + } + } + } + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "fn", + "range": [ + 203, + 205 + ], + "loc": { + "start": { + "line": 12, + "column": 3 + }, + "end": { + "line": 12, + "column": 5 + } + } + }, + "from": "function", + "init": null, + "resolved": { + "type": "Identifier", + "name": "fn", + "range": [ + 139, + 141 + ], + "loc": { + "start": { + "line": 9, + "column": 25 + }, + "end": { + "line": 9, + "column": 27 + } + } + } + } + ] + } + ], + "references": [], + "childScopes": [ + { + "type": "function", + "variables": [ + { + "name": "arguments", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "event", + "identifiers": [ + { + "type": "Identifier", + "name": "event", + "range": [ + 164, + 169 + ], + "loc": { + "start": { + "line": 10, + "column": 19 + }, + "end": { + "line": 10, + "column": 24 + } + } + } + ], + "defs": [ + { + "type": "Parameter", + "name": { + "type": "Identifier", + "name": "event", + "range": [ + 164, + 169 + ], + "loc": { + "start": { + "line": 10, + "column": 19 + }, + "end": { + "line": 10, + "column": 24 + } + } + }, + "node": { + "type": "FunctionExpression", + "async": false, + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "arguments": [], + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "event", + "range": [ + 176, + 181 + ], + "loc": { + "start": { + "line": 11, + "column": 3 + }, + "end": { + "line": 11, + "column": 8 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "name": "preventDefault", + "range": [ + 182, + 196 + ], + "loc": { + "start": { + "line": 11, + "column": 9 + }, + "end": { + "line": 11, + "column": 23 + } + } + }, + "range": [ + 176, + 196 + ], + "loc": { + "start": { + "line": 11, + "column": 3 + }, + "end": { + "line": 11, + "column": 23 + } + } + }, + "optional": false, + "range": [ + 176, + 198 + ], + "loc": { + "start": { + "line": 11, + "column": 3 + }, + "end": { + "line": 11, + "column": 25 + } + } + }, + "range": [ + 176, + 199 + ], + "loc": { + "start": { + "line": 11, + "column": 3 + }, + "end": { + "line": 11, + "column": 26 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "arguments": [ + { + "type": "ThisExpression", + "range": [ + 211, + 215 + ], + "loc": { + "start": { + "line": 12, + "column": 11 + }, + "end": { + "line": 12, + "column": 15 + } + } + }, + { + "type": "Identifier", + "name": "event", + "range": [ + 217, + 222 + ], + "loc": { + "start": { + "line": 12, + "column": 17 + }, + "end": { + "line": 12, + "column": 22 + } + } + } + ], + "callee": { + "type": "MemberExpression", + "computed": false, + "object": { + "type": "Identifier", + "name": "fn", + "range": [ + 203, + 205 + ], + "loc": { + "start": { + "line": 12, + "column": 3 + }, + "end": { + "line": 12, + "column": 5 + } + } + }, + "optional": false, + "property": { + "type": "Identifier", + "name": "call", + "range": [ + 206, + 210 + ], + "loc": { + "start": { + "line": 12, + "column": 6 + }, + "end": { + "line": 12, + "column": 10 + } + } + }, + "range": [ + 203, + 210 + ], + "loc": { + "start": { + "line": 12, + "column": 3 + }, + "end": { + "line": 12, + "column": 10 + } + } + }, + "optional": false, + "range": [ + 203, + 223 + ], + "loc": { + "start": { + "line": 12, + "column": 3 + }, + "end": { + "line": 12, + "column": 23 + } + } + }, + "range": [ + 203, + 224 + ], + "loc": { + "start": { + "line": 12, + "column": 3 + }, + "end": { + "line": 12, + "column": 24 + } + } + } + ], + "range": [ + 171, + 228 + ], + "loc": { + "start": { + "line": 10, + "column": 26 + }, + "end": { + "line": 13, + "column": 3 + } + } + }, + "expression": false, + "generator": false, + "id": null, + "params": [ + { + "type": "Identifier", + "name": "event", + "range": [ + 164, + 169 + ], + "loc": { + "start": { + "line": 10, + "column": 19 + }, + "end": { + "line": 10, + "column": 24 + } + } + } + ], + "range": [ + 154, + 228 + ], + "loc": { + "start": { + "line": 10, + "column": 9 + }, + "end": { + "line": 13, + "column": 3 + } + } + } + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "event", + "range": [ + 176, + 181 + ], + "loc": { + "start": { + "line": 11, + "column": 3 + }, + "end": { + "line": 11, + "column": 8 + } + } + }, + "from": "function", + "init": null, + "resolved": { + "type": "Identifier", + "name": "event", + "range": [ + 164, + 169 + ], + "loc": { + "start": { + "line": 10, + "column": 19 + }, + "end": { + "line": 10, + "column": 24 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "event", + "range": [ + 217, + 222 + ], + "loc": { + "start": { + "line": 12, + "column": 17 + }, + "end": { + "line": 12, + "column": 22 + } + } + }, + "from": "function", + "init": null, + "resolved": { + "type": "Identifier", + "name": "event", + "range": [ + 164, + 169 + ], + "loc": { + "start": { + "line": 10, + "column": 19 + }, + "end": { + "line": 10, + "column": 24 + } + } + } + } + ] + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "event", + "range": [ + 176, + 181 + ], + "loc": { + "start": { + "line": 11, + "column": 3 + }, + "end": { + "line": 11, + "column": 8 + } + } + }, + "from": "function", + "init": null, + "resolved": { + "type": "Identifier", + "name": "event", + "range": [ + 164, + 169 + ], + "loc": { + "start": { + "line": 10, + "column": 19 + }, + "end": { + "line": 10, + "column": 24 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "fn", + "range": [ + 203, + 205 + ], + "loc": { + "start": { + "line": 12, + "column": 3 + }, + "end": { + "line": 12, + "column": 5 + } + } + }, + "from": "function", + "init": null, + "resolved": { + "type": "Identifier", + "name": "fn", + "range": [ + 139, + 141 + ], + "loc": { + "start": { + "line": 9, + "column": 25 + }, + "end": { + "line": 9, + "column": 27 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "event", + "range": [ + 217, + 222 + ], + "loc": { + "start": { + "line": 12, + "column": 17 + }, + "end": { + "line": 12, + "column": 22 + } + } + }, + "from": "function", + "init": null, + "resolved": { + "type": "Identifier", + "name": "event", + "range": [ + 164, + 169 + ], + "loc": { + "start": { + "line": 10, + "column": 19 + }, + "end": { + "line": 10, + "column": 24 + } + } + } + } + ], + "childScopes": [], + "through": [ + { + "identifier": { + "type": "Identifier", + "name": "fn", + "range": [ + 203, + 205 + ], + "loc": { + "start": { + "line": 12, + "column": 3 + }, + "end": { + "line": 12, + "column": 5 + } + } + }, + "from": "function", + "init": null, + "resolved": { + "type": "Identifier", + "name": "fn", + "range": [ + 139, + 141 + ], + "loc": { + "start": { + "line": 9, + "column": 25 + }, + "end": { + "line": 9, + "column": 27 + } + } + } + } + ] + } + ], + "through": [] + } + ], + "through": [ + { + "identifier": { + "type": "Identifier", + "name": "handler", + "range": [ + 281, + 288 + ], + "loc": { + "start": { + "line": 17, + "column": 37 + }, + "end": { + "line": 17, + "column": 44 + } + } + }, + "from": "module", + "init": null, + "resolved": null + } + ] + } + ], + "through": [ + { + "identifier": { + "type": "Identifier", + "name": "handler", + "range": [ + 281, + 288 + ], + "loc": { + "start": { + "line": 17, + "column": 37 + }, + "end": { + "line": 17, + "column": 44 + } + } + }, + "from": "module", + "init": null, + "resolved": null + } + ] +} \ No newline at end of file diff --git a/tests/fixtures/parser/ast/svelte5/docs/event-handlers/08-event-modifiers-input.svelte b/tests/fixtures/parser/ast/svelte5/docs/event-handlers/08-event-modifiers-input.svelte new file mode 100644 index 00000000..a6ad97df --- /dev/null +++ b/tests/fixtures/parser/ast/svelte5/docs/event-handlers/08-event-modifiers-input.svelte @@ -0,0 +1 @@ + diff --git a/tests/fixtures/parser/ast/svelte5/docs/event-handlers/08-event-modifiers-no-undef-result.json b/tests/fixtures/parser/ast/svelte5/docs/event-handlers/08-event-modifiers-no-undef-result.json new file mode 100644 index 00000000..8c2b9313 --- /dev/null +++ b/tests/fixtures/parser/ast/svelte5/docs/event-handlers/08-event-modifiers-no-undef-result.json @@ -0,0 +1,8 @@ +[ + { + "ruleId": "no-undef", + "code": "a", + "line": 1, + "column": 25 + } +] \ No newline at end of file diff --git a/tests/fixtures/parser/ast/svelte5/docs/event-handlers/08-event-modifiers-output.json b/tests/fixtures/parser/ast/svelte5/docs/event-handlers/08-event-modifiers-output.json new file mode 100644 index 00000000..895785ca --- /dev/null +++ b/tests/fixtures/parser/ast/svelte5/docs/event-handlers/08-event-modifiers-output.json @@ -0,0 +1,424 @@ +{ + "type": "Program", + "body": [ + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "button", + "range": [ + 1, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 7 + } + } + }, + "startTag": { + "type": "SvelteStartTag", + "attributes": [ + { + "type": "SvelteAttribute", + "key": { + "type": "SvelteName", + "name": "onclickcapture", + "range": [ + 8, + 22 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 22 + } + } + }, + "boolean": false, + "value": [ + { + "type": "SvelteMustacheTag", + "kind": "text", + "expression": { + "type": "Identifier", + "name": "a", + "range": [ + 24, + 25 + ], + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 25 + } + } + }, + "range": [ + 23, + 26 + ], + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 26 + } + } + } + ], + "range": [ + 8, + 26 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 26 + } + } + } + ], + "selfClosing": false, + "range": [ + 0, + 27 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 27 + } + } + }, + "children": [ + { + "type": "SvelteText", + "value": "...", + "range": [ + 27, + 30 + ], + "loc": { + "start": { + "line": 1, + "column": 27 + }, + "end": { + "line": 1, + "column": 30 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", + "range": [ + 30, + 39 + ], + "loc": { + "start": { + "line": 1, + "column": 30 + }, + "end": { + "line": 1, + "column": 39 + } + } + }, + "range": [ + 0, + 39 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 39 + } + } + } + ], + "sourceType": "module", + "comments": [], + "tokens": [ + { + "type": "Punctuator", + "value": "<", + "range": [ + 0, + 1 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "button", + "range": [ + 1, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 7 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "onclickcapture", + "range": [ + 8, + 22 + ], + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 22 + } + } + }, + { + "type": "Punctuator", + "value": "=", + "range": [ + 22, + 23 + ], + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 23 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 23, + 24 + ], + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 24 + } + } + }, + { + "type": "Identifier", + "value": "a", + "range": [ + 24, + 25 + ], + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 25 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 25, + 26 + ], + "loc": { + "start": { + "line": 1, + "column": 25 + }, + "end": { + "line": 1, + "column": 26 + } + } + }, + { + "type": "Punctuator", + "value": ">", + "range": [ + 26, + 27 + ], + "loc": { + "start": { + "line": 1, + "column": 26 + }, + "end": { + "line": 1, + "column": 27 + } + } + }, + { + "type": "HTMLText", + "value": "...", + "range": [ + 27, + 30 + ], + "loc": { + "start": { + "line": 1, + "column": 27 + }, + "end": { + "line": 1, + "column": 30 + } + } + }, + { + "type": "Punctuator", + "value": "<", + "range": [ + 30, + 31 + ], + "loc": { + "start": { + "line": 1, + "column": 30 + }, + "end": { + "line": 1, + "column": 31 + } + } + }, + { + "type": "Punctuator", + "value": "/", + "range": [ + 31, + 32 + ], + "loc": { + "start": { + "line": 1, + "column": 31 + }, + "end": { + "line": 1, + "column": 32 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "button", + "range": [ + 32, + 38 + ], + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 38 + } + } + }, + { + "type": "Punctuator", + "value": ">", + "range": [ + 38, + 39 + ], + "loc": { + "start": { + "line": 1, + "column": 38 + }, + "end": { + "line": 1, + "column": 39 + } + } + } + ], + "range": [ + 0, + 40 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 0 + } + } +} \ No newline at end of file diff --git a/tests/fixtures/parser/ast/svelte5/docs/event-handlers/08-event-modifiers-scope-output.json b/tests/fixtures/parser/ast/svelte5/docs/event-handlers/08-event-modifiers-scope-output.json new file mode 100644 index 00000000..af4315eb --- /dev/null +++ b/tests/fixtures/parser/ast/svelte5/docs/event-handlers/08-event-modifiers-scope-output.json @@ -0,0 +1,130 @@ +{ + "type": "global", + "variables": [ + { + "name": "$$slots", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$$props", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$$restProps", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$state", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$derived", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$effect", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$props", + "identifiers": [], + "defs": [], + "references": [] + } + ], + "references": [], + "childScopes": [ + { + "type": "module", + "variables": [], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "a", + "range": [ + 24, + 25 + ], + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 25 + } + } + }, + "from": "module", + "init": null, + "resolved": null + } + ], + "childScopes": [], + "through": [ + { + "identifier": { + "type": "Identifier", + "name": "a", + "range": [ + 24, + 25 + ], + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 25 + } + } + }, + "from": "module", + "init": null, + "resolved": null + } + ] + } + ], + "through": [ + { + "identifier": { + "type": "Identifier", + "name": "a", + "range": [ + 24, + 25 + ], + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 25 + } + } + }, + "from": "module", + "init": null, + "resolved": null + } + ] +} \ No newline at end of file diff --git a/tests/fixtures/parser/ast/svelte5/docs/event-handlers/09-multiple-event-handlers-input.svelte b/tests/fixtures/parser/ast/svelte5/docs/event-handlers/09-multiple-event-handlers-input.svelte new file mode 100644 index 00000000..1460be05 --- /dev/null +++ b/tests/fixtures/parser/ast/svelte5/docs/event-handlers/09-multiple-event-handlers-input.svelte @@ -0,0 +1,8 @@ + diff --git a/tests/fixtures/parser/ast/svelte5/docs/event-handlers/09-multiple-event-handlers-no-undef-result.json b/tests/fixtures/parser/ast/svelte5/docs/event-handlers/09-multiple-event-handlers-no-undef-result.json new file mode 100644 index 00000000..b799950f --- /dev/null +++ b/tests/fixtures/parser/ast/svelte5/docs/event-handlers/09-multiple-event-handlers-no-undef-result.json @@ -0,0 +1,14 @@ +[ + { + "ruleId": "no-undef", + "code": "one", + "line": 3, + "column": 3 + }, + { + "ruleId": "no-undef", + "code": "two", + "line": 4, + "column": 3 + } +] \ No newline at end of file diff --git a/tests/fixtures/parser/ast/svelte5/docs/event-handlers/09-multiple-event-handlers-output.json b/tests/fixtures/parser/ast/svelte5/docs/event-handlers/09-multiple-event-handlers-output.json new file mode 100644 index 00000000..552575e8 --- /dev/null +++ b/tests/fixtures/parser/ast/svelte5/docs/event-handlers/09-multiple-event-handlers-output.json @@ -0,0 +1,918 @@ +{ + "type": "Program", + "body": [ + { + "type": "SvelteElement", + "kind": "html", + "name": { + "type": "SvelteName", + "name": "button", + "range": [ + 1, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 7 + } + } + }, + "startTag": { + "type": "SvelteStartTag", + "attributes": [ + { + "type": "SvelteAttribute", + "key": { + "type": "SvelteName", + "name": "onclick", + "range": [ + 9, + 16 + ], + "loc": { + "start": { + "line": 2, + "column": 1 + }, + "end": { + "line": 2, + "column": 8 + } + } + }, + "boolean": false, + "value": [ + { + "type": "SvelteMustacheTag", + "kind": "text", + "expression": { + "type": "ArrowFunctionExpression", + "async": false, + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "arguments": [ + { + "type": "Identifier", + "name": "e", + "range": [ + 33, + 34 + ], + "loc": { + "start": { + "line": 3, + "column": 6 + }, + "end": { + "line": 3, + "column": 7 + } + } + } + ], + "callee": { + "type": "Identifier", + "name": "one", + "range": [ + 29, + 32 + ], + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 5 + } + } + }, + "optional": false, + "range": [ + 29, + 35 + ], + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 8 + } + } + }, + "range": [ + 29, + 36 + ], + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 9 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "arguments": [ + { + "type": "Identifier", + "name": "e", + "range": [ + 43, + 44 + ], + "loc": { + "start": { + "line": 4, + "column": 6 + }, + "end": { + "line": 4, + "column": 7 + } + } + } + ], + "callee": { + "type": "Identifier", + "name": "two", + "range": [ + 39, + 42 + ], + "loc": { + "start": { + "line": 4, + "column": 2 + }, + "end": { + "line": 4, + "column": 5 + } + } + }, + "optional": false, + "range": [ + 39, + 45 + ], + "loc": { + "start": { + "line": 4, + "column": 2 + }, + "end": { + "line": 4, + "column": 8 + } + } + }, + "range": [ + 39, + 46 + ], + "loc": { + "start": { + "line": 4, + "column": 2 + }, + "end": { + "line": 4, + "column": 9 + } + } + } + ], + "range": [ + 25, + 49 + ], + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 5, + "column": 2 + } + } + }, + "expression": false, + "generator": false, + "id": null, + "params": [ + { + "type": "Identifier", + "name": "e", + "range": [ + 19, + 20 + ], + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 12 + } + } + } + ], + "range": [ + 18, + 49 + ], + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 5, + "column": 2 + } + } + }, + "range": [ + 17, + 50 + ], + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 5, + "column": 3 + } + } + } + ], + "range": [ + 9, + 50 + ], + "loc": { + "start": { + "line": 2, + "column": 1 + }, + "end": { + "line": 5, + "column": 3 + } + } + } + ], + "selfClosing": false, + "range": [ + 0, + 52 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 6, + "column": 1 + } + } + }, + "children": [ + { + "type": "SvelteText", + "value": "\n\t...\n", + "range": [ + 52, + 58 + ], + "loc": { + "start": { + "line": 6, + "column": 1 + }, + "end": { + "line": 8, + "column": 0 + } + } + } + ], + "endTag": { + "type": "SvelteEndTag", + "range": [ + 58, + 67 + ], + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 9 + } + } + }, + "range": [ + 0, + 67 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 8, + "column": 9 + } + } + } + ], + "sourceType": "module", + "comments": [], + "tokens": [ + { + "type": "Punctuator", + "value": "<", + "range": [ + 0, + 1 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "button", + "range": [ + 1, + 7 + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 7 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "onclick", + "range": [ + 9, + 16 + ], + "loc": { + "start": { + "line": 2, + "column": 1 + }, + "end": { + "line": 2, + "column": 8 + } + } + }, + { + "type": "Punctuator", + "value": "=", + "range": [ + 16, + 17 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 9 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 17, + 18 + ], + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 10 + } + } + }, + { + "type": "Punctuator", + "value": "(", + "range": [ + 18, + 19 + ], + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 11 + } + } + }, + { + "type": "Identifier", + "value": "e", + "range": [ + 19, + 20 + ], + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 12 + } + } + }, + { + "type": "Punctuator", + "value": ")", + "range": [ + 20, + 21 + ], + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 13 + } + } + }, + { + "type": "Punctuator", + "value": "=>", + "range": [ + 22, + 24 + ], + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 16 + } + } + }, + { + "type": "Punctuator", + "value": "{", + "range": [ + 25, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 18 + } + } + }, + { + "type": "Identifier", + "value": "one", + "range": [ + 29, + 32 + ], + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 5 + } + } + }, + { + "type": "Punctuator", + "value": "(", + "range": [ + 32, + 33 + ], + "loc": { + "start": { + "line": 3, + "column": 5 + }, + "end": { + "line": 3, + "column": 6 + } + } + }, + { + "type": "Identifier", + "value": "e", + "range": [ + 33, + 34 + ], + "loc": { + "start": { + "line": 3, + "column": 6 + }, + "end": { + "line": 3, + "column": 7 + } + } + }, + { + "type": "Punctuator", + "value": ")", + "range": [ + 34, + 35 + ], + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 8 + } + } + }, + { + "type": "Punctuator", + "value": ";", + "range": [ + 35, + 36 + ], + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 9 + } + } + }, + { + "type": "Identifier", + "value": "two", + "range": [ + 39, + 42 + ], + "loc": { + "start": { + "line": 4, + "column": 2 + }, + "end": { + "line": 4, + "column": 5 + } + } + }, + { + "type": "Punctuator", + "value": "(", + "range": [ + 42, + 43 + ], + "loc": { + "start": { + "line": 4, + "column": 5 + }, + "end": { + "line": 4, + "column": 6 + } + } + }, + { + "type": "Identifier", + "value": "e", + "range": [ + 43, + 44 + ], + "loc": { + "start": { + "line": 4, + "column": 6 + }, + "end": { + "line": 4, + "column": 7 + } + } + }, + { + "type": "Punctuator", + "value": ")", + "range": [ + 44, + 45 + ], + "loc": { + "start": { + "line": 4, + "column": 7 + }, + "end": { + "line": 4, + "column": 8 + } + } + }, + { + "type": "Punctuator", + "value": ";", + "range": [ + 45, + 46 + ], + "loc": { + "start": { + "line": 4, + "column": 8 + }, + "end": { + "line": 4, + "column": 9 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 48, + 49 + ], + "loc": { + "start": { + "line": 5, + "column": 1 + }, + "end": { + "line": 5, + "column": 2 + } + } + }, + { + "type": "Punctuator", + "value": "}", + "range": [ + 49, + 50 + ], + "loc": { + "start": { + "line": 5, + "column": 2 + }, + "end": { + "line": 5, + "column": 3 + } + } + }, + { + "type": "Punctuator", + "value": ">", + "range": [ + 51, + 52 + ], + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 1 + } + } + }, + { + "type": "HTMLText", + "value": "\n\t", + "range": [ + 52, + 54 + ], + "loc": { + "start": { + "line": 6, + "column": 1 + }, + "end": { + "line": 7, + "column": 1 + } + } + }, + { + "type": "HTMLText", + "value": "...", + "range": [ + 54, + 57 + ], + "loc": { + "start": { + "line": 7, + "column": 1 + }, + "end": { + "line": 7, + "column": 4 + } + } + }, + { + "type": "HTMLText", + "value": "\n", + "range": [ + 57, + 58 + ], + "loc": { + "start": { + "line": 7, + "column": 4 + }, + "end": { + "line": 8, + "column": 0 + } + } + }, + { + "type": "Punctuator", + "value": "<", + "range": [ + 58, + 59 + ], + "loc": { + "start": { + "line": 8, + "column": 0 + }, + "end": { + "line": 8, + "column": 1 + } + } + }, + { + "type": "Punctuator", + "value": "/", + "range": [ + 59, + 60 + ], + "loc": { + "start": { + "line": 8, + "column": 1 + }, + "end": { + "line": 8, + "column": 2 + } + } + }, + { + "type": "HTMLIdentifier", + "value": "button", + "range": [ + 60, + 66 + ], + "loc": { + "start": { + "line": 8, + "column": 2 + }, + "end": { + "line": 8, + "column": 8 + } + } + }, + { + "type": "Punctuator", + "value": ">", + "range": [ + 66, + 67 + ], + "loc": { + "start": { + "line": 8, + "column": 8 + }, + "end": { + "line": 8, + "column": 9 + } + } + } + ], + "range": [ + 0, + 68 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 9, + "column": 0 + } + } +} \ No newline at end of file diff --git a/tests/fixtures/parser/ast/svelte5/docs/event-handlers/09-multiple-event-handlers-scope-output.json b/tests/fixtures/parser/ast/svelte5/docs/event-handlers/09-multiple-event-handlers-scope-output.json new file mode 100644 index 00000000..7d4b2351 --- /dev/null +++ b/tests/fixtures/parser/ast/svelte5/docs/event-handlers/09-multiple-event-handlers-scope-output.json @@ -0,0 +1,669 @@ +{ + "type": "global", + "variables": [ + { + "name": "$$slots", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$$props", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$$restProps", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$state", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$derived", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$effect", + "identifiers": [], + "defs": [], + "references": [] + }, + { + "name": "$props", + "identifiers": [], + "defs": [], + "references": [] + } + ], + "references": [], + "childScopes": [ + { + "type": "module", + "variables": [], + "references": [], + "childScopes": [ + { + "type": "function", + "variables": [ + { + "name": "e", + "identifiers": [ + { + "type": "Identifier", + "name": "e", + "range": [ + 19, + 20 + ], + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 12 + } + } + } + ], + "defs": [ + { + "type": "Parameter", + "name": { + "type": "Identifier", + "name": "e", + "range": [ + 19, + 20 + ], + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 12 + } + } + }, + "node": { + "type": "ArrowFunctionExpression", + "async": false, + "body": { + "type": "BlockStatement", + "body": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "arguments": [ + { + "type": "Identifier", + "name": "e", + "range": [ + 33, + 34 + ], + "loc": { + "start": { + "line": 3, + "column": 6 + }, + "end": { + "line": 3, + "column": 7 + } + } + } + ], + "callee": { + "type": "Identifier", + "name": "one", + "range": [ + 29, + 32 + ], + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 5 + } + } + }, + "optional": false, + "range": [ + 29, + 35 + ], + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 8 + } + } + }, + "range": [ + 29, + 36 + ], + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 9 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "arguments": [ + { + "type": "Identifier", + "name": "e", + "range": [ + 43, + 44 + ], + "loc": { + "start": { + "line": 4, + "column": 6 + }, + "end": { + "line": 4, + "column": 7 + } + } + } + ], + "callee": { + "type": "Identifier", + "name": "two", + "range": [ + 39, + 42 + ], + "loc": { + "start": { + "line": 4, + "column": 2 + }, + "end": { + "line": 4, + "column": 5 + } + } + }, + "optional": false, + "range": [ + 39, + 45 + ], + "loc": { + "start": { + "line": 4, + "column": 2 + }, + "end": { + "line": 4, + "column": 8 + } + } + }, + "range": [ + 39, + 46 + ], + "loc": { + "start": { + "line": 4, + "column": 2 + }, + "end": { + "line": 4, + "column": 9 + } + } + } + ], + "range": [ + 25, + 49 + ], + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 5, + "column": 2 + } + } + }, + "expression": false, + "generator": false, + "id": null, + "params": [ + { + "type": "Identifier", + "name": "e", + "range": [ + 19, + 20 + ], + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 12 + } + } + } + ], + "range": [ + 18, + 49 + ], + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 5, + "column": 2 + } + } + } + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "e", + "range": [ + 33, + 34 + ], + "loc": { + "start": { + "line": 3, + "column": 6 + }, + "end": { + "line": 3, + "column": 7 + } + } + }, + "from": "function", + "init": null, + "resolved": { + "type": "Identifier", + "name": "e", + "range": [ + 19, + 20 + ], + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 12 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "e", + "range": [ + 43, + 44 + ], + "loc": { + "start": { + "line": 4, + "column": 6 + }, + "end": { + "line": 4, + "column": 7 + } + } + }, + "from": "function", + "init": null, + "resolved": { + "type": "Identifier", + "name": "e", + "range": [ + 19, + 20 + ], + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 12 + } + } + } + } + ] + } + ], + "references": [ + { + "identifier": { + "type": "Identifier", + "name": "one", + "range": [ + 29, + 32 + ], + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 5 + } + } + }, + "from": "function", + "init": null, + "resolved": null + }, + { + "identifier": { + "type": "Identifier", + "name": "e", + "range": [ + 33, + 34 + ], + "loc": { + "start": { + "line": 3, + "column": 6 + }, + "end": { + "line": 3, + "column": 7 + } + } + }, + "from": "function", + "init": null, + "resolved": { + "type": "Identifier", + "name": "e", + "range": [ + 19, + 20 + ], + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 12 + } + } + } + }, + { + "identifier": { + "type": "Identifier", + "name": "two", + "range": [ + 39, + 42 + ], + "loc": { + "start": { + "line": 4, + "column": 2 + }, + "end": { + "line": 4, + "column": 5 + } + } + }, + "from": "function", + "init": null, + "resolved": null + }, + { + "identifier": { + "type": "Identifier", + "name": "e", + "range": [ + 43, + 44 + ], + "loc": { + "start": { + "line": 4, + "column": 6 + }, + "end": { + "line": 4, + "column": 7 + } + } + }, + "from": "function", + "init": null, + "resolved": { + "type": "Identifier", + "name": "e", + "range": [ + 19, + 20 + ], + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 12 + } + } + } + } + ], + "childScopes": [], + "through": [ + { + "identifier": { + "type": "Identifier", + "name": "one", + "range": [ + 29, + 32 + ], + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 5 + } + } + }, + "from": "function", + "init": null, + "resolved": null + }, + { + "identifier": { + "type": "Identifier", + "name": "two", + "range": [ + 39, + 42 + ], + "loc": { + "start": { + "line": 4, + "column": 2 + }, + "end": { + "line": 4, + "column": 5 + } + } + }, + "from": "function", + "init": null, + "resolved": null + } + ] + } + ], + "through": [ + { + "identifier": { + "type": "Identifier", + "name": "one", + "range": [ + 29, + 32 + ], + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 5 + } + } + }, + "from": "function", + "init": null, + "resolved": null + }, + { + "identifier": { + "type": "Identifier", + "name": "two", + "range": [ + 39, + 42 + ], + "loc": { + "start": { + "line": 4, + "column": 2 + }, + "end": { + "line": 4, + "column": 5 + } + } + }, + "from": "function", + "init": null, + "resolved": null + } + ] + } + ], + "through": [ + { + "identifier": { + "type": "Identifier", + "name": "one", + "range": [ + 29, + 32 + ], + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 5 + } + } + }, + "from": "function", + "init": null, + "resolved": null + }, + { + "identifier": { + "type": "Identifier", + "name": "two", + "range": [ + 39, + 42 + ], + "loc": { + "start": { + "line": 4, + "column": 2 + }, + "end": { + "line": 4, + "column": 5 + } + } + }, + "from": "function", + "init": null, + "resolved": null + } + ] +} \ No newline at end of file