fix: correctly handle falsy values of style directives in SSR mode (#11584)

fixes #11044
pull/11594/head
Simon H 1 year ago committed by GitHub
parent 72d493aaa5
commit 8592914fdd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: correctly handle falsy values of style directives in SSR mode

@ -193,7 +193,7 @@ export function add_classes(classes) {
/** @returns {string} */
function style_object_to_string(style_object) {
return Object.keys(style_object)
.filter((key) => style_object[key])
.filter((key) => style_object[key] != null && style_object[key] !== '')
.map((key) => `${key}: ${escape_attribute_value(style_object[key])};`)
.join(' ');
}

@ -0,0 +1,9 @@
export default {
html: `
<p style="--a: 0;"></p>
<p style="--b: false;"></p>
<p></p>
<p></p>
<p></p>
`
};

@ -0,0 +1,5 @@
<p style:--a={0}></p>
<p style:--b={false}></p>
<p style:--c=""></p>
<p style:--d={undefined}></p>
<p style:--e={null}></p>
Loading…
Cancel
Save