File tree 3 files changed +10
-8
lines changed
packages/svelte/src/compiler/phases
3 files changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,9 @@ export function IfBlock(node, context) {
14
14
const consequent = /** @type {BlockStatement } */ ( context . visit ( node . consequent ) ) ;
15
15
context . state . template . push ( '<!>' ) ;
16
16
if ( evaluated . is_truthy ) {
17
- context . state . init . push ( b . stmt ( b . call ( b . arrow ( [ b . id ( '$$anchor' ) ] , consequent ) , context . state . node ) ) ) ;
17
+ context . state . init . push (
18
+ b . stmt ( b . call ( b . arrow ( [ b . id ( '$$anchor' ) ] , consequent ) , context . state . node ) )
19
+ ) ;
18
20
} else {
19
21
const statements = [ ] ;
20
22
const consequent_id = context . state . scope . generate ( 'consequent' ) ;
Original file line number Diff line number Diff line change @@ -488,12 +488,12 @@ export function transform_inspect_rune(node, context) {
488
488
}
489
489
490
490
/**
491
- * Whether a `BlockStatement` needs to be a block statement as opposed to just inlining all of its statements.
491
+ * Whether a `BlockStatement` needs to be a block statement as opposed to just inlining all of its statements.
492
492
* @param {BlockStatement } block
493
493
*/
494
494
export function needs_new_scope ( block ) {
495
- const has_vars = block . body . some ( child => child . type === 'VariableDeclaration' ) ;
496
- const has_fns = block . body . some ( child => child . type === 'FunctionDeclaration' ) ;
497
- const has_class = block . body . some ( child => child . type === 'ClassDeclaration' ) ;
495
+ const has_vars = block . body . some ( ( child ) => child . type === 'VariableDeclaration' ) ;
496
+ const has_fns = block . body . some ( ( child ) => child . type === 'FunctionDeclaration' ) ;
497
+ const has_class = block . body . some ( ( child ) => child . type === 'ClassDeclaration' ) ;
498
498
return has_vars || has_fns || has_class ;
499
- }
499
+ }
Original file line number Diff line number Diff line change @@ -1011,7 +1011,7 @@ export class Scope {
1011
1011
/**
1012
1012
* A set of all the names referenced with this scope
1013
1013
* — useful for generating unique names
1014
- * @type {Map<string, { node: Identifier; path: AST.SvelteNode[] }[]> }
1014
+ * @type {Map<string, { node: Identifier; path: AST.SvelteNode[], scope: Scope }[]> }
1015
1015
*/
1016
1016
references = new Map ( ) ;
1017
1017
@@ -1145,7 +1145,7 @@ export class Scope {
1145
1145
1146
1146
if ( ! references ) this . references . set ( node . name , ( references = [ ] ) ) ;
1147
1147
1148
- references . push ( { node, path } ) ;
1148
+ references . push ( { node, path, scope : this } ) ;
1149
1149
1150
1150
const binding = this . declarations . get ( node . name ) ;
1151
1151
if ( binding ) {
You can’t perform that action at this time.
0 commit comments