@@ -25,27 +25,26 @@ export function build_style_directives(
25
25
const state = context . state ;
26
26
27
27
for ( const directive of style_directives ) {
28
+ const { has_state, has_call } = directive . metadata . expression ;
29
+
28
30
let value =
29
31
directive . value === true
30
32
? build_getter ( { name : directive . name , type : 'Identifier' } , context . state )
31
33
: build_attribute_value ( directive . value , context ) . value ;
32
- const { has_state, has_call } = directive . metadata . expression ;
33
-
34
- let final_value = value ;
35
34
36
35
if ( has_call ) {
37
36
const id = b . id ( state . scope . generate ( 'style_directive' ) ) ;
38
37
39
38
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 ) ;
41
40
}
42
41
43
42
const update = b . stmt (
44
43
b . call (
45
44
'$.set_style' ,
46
45
element_id ,
47
46
b . literal ( directive . name ) ,
48
- final_value ,
47
+ value ,
49
48
/** @type {Expression } */ ( directive . modifiers . includes ( 'important' ) ? b . true : undefined ) ,
50
49
force_check ? b . true : undefined
51
50
)
@@ -77,21 +76,17 @@ export function build_class_directives(
77
76
) {
78
77
const state = context . state ;
79
78
for ( const directive of class_directives ) {
80
- const value = /** @type {Expression } */ ( context . visit ( directive . expression ) ) ;
81
79
const { has_state, has_call } = directive . metadata . expression ;
82
-
83
- let final_value = value ;
80
+ let value = /** @type {Expression } */ ( context . visit ( directive . expression ) ) ;
84
81
85
82
if ( has_call ) {
86
83
const id = b . id ( state . scope . generate ( 'class_directive' ) ) ;
87
84
88
85
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 ) ;
90
87
}
91
88
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 ) ) ;
95
90
96
91
if ( ! is_attributes_reactive && has_call ) {
97
92
state . init . push ( build_update ( update ) ) ;
0 commit comments