fix: correctly SSR hidden="until-found" (#16773)

main
7nik 22 hours ago committed by GitHub
parent 8b4e1fcb7a
commit 8b106b94f4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: correctly SSR hidden="until-found"

@ -23,6 +23,10 @@ const replacements = {
*/ */
export function attr(name, value, is_boolean = false) { export function attr(name, value, is_boolean = false) {
if (value == null || (!value && is_boolean)) return ''; if (value == null || (!value && is_boolean)) return '';
// attribute hidden for values other than "until-found" behaves like a boolean attribute
if (name === 'hidden' && value !== 'until-found') {
is_boolean = true;
}
const normalized = (name in replacements && replacements[name].get(value)) || value; const normalized = (name in replacements && replacements[name].get(value)) || value;
const assignment = is_boolean ? '' : `="${escape_html(normalized, true)}"`; const assignment = is_boolean ? '' : `="${escape_html(normalized, true)}"`;
return ` ${name}${assignment}`; return ` ${name}${assignment}`;

@ -154,7 +154,6 @@ const DOM_BOOLEAN_ATTRIBUTES = [
'default', 'default',
'disabled', 'disabled',
'formnovalidate', 'formnovalidate',
'hidden',
'indeterminate', 'indeterminate',
'inert', 'inert',
'ismap', 'ismap',

@ -0,0 +1 @@
<!--[--><div>A</div><div hidden>B</div><div hidden="until-found">C</div><!--]-->

@ -0,0 +1,3 @@
<div {...{ hidden: false }}>A</div>
<div {...{ hidden: true }}>B</div>
<div {...{ hidden: 'until-found' }}>C</div>
Loading…
Cancel
Save