Skip to content

Commit dcebd46

Browse files
committed
support for style:display|transition with boolean value in SSR
1 parent 9f1400e commit dcebd46

File tree

2 files changed

+10
-0
lines changed
  • packages/svelte/src

2 files changed

+10
-0
lines changed

packages/svelte/src/compiler/phases/3-transform/server/visitors/shared/element.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,9 @@ function build_style_directives(display_directive, style_directives, style_attri
448448
directive.value === true
449449
? b.id(directive.name)
450450
: build_attribute_value(directive.value, context, true);
451+
if (directive.name === 'display' && directive.modifiers.includes('transition')) {
452+
value = b.call('$.get_display', value);
453+
}
451454
if (directive.modifiers.includes('important')) {
452455
value = b.binary('+', value, b.literal(' !important'));
453456
}

packages/svelte/src/internal/server/index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,13 @@ function style_object_to_string(style_object) {
270270
.join(' ');
271271
}
272272

273+
/** @param {string|boolean} value */
274+
export function get_display(value) {
275+
if (value === true) return null;
276+
if (value === false) return 'none';
277+
return value;
278+
}
279+
273280
/** @param {Record<string, string>} style_object */
274281
export function add_styles(style_object) {
275282
const styles = style_object_to_string(style_object);

0 commit comments

Comments
 (0)