File tree Expand file tree Collapse file tree 1 file changed +9
-9
lines changed
packages/svelte/src/compiler/phases/3-transform/client/visitors/shared Expand file tree Collapse file tree 1 file changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ export function build_set_attributes(
27
27
is_custom_element
28
28
) {
29
29
let needs_isolation = false ;
30
- let is_reactive = false ;
30
+ let has_state = false ;
31
31
32
32
/** @type {ObjectExpression['properties'] } */
33
33
const values = [ ] ;
@@ -47,30 +47,30 @@ export function build_set_attributes(
47
47
} else {
48
48
values . push ( b . init ( attribute . name , value ) ) ;
49
49
}
50
+
51
+ has_state ||= attribute . metadata . expression . has_state ;
50
52
} else {
51
53
values . push ( b . spread ( /** @type {Expression } */ ( context . visit ( attribute ) ) ) ) ;
52
- }
53
54
54
- is_reactive ||=
55
- attribute . metadata . expression . has_state ||
56
55
// objects could contain reactive getters -> play it safe and always assume spread attributes are reactive
57
- attribute . type === 'SpreadAttribute' ;
58
- needs_isolation ||=
59
- attribute . type === 'SpreadAttribute' && attribute . metadata . expression . has_call ;
56
+ has_state = true ;
57
+
58
+ needs_isolation ||= attribute . metadata . expression . has_call ;
59
+ }
60
60
}
61
61
62
62
const call = b . call (
63
63
'$.set_attributes' ,
64
64
element_id ,
65
- is_reactive ? attributes_id : b . literal ( null ) ,
65
+ has_state ? attributes_id : b . literal ( null ) ,
66
66
b . object ( values ) ,
67
67
context . state . analysis . css . hash !== '' && b . literal ( context . state . analysis . css . hash ) ,
68
68
preserve_attribute_case ,
69
69
is_custom_element ,
70
70
is_ignored ( element , 'hydration_attribute_changed' ) && b . true
71
71
) ;
72
72
73
- if ( is_reactive ) {
73
+ if ( has_state ) {
74
74
context . state . init . push ( b . let ( attributes_id ) ) ;
75
75
76
76
const update = b . stmt ( b . assignment ( '=' , attributes_id , call ) ) ;
You can’t perform that action at this time.
0 commit comments