@@ -9,6 +9,7 @@ import add_to_set from '../../utils/add_to_set';
9
9
import get_slot_data from '../../utils/get_slot_data' ;
10
10
import { stringify_props } from '../../utils/stringify_props' ;
11
11
import Expression from '../../nodes/shared/Expression' ;
12
+ import is_dynamic from './shared/is_dynamic' ;
12
13
13
14
export default class SlotWrapper extends Wrapper {
14
15
node : Slot ;
@@ -72,17 +73,27 @@ export default class SlotWrapper extends Wrapper {
72
73
this . node . values . forEach ( attribute => {
73
74
attribute . chunks . forEach ( chunk => {
74
75
if ( ( chunk as Expression ) . dependencies ) {
75
- add_to_set ( dependencies , ( chunk as Expression ) . dependencies ) ;
76
76
add_to_set ( dependencies , ( chunk as Expression ) . contextual_dependencies ) ;
77
+
78
+ // add_to_set(dependencies, (chunk as Expression).dependencies);
79
+ ( chunk as Expression ) . dependencies . forEach ( name => {
80
+ const variable = renderer . component . var_lookup . get ( name ) ;
81
+ if ( variable && ! variable . hoistable ) dependencies . add ( name ) ;
82
+ } ) ;
77
83
}
78
84
} ) ;
79
85
80
- if ( attribute . dependencies . size > 0 ) {
81
- changes_props . push ( `${ attribute . name } : ${ [ ...attribute . dependencies ] . join ( ' || ' ) } ` ) ;
86
+ const dynamic_dependencies = Array . from ( attribute . dependencies ) . filter ( name => {
87
+ const variable = renderer . component . var_lookup . get ( name ) ;
88
+ return is_dynamic ( variable ) ;
89
+ } ) ;
90
+
91
+ if ( dynamic_dependencies . length > 0 ) {
92
+ changes_props . push ( `${ attribute . name } : ${ dynamic_dependencies . join ( ' || ' ) } ` ) ;
82
93
}
83
94
} ) ;
84
95
85
- const arg = dependencies . size > 0 ? `{ ${ Array . from ( dependencies ) . join ( ', ' ) } }` : '{} ' ;
96
+ const arg = dependencies . size > 0 ? `{ ${ Array . from ( dependencies ) . join ( ', ' ) } }` : '' ;
86
97
87
98
renderer . blocks . push ( deindent `
88
99
const ${ get_slot_changes } = (${ arg } ) => (${ stringify_props ( changes_props ) } );
@@ -149,8 +160,14 @@ export default class SlotWrapper extends Wrapper {
149
160
`@transition_out(${ slot } , #local);`
150
161
) ;
151
162
152
- let update_conditions = [ ...this . dependencies ] . map ( name => `changed.${ name } ` ) . join ( ' || ' ) ;
153
- if ( this . dependencies . size > 1 ) update_conditions = `(${ update_conditions } )` ;
163
+ const dynamic_dependencies = Array . from ( this . dependencies ) . filter ( name => {
164
+ if ( name === '$$scope' ) return true ;
165
+ const variable = renderer . component . var_lookup . get ( name ) ;
166
+ return is_dynamic ( variable ) ;
167
+ } ) ;
168
+
169
+ let update_conditions = dynamic_dependencies . map ( name => `changed.${ name } ` ) . join ( ' || ' ) ;
170
+ if ( dynamic_dependencies . length > 1 ) update_conditions = `(${ update_conditions } )` ;
154
171
155
172
block . builders . update . add_block ( deindent `
156
173
if (${ slot } && ${ slot } .p && ${ update_conditions } ) {
0 commit comments