@@ -83,8 +83,15 @@ function get_attribute_name(element, attribute, context) {
83
83
* @param {Identifier } element_id
84
84
* @param {ComponentContext } context
85
85
* @param {boolean } is_attributes_reactive
86
+ * @param {boolean } force_check Should be `true` if we can't rely on our cached value, because for example there's also a `style` attribute
86
87
*/
87
- function serialize_style_directives ( style_directives , element_id , context , is_attributes_reactive ) {
88
+ function serialize_style_directives (
89
+ style_directives ,
90
+ element_id ,
91
+ context ,
92
+ is_attributes_reactive ,
93
+ force_check
94
+ ) {
88
95
const state = context . state ;
89
96
90
97
for ( const directive of style_directives ) {
@@ -99,7 +106,8 @@ function serialize_style_directives(style_directives, element_id, context, is_at
99
106
element_id ,
100
107
b . literal ( directive . name ) ,
101
108
value ,
102
- /** @type {Expression } */ ( directive . modifiers . includes ( 'important' ) ? b . true : undefined )
109
+ /** @type {Expression } */ ( directive . modifiers . includes ( 'important' ) ? b . true : undefined ) ,
110
+ force_check ? b . true : undefined
103
111
)
104
112
) ;
105
113
@@ -2029,6 +2037,7 @@ export const template_visitors = {
2029
2037
let img_might_be_lazy = false ;
2030
2038
let might_need_event_replaying = false ;
2031
2039
let has_direction_attribute = false ;
2040
+ let has_style_attribute = false ;
2032
2041
2033
2042
if ( is_custom_element ) {
2034
2043
// cloneNode is faster, but it does not instantiate the underlying class of the
@@ -2047,6 +2056,9 @@ export const template_visitors = {
2047
2056
if ( attribute . name === 'dir' ) {
2048
2057
has_direction_attribute = true ;
2049
2058
}
2059
+ if ( attribute . name === 'style' ) {
2060
+ has_style_attribute = true ;
2061
+ }
2050
2062
if (
2051
2063
( attribute . name === 'value' || attribute . name === 'checked' ) &&
2052
2064
! is_text_attribute ( attribute )
@@ -2196,7 +2208,13 @@ export const template_visitors = {
2196
2208
2197
2209
// class/style directives must be applied last since they could override class/style attributes
2198
2210
serialize_class_directives ( class_directives , node_id , context , is_attributes_reactive ) ;
2199
- serialize_style_directives ( style_directives , node_id , context , is_attributes_reactive ) ;
2211
+ serialize_style_directives (
2212
+ style_directives ,
2213
+ node_id ,
2214
+ context ,
2215
+ is_attributes_reactive ,
2216
+ has_style_attribute || node . metadata . has_spread
2217
+ ) ;
2200
2218
2201
2219
if ( might_need_event_replaying ) {
2202
2220
context . state . after_update . push ( b . stmt ( b . call ( '$.replay_events' , node_id ) ) ) ;
@@ -2357,7 +2375,13 @@ export const template_visitors = {
2357
2375
2358
2376
// class/style directives must be applied last since they could override class/style attributes
2359
2377
serialize_class_directives ( class_directives , element_id , inner_context , is_attributes_reactive ) ;
2360
- serialize_style_directives ( style_directives , element_id , inner_context , is_attributes_reactive ) ;
2378
+ serialize_style_directives (
2379
+ style_directives ,
2380
+ element_id ,
2381
+ inner_context ,
2382
+ is_attributes_reactive ,
2383
+ true
2384
+ ) ;
2361
2385
2362
2386
const get_tag = b . thunk ( /** @type {Expression } */ ( context . visit ( node . tag ) ) ) ;
2363
2387
0 commit comments