@@ -90,10 +90,17 @@ export function SvelteElement(node, context) {
90
90
) ;
91
91
}
92
92
} else {
93
+ const attributes_id = b . id ( context . state . scope . generate ( 'attributes' ) ) ;
94
+
93
95
// Always use spread because we don't know whether the element is a custom element or not,
94
96
// therefore we need to do the "how to set an attribute" logic at runtime.
95
- is_attributes_reactive =
96
- build_dynamic_element_attributes ( node , attributes , inner_context , element_id ) !== null ;
97
+ is_attributes_reactive = build_dynamic_element_attributes (
98
+ node ,
99
+ attributes ,
100
+ inner_context ,
101
+ element_id ,
102
+ attributes_id
103
+ ) ;
97
104
}
98
105
99
106
// class/style directives must be applied last since they could override class/style attributes
@@ -151,9 +158,10 @@ export function SvelteElement(node, context) {
151
158
* @param {Array<AST.Attribute | AST.SpreadAttribute> } attributes
152
159
* @param {ComponentContext } context
153
160
* @param {Identifier } element_id
161
+ * @param {Identifier } attributes_id
154
162
* @returns {boolean }
155
163
*/
156
- function build_dynamic_element_attributes ( element , attributes , context , element_id ) {
164
+ function build_dynamic_element_attributes ( element , attributes , context , element_id , attributes_id ) {
157
165
let needs_isolation = false ;
158
166
let is_reactive = false ;
159
167
@@ -189,17 +197,16 @@ function build_dynamic_element_attributes(element, attributes, context, element_
189
197
}
190
198
191
199
if ( is_reactive ) {
192
- const id = b . id ( context . state . scope . generate ( 'attributes' ) ) ;
193
- context . state . init . push ( b . let ( id ) ) ;
200
+ context . state . init . push ( b . let ( attributes_id ) ) ;
194
201
195
202
const update = b . stmt (
196
203
b . assignment (
197
204
'=' ,
198
- id ,
205
+ attributes_id ,
199
206
b . call (
200
207
'$.set_attributes' ,
201
208
element_id ,
202
- id ,
209
+ attributes_id ,
203
210
b . object ( values ) ,
204
211
context . state . analysis . css . hash !== '' && b . literal ( context . state . analysis . css . hash ) ,
205
212
b . binary ( '!==' , b . member ( element_id , 'namespaceURI' ) , b . id ( '$.NAMESPACE_SVG' ) ) ,
0 commit comments