fix: correctly SSR hidden="until-found"

fix-16750
7nik 6 hours ago
parent 8b4e1fcb7a
commit f835a57209

@ -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) {
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 assignment = is_boolean ? '' : `="${escape_html(normalized, true)}"`;
return ` ${name}${assignment}`;

@ -154,7 +154,6 @@ const DOM_BOOLEAN_ATTRIBUTES = [
'default',
'disabled',
'formnovalidate',
'hidden',
'indeterminate',
'inert',
'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