Skip to content

Commit 8b106b9

Browse files
authored
fix: correctly SSR hidden="until-found" (#16773)
1 parent 8b4e1fc commit 8b106b9

File tree

5 files changed

+13
-1
lines changed

5 files changed

+13
-1
lines changed

.changeset/pink-gifts-sell.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: correctly SSR hidden="until-found"

packages/svelte/src/internal/shared/attributes.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ const replacements = {
2323
*/
2424
export function attr(name, value, is_boolean = false) {
2525
if (value == null || (!value && is_boolean)) return '';
26+
// attribute hidden for values other than "until-found" behaves like a boolean attribute
27+
if (name === 'hidden' && value !== 'until-found') {
28+
is_boolean = true;
29+
}
2630
const normalized = (name in replacements && replacements[name].get(value)) || value;
2731
const assignment = is_boolean ? '' : `="${escape_html(normalized, true)}"`;
2832
return ` ${name}${assignment}`;

packages/svelte/src/utils.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,6 @@ const DOM_BOOLEAN_ATTRIBUTES = [
154154
'default',
155155
'disabled',
156156
'formnovalidate',
157-
'hidden',
158157
'indeterminate',
159158
'inert',
160159
'ismap',
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<!--[--><div>A</div><div hidden>B</div><div hidden="until-found">C</div><!--]-->
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<div {...{ hidden: false }}>A</div>
2+
<div {...{ hidden: true }}>B</div>
3+
<div {...{ hidden: 'until-found' }}>C</div>

0 commit comments

Comments
 (0)