Skip to content

Commit

Permalink
fix: hydrate href that is part of spread attributes (#15226)
Browse files Browse the repository at this point in the history
We had some duplicated and buggy code, removing it fixes #15120
  • Loading branch information
dummdidumm authored Feb 6, 2025
1 parent f2c83e5 commit 4883fd2
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/wicked-apes-sin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: hydrate `href` that is part of spread attributes
Original file line number Diff line number Diff line change
Expand Up @@ -419,11 +419,7 @@ export function set_attributes(
// @ts-ignore
element[name] = value;
} else if (typeof value !== 'function') {
if (hydrating && (name === 'src' || name === 'href' || name === 'srcset')) {
if (!skip_warning) check_src_in_dev_hydration(element, name, value ?? '');
} else {
set_attribute(element, name, value);
}
set_attribute(element, name, value);
}
}
if (key === 'style' && '__styles' in element) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!--[--><a href="/foo">foo</a><!--]-->
<!--[--><a href="/foo">foo</a> <a href="/foo">foo</a><!--]-->
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
</script>

<a href={browser ? '/foo' : '/bar'}>foo</a>
<a {...{href: browser ? '/foo' : '/bar'}}>foo</a>

0 comments on commit 4883fd2

Please # to comment.