Skip to content

Commit bdf3a1a

Browse files
committed
fix bug
1 parent b05d42c commit bdf3a1a

File tree

21 files changed

+63
-45
lines changed

21 files changed

+63
-45
lines changed

packages/svelte/src/compiler/phases/2-analyze/visitors/SnippetBlock.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,9 @@ function can_hoist_snippet(scope, scopes, visited = new Set()) {
9999
if (binding.initial?.type === 'SnippetBlock') {
100100
if (visited.has(binding)) continue;
101101
visited.add(binding);
102+
const snippet_scope = /** @type {Scope} */ (scopes.get(binding.initial));
102103

103-
if (can_hoist_snippet(binding.scope, scopes, visited)) {
104+
if (can_hoist_snippet(snippet_scope, scopes, visited)) {
104105
continue;
105106
}
106107
}

packages/svelte/tests/parser-legacy/samples/action-duplicate/output.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@
1515
"end": 20,
1616
"type": "Action",
1717
"name": "autofocus",
18-
"modifiers": [],
19-
"expression": null
18+
"expression": null,
19+
"modifiers": []
2020
},
2121
{
2222
"start": 21,
2323
"end": 34,
2424
"type": "Action",
2525
"name": "autofocus",
26-
"modifiers": [],
27-
"expression": null
26+
"expression": null,
27+
"modifiers": []
2828
}
2929
],
3030
"children": []

packages/svelte/tests/parser-legacy/samples/action-with-call/output.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
"end": 39,
1616
"type": "Action",
1717
"name": "tooltip",
18-
"modifiers": [],
1918
"expression": {
2019
"type": "CallExpression",
2120
"start": 21,
@@ -66,7 +65,8 @@
6665
}
6766
],
6867
"optional": false
69-
}
68+
},
69+
"modifiers": []
7070
}
7171
],
7272
"children": []

packages/svelte/tests/parser-legacy/samples/action-with-identifier/output.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
"end": 28,
1616
"type": "Action",
1717
"name": "tooltip",
18-
"modifiers": [],
1918
"expression": {
2019
"type": "Identifier",
2120
"start": 20,
@@ -31,7 +30,8 @@
3130
}
3231
},
3332
"name": "message"
34-
}
33+
},
34+
"modifiers": []
3535
}
3636
],
3737
"children": []

packages/svelte/tests/parser-legacy/samples/action-with-literal/output.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
"end": 36,
1616
"type": "Action",
1717
"name": "tooltip",
18-
"modifiers": [],
1918
"expression": {
2019
"type": "Literal",
2120
"start": 21,
@@ -32,7 +31,8 @@
3231
},
3332
"value": "tooltip msg",
3433
"raw": "'tooltip msg'"
35-
}
34+
},
35+
"modifiers": []
3636
}
3737
],
3838
"children": []

packages/svelte/tests/parser-legacy/samples/action/output.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
"end": 20,
1616
"type": "Action",
1717
"name": "autofocus",
18-
"modifiers": [],
19-
"expression": null
18+
"expression": null,
19+
"modifiers": []
2020
}
2121
],
2222
"children": []

packages/svelte/tests/parser-legacy/samples/animation/output.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
"end": 50,
2121
"type": "Animation",
2222
"name": "flip",
23-
"modifiers": [],
24-
"expression": null
23+
"expression": null,
24+
"modifiers": []
2525
}
2626
],
2727
"children": [

packages/svelte/tests/parser-legacy/samples/attribute-class-directive/output.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
"end": 22,
1616
"type": "Class",
1717
"name": "foo",
18-
"modifiers": [],
1918
"expression": {
2019
"type": "Identifier",
2120
"start": 16,
@@ -31,7 +30,8 @@
3130
}
3231
},
3332
"name": "isFoo"
34-
}
33+
},
34+
"modifiers": []
3535
}
3636
],
3737
"children": []

packages/svelte/tests/parser-legacy/samples/attribute-with-whitespace/output.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
"end": 23,
1616
"type": "EventHandler",
1717
"name": "click",
18-
"modifiers": [],
1918
"expression": {
2019
"type": "Identifier",
2120
"start": 19,
@@ -31,7 +30,8 @@
3130
}
3231
},
3332
"name": "foo"
34-
}
33+
},
34+
"modifiers": []
3535
}
3636
],
3737
"children": [

packages/svelte/tests/parser-legacy/samples/binding-shorthand/output.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@
2222
"end": 46,
2323
"type": "Binding",
2424
"name": "foo",
25-
"modifiers": [],
2625
"expression": {
2726
"start": 43,
2827
"end": 46,
2928
"type": "Identifier",
3029
"name": "foo"
31-
}
30+
},
31+
"modifiers": []
3232
}
3333
],
3434
"children": []

0 commit comments

Comments
 (0)