From eba331af8b648d440bbb0b978361251c61210dc7 Mon Sep 17 00:00:00 2001 From: zhouyan Date: Thu, 21 Nov 2024 10:39:00 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0Span=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E9=80=9A=E7=94=A8=E5=B1=9E=E6=80=A7=E4=B8=8D=E7=94=9F=E6=95=88?= =?UTF-8?q?=E5=91=8A=E8=AD=A6=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhouyan Change-Id: Ib24722f8e56e544d5dfe5a658c19a5fb0253d096 --- compiler/src/pre_define.ts | 1 + compiler/src/process_component_build.ts | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/compiler/src/pre_define.ts b/compiler/src/pre_define.ts index 1e8aeabc..938390ef 100644 --- a/compiler/src/pre_define.ts +++ b/compiler/src/pre_define.ts @@ -603,3 +603,4 @@ export const ARKTS_MODULE_PREFIX: string = '@arkts'; export const ARKTS_MODULE_NAME: string = 'arkts'; export const COLD_RELOAD_MODE: string = 'coldReload'; export const INTEGRATED_HSP: string = 'integratedHsp'; +export const SpanComponents: string[] = ['Span']; \ No newline at end of file diff --git a/compiler/src/process_component_build.ts b/compiler/src/process_component_build.ts index e5eeee50..80563208 100644 --- a/compiler/src/process_component_build.ts +++ b/compiler/src/process_component_build.ts @@ -137,7 +137,8 @@ import { NAVIGATION, CREATE_ROUTER_COMPONENT_COLLECT, NAV_PATH_STACK, - IS_USER_CREATE_STACK + IS_USER_CREATE_STACK, + SpanComponents } from './pre_define'; import { INNER_COMPONENT_NAMES, @@ -2145,6 +2146,7 @@ export function bindComponentAttr(node: ts.ExpressionStatement, identifierNode: } while (temp && ts.isCallExpression(temp) && temp.expression) { let flag: boolean = false; + validatePropertyAccessExpressionOnSpanComponent(temp.expression, identifierNode, log); if (temp.expression && (validatePropertyAccessExpressionWithCustomBuilder(temp.expression) || validateIdentifierWithCustomBuilder(temp.expression))) { let propertyName: string = ''; @@ -2589,6 +2591,17 @@ function validateIdentifierWithCustomBuilder(node: ts.Node): boolean { return ts.isIdentifier(node) && CUSTOM_BUILDER_PROPERTIES.has(node.escapedText.toString()); } +function validatePropertyAccessExpressionOnSpanComponent(node: ts.Node, identifierNode: ts.Identifier, log: LogInfo[]): void { + if (SpanComponents.includes(identifierNode.escapedText.toString()) && ts.isPropertyAccessExpression(node) && node.name && + ts.isIdentifier(node.name) && BUILDIN_STYLE_NAMES.has(node.name.escapedText.toString())) { + log.push({ + type: LogType.WARN, + message: `Property '${node.name.escapedText.toString()}' does not take effect on '${identifierNode.escapedText.toString()}'.`, + pos: node.getStart() + }); + } +} + function createArrowFunctionForDollar($$varExp: ts.Expression): ts.ArrowFunction { return ts.factory.createArrowFunction( undefined, undefined,