From dd67673be0b97b84d7c355d82776002d19c94e27 Mon Sep 17 00:00:00 2001 From: jiangbo Date: Mon, 11 Jul 2022 21:07:56 +0800 Subject: [PATCH] jiangbo91@huawei.com Fix the error when the statestyles attribute is empty Signed-off-by: jiangbo Change-Id: I84a9207cfec59f5a58c4154c20abc65d792ef6de --- compiler/src/process_component_build.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/compiler/src/process_component_build.ts b/compiler/src/process_component_build.ts index 2da586b..79e6a03 100644 --- a/compiler/src/process_component_build.ts +++ b/compiler/src/process_component_build.ts @@ -1181,7 +1181,9 @@ function traverseStateStylesAttr(temp: any, statements: ts.Statement[], bindComponentAttr(ts.factory.createExpressionStatement( item.initializer.properties[0].initializer), identifierNode, statements, log, false, true); } else { - validateStateStyleSyntax(item, temp, log); + if (!(ts.isObjectLiteralExpression(item.initializer) && item.initializer.properties.length === 0)) { + validateStateStyleSyntax(temp, log); + } } if (item.name) { statements.push(createViewStackProcessor(item, false)); @@ -1367,14 +1369,12 @@ function getComponentType(node: ts.ExpressionStatement, log: LogInfo[], return null; } -export function validateStateStyleSyntax(item: ts.PropertyAssignment, temp: any, log: LogInfo[]): void { - if (!(ts.isObjectLiteralExpression(item.initializer) && item.initializer.properties.length === 0)) { - log.push({ - type: LogType.ERROR, - message: `.stateStyles doesn't conform standard.`, - pos: temp.getStart() - }); - } +export function validateStateStyleSyntax(temp: any, log: LogInfo[]): void { + log.push({ + type: LogType.ERROR, + message: `.stateStyles doesn't conform standard.`, + pos: temp.getStart() + }); } function getEtsComponentExpression(node:ts.ExpressionStatement): ts.EtsComponentExpression {