fix builder bug

Signed-off-by: puyajun <puyajun@huawei.com>
Change-Id: I12282fdcc6429ca43081c3565e8406f3cbb93d14
This commit is contained in:
puyajun
2022-02-11 11:57:23 +08:00
parent d17d764f28
commit 485437a3f7
2 changed files with 11 additions and 4 deletions
+10 -2
View File
@@ -557,8 +557,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);
@@ -568,6 +567,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);
+1 -2
View File
@@ -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,