@@ -19,7 +19,7 @@ export function svelte_html(get_attributes) {
19
19
/** @type {Record<string, any> } Does _not_ contain event listeners, those are handled separately */
20
20
let attributes ;
21
21
22
- const set_html_attributes = ( ) => {
22
+ render_effect ( ( ) => {
23
23
attributes = get_attributes ( ) ;
24
24
25
25
for ( const name in attributes ) {
@@ -30,29 +30,30 @@ export function svelte_html(get_attributes) {
30
30
let value = attributes [ name ] ;
31
31
current . push ( { owner : self , value } ) ;
32
32
33
+ const set = ( ) => {
34
+ if ( name === 'class' ) {
35
+ // Avoid unrelated attribute changes from triggering class changes
36
+ if ( old !== value ) {
37
+ set_class ( node , current_setters [ name ] . map ( ( e ) => e . value ) . join ( ' ' ) ) ;
38
+ }
39
+ } else {
40
+ set_attribute ( node , name , value ) ;
41
+ }
42
+ } ;
43
+
33
44
// Defer hydration on initial render during hydration: If there are attribute duplicates, the last value
34
45
// wins, so we wait until all values have been set to see if we're actually the last one that sets the value.
35
46
if ( hydrating ) {
36
47
effect ( ( ) => {
37
48
if ( current [ current . length - 1 ] . owner === self ) {
38
- untrack ( set_html_attributes ) ;
49
+ set ( ) ;
39
50
}
40
51
} ) ;
41
- return ;
42
- }
43
-
44
- if ( name === 'class' ) {
45
- // Avoid unrelated attribute changes from triggering class changes
46
- if ( old !== value ) {
47
- set_class ( node , current_setters [ name ] . map ( ( e ) => e . value ) . join ( ' ' ) ) ;
48
- }
49
52
} else {
50
- set_attribute ( node , name , value ) ;
53
+ set ( ) ;
51
54
}
52
55
}
53
- } ;
54
-
55
- render_effect ( set_html_attributes ) ;
56
+ } ) ;
56
57
57
58
teardown ( ( ) => {
58
59
for ( const name in attributes ) {
0 commit comments