File tree Expand file tree Collapse file tree 3 files changed +10
-8
lines changed
packages/svelte/src/compiler/phases Expand file tree Collapse file tree 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) {
1414 const consequent = /** @type {BlockStatement } */ ( context . visit ( node . consequent ) ) ;
1515 context . state . template . push ( '<!>' ) ;
1616 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+ ) ;
1820 } else {
1921 const statements = [ ] ;
2022 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) {
488488}
489489
490490/**
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.
492492 * @param {BlockStatement } block
493493 */
494494export 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' ) ;
498498 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 {
10111011 /**
10121012 * A set of all the names referenced with this scope
10131013 * — 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 }[]> }
10151015 */
10161016 references = new Map ( ) ;
10171017
@@ -1145,7 +1145,7 @@ export class Scope {
11451145
11461146 if ( ! references ) this . references . set ( node . name , ( references = [ ] ) ) ;
11471147
1148- references . push ( { node, path } ) ;
1148+ references . push ( { node, path, scope : this } ) ;
11491149
11501150 const binding = this . declarations . get ( node . name ) ;
11511151 if ( binding ) {
You can’t perform that action at this time.
0 commit comments