Skip to content

Commit e4800e0

Browse files
authored
fix(engine-server): dynamic style generation (salesforce#1944)
1 parent 24a6920 commit e4800e0

File tree

2 files changed

+18
-6
lines changed
  • packages/@lwc/engine-server/src

2 files changed

+18
-6
lines changed

packages/@lwc/engine-server/src/__tests__/fixtures/attribute-dynamic/.skip

Whitespace-only changes.

packages/@lwc/engine-server/src/renderer.ts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -173,14 +173,22 @@ export const renderer: Renderer<HostNode, HostElement> = {
173173
return new Proxy(
174174
{},
175175
{
176-
get(target, property) {
176+
get(target, property): string {
177+
let value: string;
178+
177179
const styleAttribute = getStyleAttribute();
178180
if (isUndefined(styleAttribute)) {
179181
return '';
180182
}
181183

182-
const cssDeclaration = styleTextToCssDeclaration(styleAttribute.value);
183-
return cssDeclaration[property as string] || '';
184+
if (property === 'cssText') {
185+
value = styleAttribute.value;
186+
} else {
187+
const cssDeclaration = styleTextToCssDeclaration(styleAttribute.value);
188+
value = cssDeclaration[property as string] || '';
189+
}
190+
191+
return value;
184192
},
185193
set(target, property, value) {
186194
let styleAttribute = getStyleAttribute();
@@ -194,9 +202,13 @@ export const renderer: Renderer<HostNode, HostElement> = {
194202
element.attributes.push(styleAttribute);
195203
}
196204

197-
const cssDeclaration = styleTextToCssDeclaration(styleAttribute.value);
198-
cssDeclaration[property as string] = value;
199-
styleAttribute.value = cssDeclarationToStyleText(cssDeclaration);
205+
if (property === 'cssText') {
206+
styleAttribute.value = value;
207+
} else {
208+
const cssDeclaration = styleTextToCssDeclaration(styleAttribute.value);
209+
cssDeclaration[property as string] = value;
210+
styleAttribute.value = cssDeclarationToStyleText(cssDeclaration);
211+
}
200212

201213
return value;
202214
},

0 commit comments

Comments
 (0)