@@ -25,27 +25,26 @@ export function build_style_directives(
2525 const state = context . state ;
2626
2727 for ( const directive of style_directives ) {
28+ const { has_state, has_call } = directive . metadata . expression ;
29+
2830 let value =
2931 directive . value === true
3032 ? build_getter ( { name : directive . name , type : 'Identifier' } , context . state )
3133 : build_attribute_value ( directive . value , context ) . value ;
32- const { has_state, has_call } = directive . metadata . expression ;
33-
34- let final_value = value ;
3534
3635 if ( has_call ) {
3736 const id = b . id ( state . scope . generate ( 'style_directive' ) ) ;
3837
3938 state . init . push ( b . const ( id , create_derived ( state , b . thunk ( value ) ) ) ) ;
40- final_value = b . call ( '$.get' , id ) ;
39+ value = b . call ( '$.get' , id ) ;
4140 }
4241
4342 const update = b . stmt (
4443 b . call (
4544 '$.set_style' ,
4645 element_id ,
4746 b . literal ( directive . name ) ,
48- final_value ,
47+ value ,
4948 /** @type {Expression } */ ( directive . modifiers . includes ( 'important' ) ? b . true : undefined ) ,
5049 force_check ? b . true : undefined
5150 )
@@ -77,21 +76,17 @@ export function build_class_directives(
7776) {
7877 const state = context . state ;
7978 for ( const directive of class_directives ) {
80- const value = /** @type {Expression } */ ( context . visit ( directive . expression ) ) ;
8179 const { has_state, has_call } = directive . metadata . expression ;
82-
83- let final_value = value ;
80+ let value = /** @type {Expression } */ ( context . visit ( directive . expression ) ) ;
8481
8582 if ( has_call ) {
8683 const id = b . id ( state . scope . generate ( 'class_directive' ) ) ;
8784
8885 state . init . push ( b . const ( id , create_derived ( state , b . thunk ( value ) ) ) ) ;
89- final_value = b . call ( '$.get' , id ) ;
86+ value = b . call ( '$.get' , id ) ;
9087 }
9188
92- const update = b . stmt (
93- b . call ( '$.toggle_class' , element_id , b . literal ( directive . name ) , final_value )
94- ) ;
89+ const update = b . stmt ( b . call ( '$.toggle_class' , element_id , b . literal ( directive . name ) , value ) ) ;
9590
9691 if ( ! is_attributes_reactive && has_call ) {
9792 state . init . push ( build_update ( update ) ) ;
0 commit comments