Skip to content

Commit c723222

Browse files
committed
fix
1 parent c30cf71 commit c723222

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

packages/svelte/src/internal/client/dom/blocks/svelte-html.js

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export function svelte_html(get_attributes) {
1919
/** @type {Record<string, any>} Does _not_ contain event listeners, those are handled separately */
2020
let attributes;
2121

22-
const set_html_attributes = () => {
22+
render_effect(() => {
2323
attributes = get_attributes();
2424

2525
for (const name in attributes) {
@@ -30,29 +30,30 @@ export function svelte_html(get_attributes) {
3030
let value = attributes[name];
3131
current.push({ owner: self, value });
3232

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+
3344
// Defer hydration on initial render during hydration: If there are attribute duplicates, the last value
3445
// wins, so we wait until all values have been set to see if we're actually the last one that sets the value.
3546
if (hydrating) {
3647
effect(() => {
3748
if (current[current.length - 1].owner === self) {
38-
untrack(set_html_attributes);
49+
set();
3950
}
4051
});
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-
}
4952
} else {
50-
set_attribute(node, name, value);
53+
set();
5154
}
5255
}
53-
};
54-
55-
render_effect(set_html_attributes);
56+
});
5657

5758
teardown(() => {
5859
for (const name in attributes) {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy