From ad6995c3a2f789e2c66ec6d66c6a8867d5f2e26f Mon Sep 17 00:00:00 2001 From: puyajun Date: Thu, 10 Feb 2022 17:14:25 +0800 Subject: [PATCH] puyajun@huawi.com Signed-off-by: puyajun Change-Id: I968862fa7dc0f5771581a1b4f79766072298dc82 --- compiler/src/process_component_build.ts | 12 ++++++++++-- compiler/src/process_component_class.ts | 9 ++++----- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/compiler/src/process_component_build.ts b/compiler/src/process_component_build.ts index c66da1729..63bf1f4d2 100644 --- a/compiler/src/process_component_build.ts +++ b/compiler/src/process_component_build.ts @@ -555,8 +555,7 @@ export function bindComponentAttr(node: ts.ExpressionStatement, identifierNode: function processCustomBuilderProperty(node: ts.CallExpression): ts.CallExpression { const newArguments: ts.Expression[] = []; node.arguments.forEach((argument: ts.Expression | ts.Identifier, index: number) => { - if (index === 0 && (ts.isPropertyAccessExpression(argument) || ts.isCallExpression(argument) || - ts.isIdentifier(argument))) { + if (index === 0 && isBuilderChangeNode(argument)) { newArguments.push(parseBuilderNode(argument)); } else { newArguments.push(argument); @@ -566,6 +565,15 @@ function processCustomBuilderProperty(node: ts.CallExpression): ts.CallExpressio return node; } +function isBuilderChangeNode(argument: ts.Node): boolean { + return (ts.isPropertyAccessExpression(argument) && argument.name && ts.isIdentifier(argument.name) + && CUSTOM_BUILDER_METHOD.has(argument.name.getText())) || + (ts.isCallExpression(argument) && argument.expression && argument.expression.name && + ts.isIdentifier(argument.expression.name) && + CUSTOM_BUILDER_METHOD.has(argument.expression.name.getText())) || (ts.isIdentifier(argument) && + argument.escapedText && CUSTOM_BUILDER_METHOD.has(argument.escapedText.toString())); +} + function parseBuilderNode(node: ts.Node): ts.ObjectLiteralExpression { if (isPropertyAccessExpressionNode(node)) { return processPropertyBuilder(node as ts.PropertyAccessExpression); diff --git a/compiler/src/process_component_class.ts b/compiler/src/process_component_class.ts index 1732d6c3a..09bc1d9a1 100644 --- a/compiler/src/process_component_class.ts +++ b/compiler/src/process_component_class.ts @@ -50,8 +50,7 @@ import { COMPONENT_STYLES_DECORATOR, STYLES, INTERFACE_NAME_SUFFIX, - OBSERVED_PROPERTY_ABSTRACT, - CUSTOM_COMPONENT_EARLIER_CREATE_CHILD + OBSERVED_PROPERTY_ABSTRACT } from './pre_define'; import { BUILDIN_STYLE_NAMES, @@ -481,9 +480,9 @@ function createParamsInitBlock(express: string, statements: ts.Statement[], express === COMPONENT_CONSTRUCTOR_DELETE_PARAMS ? undefined : ts.factory.createIdentifier(CREATE_CONSTRUCTOR_PARAMS), undefined, express === COMPONENT_CONSTRUCTOR_DELETE_PARAMS ? undefined : - ts.factory.createTypeReferenceNode( - ts.factory.createIdentifier(parentComponentName.getText() + INTERFACE_NAME_SUFFIX), undefined), - undefined)], undefined, ts.factory.createBlock(statements, true)); + ts.factory.createTypeReferenceNode( + ts.factory.createIdentifier(parentComponentName.getText() + INTERFACE_NAME_SUFFIX), + undefined), undefined)], undefined, ts.factory.createBlock(statements, true)); return methodDeclaration; } -- Gitee