@@ -1007,7 +1007,7 @@ export default class Component {
10071007 return null ;
10081008 }
10091009
1010- rewrite_props ( get_insert : ( variable : Var ) => Node [ ] ) {
1010+ rewrite_props_and_add_subscriptions ( get_subscriptions : ( variable : Var ) => Node [ ] ) {
10111011 if ( ! this . ast . instance ) return ;
10121012
10131013 const component = this ;
@@ -1031,7 +1031,7 @@ export default class Component {
10311031 if ( node . type === 'VariableDeclaration' ) {
10321032 // NOTE: `var` does not follow block scoping
10331033 if ( node . kind === 'var' || scope === instance_scope ) {
1034- const inserts = [ ] ;
1034+ const subscriptions = [ ] ;
10351035 const props = [ ] ;
10361036
10371037 function add_new_props ( exported , local , default_value ) {
@@ -1067,7 +1067,7 @@ export default class Component {
10671067 function get_new_name ( local ) {
10681068 const variable = component . var_lookup . get ( local . name ) ;
10691069 if ( variable . subscribable ) {
1070- inserts . push ( get_insert ( variable ) ) ;
1070+ subscriptions . push ( get_subscriptions ( variable ) ) ;
10711071 }
10721072
10731073 if ( variable . export_name && variable . writable ) {
@@ -1133,7 +1133,7 @@ export default class Component {
11331133 node . declarations . splice ( index -- , 1 ) ;
11341134 }
11351135 if ( variable . subscribable && ( is_props || declarator . init ) ) {
1136- inserts . push ( get_insert ( variable ) ) ;
1136+ subscriptions . push ( get_subscriptions ( variable ) ) ;
11371137 }
11381138 }
11391139 }
@@ -1145,10 +1145,10 @@ export default class Component {
11451145
11461146 if ( Array . isArray ( parent [ key ] ) ) {
11471147 // If the variable declaration is part of some block, that is, among an array of statements
1148- // then, we add the inserts and the $$props declaration after declaration
1149- if ( inserts . length > 0 ) {
1150- inserts . reverse ( ) . forEach ( ( insert ) => {
1151- parent [ key ] . splice ( index + 1 , 0 , ...insert ) ;
1148+ // then, we add the subscriptions and the $$props declaration after declaration
1149+ if ( subscriptions . length > 0 ) {
1150+ subscriptions . reverse ( ) . forEach ( ( subscription ) => {
1151+ parent [ key ] . splice ( index + 1 , 0 , ...subscription ) ;
11521152 } ) ;
11531153 }
11541154 if ( props . length > 0 ) {
@@ -1158,14 +1158,14 @@ export default class Component {
11581158 if ( node . declarations . length == 0 ) {
11591159 parent [ key ] . splice ( index , 1 ) ;
11601160 }
1161- } else if ( inserts . length > 0 ) {
1161+ } else if ( subscriptions . length > 0 ) {
11621162 // If the variable declaration is not part of a block, we instead get a dummy variable setting
11631163 // calling an immediately-invoked function expression containing all the subscription functions
11641164 node . declarations . push ( {
11651165 type : 'VariableDeclarator' ,
1166- id : component . get_unique_name ( '$$subscription_inserts ' , scope ) ,
1166+ id : component . get_unique_name ( '$$subscriptions ' , scope ) ,
11671167 init : x `(() => {
1168- ${ inserts }
1168+ ${ subscriptions }
11691169 })()`
11701170 } ) ;
11711171 }
0 commit comments