diff --git a/packages/designer/src/builtin-simulator/host.ts b/packages/designer/src/builtin-simulator/host.ts index bbcc36fce..49ae0f443 100644 --- a/packages/designer/src/builtin-simulator/host.ts +++ b/packages/designer/src/builtin-simulator/host.ts @@ -291,6 +291,7 @@ export class BuiltinSimulatorHost implements ISimulatorHost { - return `${b / 2}px`; - }).replace(/:root/g, `.${cssClass}`))); + s.appendChild(doc.createTextNode(newStyleStr)); } } + +function stringEquals(str: string, targetStr: string): boolean { + return removeWhitespace(str) === removeWhitespace(targetStr); +} + +function removeWhitespace(str: string = ''): string { + return str.replace(/\s/g, ''); +} + +function transformStyleStr(styleStr: string = '', cssClass: string): string { + return styleStr + .replace(/(\d+)rpx/g, (all, num) => { + return `${num / 2}px`; + }) + .replace(/:root/g, `.${cssClass}`); +}