From 5a8a473c5dce6f1c94e61995db6b1a752bc52577 Mon Sep 17 00:00:00 2001 From: pmurray73 Date: Tue, 26 Jan 2021 20:17:16 -0500 Subject: [PATCH] style-directives: handle spread styles in ssr --- src/runtime/internal/ssr.ts | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/runtime/internal/ssr.ts b/src/runtime/internal/ssr.ts index 73f564d55d..936cb57c30 100644 --- a/src/runtime/internal/ssr.ts +++ b/src/runtime/internal/ssr.ts @@ -6,15 +6,26 @@ export const invalid_attribute_name_character = /[\s'">/=\u{FDD0}-\u{FDEF}\u{FFF // https://html.spec.whatwg.org/multipage/syntax.html#attributes-2 // https://infra.spec.whatwg.org/#noncharacter -export function spread(args, classes_to_add) { +export function spread(args, add) { const attributes = Object.assign({}, ...args); - if (classes_to_add) { - if (attributes.class == null) { - attributes.class = classes_to_add; - } else { - attributes.class += ' ' + classes_to_add; + if (add) { + if (add.classes) { + if (attributes.class == null) { + attributes.class = add.classes; + } else { + attributes.class += ' ' + add.classes; + } + } + + if (add.styles) { + if (attributes.style == null) { + attributes.style = add.styles; + } else { + attributes.style += '; ' + add.styles; + } } } + let str = ''; Object.keys(attributes).forEach(name => {