svelte-parse
Version:
An increidbly relaxed svelte-parser
253 lines (252 loc) • 4.25 kB
JSON
{
"type": "root",
"children": [
{
"type": "svelteScript",
"tagName": "script",
"properties": [],
"selfClosing": false,
"children": [
{
"type": "text",
"value": "\n\tlet count = 0;\n\n\t$: if (count >= 10) {\n\t\talert(`count is dangerously high!`);\n\t\tcount = 9;\n\t}\n\n\tfunction handleClick() {\n\t\tcount += 1;\n\t}\n",
"position": {
"start": {
"line": 1,
"column": 9,
"offset": 8
},
"end": {
"line": 12,
"column": 1,
"offset": 148
}
}
}
],
"position": {
"start": {
"line": 1,
"column": 1,
"offset": 0
},
"end": {
"line": 12,
"column": 10,
"offset": 157
}
}
},
{
"type": "text",
"value": "\n\n",
"position": {
"start": {
"line": 12,
"column": 10,
"offset": 157
},
"end": {
"line": 14,
"column": 1,
"offset": 159
}
}
},
{
"type": "svelteElement",
"tagName": "button",
"properties": [
{
"type": "svelteDirective",
"name": "on",
"value": [
{
"type": "svelteDynamicContent",
"position": {
"start": {
"line": 14,
"column": 18,
"offset": 176
},
"end": {
"line": 14,
"column": 31,
"offset": 189
}
},
"expression": {
"type": "svelteExpression",
"value": "handleClick",
"position": {
"start": {
"line": 14,
"column": 19,
"offset": 177
},
"end": {
"line": 14,
"column": 30,
"offset": 188
}
}
}
}
],
"modifiers": [],
"shorthand": "none",
"position": {
"start": {
"line": 14,
"column": 9,
"offset": 167
},
"end": {
"line": 14,
"column": 31,
"offset": 189
}
},
"specifier": "click"
}
],
"selfClosing": false,
"children": [
{
"type": "text",
"value": "\n\tClicked ",
"position": {
"start": {
"line": 14,
"column": 32,
"offset": 190
},
"end": {
"line": 15,
"column": 10,
"offset": 200
}
}
},
{
"type": "svelteDynamicContent",
"position": {
"start": {
"line": 15,
"column": 10,
"offset": 200
},
"end": {
"line": 15,
"column": 17,
"offset": 207
}
},
"expression": {
"type": "svelteExpression",
"value": "count",
"position": {
"start": {
"line": 15,
"column": 11,
"offset": 201
},
"end": {
"line": 15,
"column": 16,
"offset": 206
}
}
}
},
{
"type": "text",
"value": " ",
"position": {
"start": {
"line": 15,
"column": 17,
"offset": 207
},
"end": {
"line": 15,
"column": 18,
"offset": 208
}
}
},
{
"type": "svelteDynamicContent",
"position": {
"start": {
"line": 15,
"column": 18,
"offset": 208
},
"end": {
"line": 15,
"column": 50,
"offset": 240
}
},
"expression": {
"type": "svelteExpression",
"value": "count === 1 ? 'time' : 'times'",
"position": {
"start": {
"line": 15,
"column": 19,
"offset": 209
},
"end": {
"line": 15,
"column": 49,
"offset": 239
}
}
}
},
{
"type": "text",
"value": "\n",
"position": {
"start": {
"line": 15,
"column": 50,
"offset": 240
},
"end": {
"line": 16,
"column": 1,
"offset": 241
}
}
}
],
"position": {
"start": {
"line": 14,
"column": 1,
"offset": 159
},
"end": {
"line": 16,
"column": 10,
"offset": 250
}
}
}
],
"position": {
"start": {
"column": 1,
"line": 1,
"offset": 0
},
"end": {
"line": 16,
"column": 10,
"offset": 250
}
}
}