Skip to content

Commit

Permalink
fix: correctly handle falsy values of style directives in SSR mode (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
dummdidumm authored May 13, 2024
1 parent 72d493a commit 8592914
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/long-owls-eat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: correctly handle falsy values of style directives in SSR mode
2 changes: 1 addition & 1 deletion packages/svelte/src/runtime/internal/ssr.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(' ');
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export default {
html: `
<p style="--a: 0;"></p>
<p style="--b: false;"></p>
<p></p>
<p></p>
<p></p>
`
};
Original file line number Diff line number Diff line change
@@ -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>

0 comments on commit 8592914

Please sign in to comment.