File tree Expand file tree Collapse file tree 4 files changed +22
-1
lines changed
tests/runtime-legacy/samples/inline-style-directive-falsy-value Expand file tree Collapse file tree 4 files changed +22
-1
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " svelte " : patch
3
+ ---
4
+
5
+ fix: correctly handle falsy values of style directives in SSR mode
Original file line number Diff line number Diff line change @@ -354,7 +354,7 @@ export function stringify(value) {
354
354
/** @param {Record<string, string> } style_object */
355
355
function style_object_to_string ( style_object ) {
356
356
return Object . keys ( style_object )
357
- . filter ( /** @param {any } key */ ( key ) => style_object [ key ] )
357
+ . filter ( /** @param {any } key */ ( key ) => style_object [ key ] != null && style_object [ key ] !== '' )
358
358
. map ( /** @param {any } key */ ( key ) => `${ key } : ${ escape_html ( style_object [ key ] , true ) } ;` )
359
359
. join ( ' ' ) ;
360
360
}
Original file line number Diff line number Diff line change
1
+ import { test } from '../../test' ;
2
+
3
+ export default test ( {
4
+ html : `
5
+ <p style="--a: 0;"></p>
6
+ <p style="--b: false;"></p>
7
+ <p></p>
8
+ <p></p>
9
+ <p></p>
10
+ `
11
+ } ) ;
Original file line number Diff line number Diff line change
1
+ <p style:--a ={0 }></p >
2
+ <p style:--b ={false }></p >
3
+ <p style:--c =" " ></p >
4
+ <p style:--d ={undefined }></p >
5
+ <p style:--e ={null }></p >
You can’t perform that action at this time.
0 commit comments