From 0d865dcef71d6840a2a7984eeefa3936d31d79a4 Mon Sep 17 00:00:00 2001 From: yuche Date: Tue, 30 Jul 2019 11:12:17 +0800 Subject: [PATCH] =?UTF-8?q?refactor(transformer):=20=E9=99=A4=E4=BA=86=20d?= =?UTF-8?q?iv=20=E5=92=8C=20text=20=E4=B9=8B=E5=A4=96=E7=9A=84=E6=89=80?= =?UTF-8?q?=E6=9C=89=E5=BF=AB=E5=BA=94=E7=94=A8=E7=BB=84=E4=BB=B6:=20style?= =?UTF-8?q?=20->=20customstyle?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/taro-transformer-wx/src/create-html-element.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/taro-transformer-wx/src/create-html-element.ts b/packages/taro-transformer-wx/src/create-html-element.ts index 397d17f390a1..cc6b176b1488 100644 --- a/packages/taro-transformer-wx/src/create-html-element.ts +++ b/packages/taro-transformer-wx/src/create-html-element.ts @@ -21,7 +21,7 @@ interface Options { value: string } -function stringifyAttributes (input: object) { +function stringifyAttributes (input: object, componentName: string) { const attributes: string[] = [] for (const key of Object.keys(input)) { @@ -37,6 +37,10 @@ function stringifyAttributes (input: object) { let attribute = key + if (Adapters.quickapp === Adapter.type && !['div', 'text'].includes(componentName) && key === 'style') { + attribute = 'customstyle' + } + if (value !== true) { attribute += `="${String(value)}"` } @@ -78,7 +82,7 @@ export const createHTMLElement = (options: Options, isFirstEmit = false) => { const isVoidTag = voidHtmlTags.has(options.name) - let ret = `<${options.name}${stringifyAttributes(options.attributes)}${isVoidTag ? `/` : '' }>` + let ret = `<${options.name}${stringifyAttributes(options.attributes, options.name)}${isVoidTag ? `/` : '' }>` if (!isVoidTag) { ret += `${options.value}`