@@ -129,20 +129,15 @@ export function set_xlink_attribute(dom, attribute, value) {
129
129
* @param {any } node
130
130
* @param {string } prop
131
131
* @param {any } value
132
- * @param {string } [css_hash]
133
132
*/
134
- export function set_custom_element_data ( node , prop , value , css_hash ) {
133
+ export function set_custom_element_data ( node , prop , value ) {
135
134
if ( prop in node ) {
136
135
var curr_val = node [ prop ] ;
137
136
var next_val = typeof curr_val === 'boolean' && value === '' ? true : value ;
138
137
if ( typeof curr_val !== 'object' || curr_val !== next_val ) {
139
138
node [ prop ] = next_val ;
140
139
}
141
140
} else {
142
- if ( css_hash && css_hash . length !== 0 && prop === 'class' ) {
143
- if ( value ) value += ' ' ;
144
- value += css_hash ;
145
- }
146
141
set_attribute ( node , prop , value ) ;
147
142
}
148
143
}
@@ -158,7 +153,6 @@ export function set_custom_element_data(node, prop, value, css_hash) {
158
153
* @returns {Record<string, any> }
159
154
*/
160
155
export function set_attributes ( element , prev , next , lowercase_attributes , css_hash , skip_warning ) {
161
- var has_hash = css_hash . length !== 0 ;
162
156
var current = prev || { } ;
163
157
var is_option_element = element . tagName === 'OPTION' ;
164
158
@@ -168,8 +162,8 @@ export function set_attributes(element, prev, next, lowercase_attributes, css_ha
168
162
}
169
163
}
170
164
171
- if ( has_hash && ! next . class ) {
172
- next . class = '' ;
165
+ if ( css_hash !== '' ) {
166
+ next . class = next . class ? next . class + ' ' + css_hash : css_hash ;
173
167
}
174
168
175
169
var setters = setters_cache . get ( element . nodeName ) ;
@@ -284,11 +278,6 @@ export function set_attributes(element, prev, next, lowercase_attributes, css_ha
284
278
element [ name ] = value ;
285
279
}
286
280
} else if ( typeof value !== 'function' ) {
287
- if ( has_hash && name === 'class' ) {
288
- if ( value ) value += ' ' ;
289
- value += css_hash ;
290
- }
291
-
292
281
set_attribute ( element , name , value ) ;
293
282
}
294
283
}
@@ -314,18 +303,22 @@ export function set_attributes(element, prev, next, lowercase_attributes, css_ha
314
303
* @param {Element } node
315
304
* @param {Record<string, any> | undefined } prev
316
305
* @param {Record<string, any> } next The new attributes - this function mutates this object
317
- * @param {string } css_hash
306
+ * @param {string } [ css_hash]
318
307
*/
319
- export function set_dynamic_element_attributes ( node , prev , next , css_hash ) {
308
+ export function set_dynamic_element_attributes ( node , prev , next , css_hash = '' ) {
320
309
if ( node . tagName . includes ( '-' ) ) {
321
310
for ( var key in prev ) {
322
311
if ( ! ( key in next ) ) {
323
312
next [ key ] = null ;
324
313
}
325
314
}
326
315
316
+ if ( css_hash !== '' ) {
317
+ next . class = next . class ? next . class + ' ' + css_hash : css_hash ;
318
+ }
319
+
327
320
for ( key in next ) {
328
- set_custom_element_data ( node , key , next [ key ] , css_hash ) ;
321
+ set_custom_element_data ( node , key , next [ key ] ) ;
329
322
}
330
323
331
324
return next ;
0 commit comments