From 9645337b41b30a23d939db53671e3a50779fbdd0 Mon Sep 17 00:00:00 2001 From: Bojiang Date: Mon, 26 May 2025 15:16:13 +0800 Subject: [PATCH] jiangbo91@huawei.com MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix 三目运算符编译源码报错 Signed-off-by: Bojiang Change-Id: I95c0e046accf60b894ae2c2e53bb56465c5dac2b --- compiler/src/process_component_build.ts | 3 +- .../attrs/bindSheet.js.sample | 69 +++++++++++++++++++ .../attrs/bindSheet.ets | 33 +++++++++ .../test/transform_ut/helpers/pathConfig.ts | 1 + 4 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForPartialUpdate/inner_component_transform/attrs/bindSheet.js.sample create mode 100644 compiler/test/transform_ut/application/entry/src/main/ets/pages/utForPartialUpdate/inner_component_transform/attrs/bindSheet.ets diff --git a/compiler/src/process_component_build.ts b/compiler/src/process_component_build.ts index 1a9dac174..847086d48 100644 --- a/compiler/src/process_component_build.ts +++ b/compiler/src/process_component_build.ts @@ -2542,7 +2542,8 @@ function processConditionalBuilder(initializer: ts.ConditionalExpression, identi if (isBuilderChangeNode(initializer.whenFalse, identifierNode, propertyName)) { whenFalse = parseBuilderNode(initializer.whenFalse, propertyName); } - return ts.factory.createConditionalExpression( + return ts.factory.updateConditionalExpression( + initializer, initializer.condition, initializer.questionToken, whenTrue, diff --git a/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForPartialUpdate/inner_component_transform/attrs/bindSheet.js.sample b/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForPartialUpdate/inner_component_transform/attrs/bindSheet.js.sample new file mode 100644 index 000000000..146ca3c8a --- /dev/null +++ b/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForPartialUpdate/inner_component_transform/attrs/bindSheet.js.sample @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +"use strict"; +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { +var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; +if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); +else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; +return c > 3 && r && Object.defineProperty(target, key, r), r; +}; + +if (!("finalizeConstruction" in ViewPU.prototype)) { + Reflect.set(ViewPU.prototype, "finalizeConstruction", () => { }); +} +class BottomSheet extends ViewV2 { + constructor(parent, params, __localStorage, elmtId = -1, paramsLambda, extraInfo) { + super(parent, elmtId, extraInfo); + this.initParam("title", (params && "title" in params) ? params.title : undefined); + this.finalizeConstruction(); + } + resetStateVarsOnReuse(params) { + this.resetParam("title", (params && "title" in params) ? params.title : undefined); + } + sheetBuilder(parent = null) { + } + initialRender() { + this.observeComponentCreation2((elmtId, isInitialRender) => { + Row.create(); + }, Row); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Blank.create(); + Blank.bindSheet(this.title ? true : false, { builder: () => { + this.sheetBuilder.call(this); + } }, {}); + }, Blank); + Blank.pop(); + Row.pop(); + } + updateStateVars(params) { + if (params === undefined) { + return; + } + if ("title" in params) { + this.updateParam("title", params.title); + } + } + rerender() { + this.updateDirtyElements(); + } + static getEntryName() { + return "BottomSheet"; + } +} +__decorate([ + Param +], BottomSheet.prototype, "title", void 0); +registerNamedRoute(() => new BottomSheet(undefined, {}), "", { bundleName: "com.example.application", moduleName: "application", pagePath: "pages/utForPartialUpdate/inner_component_transform/attrs/bindSheet", pageFullPath: "application/entry/src/main/ets/pages/utForPartialUpdate/inner_component_transform/attrs/bindSheet", integratedHsp: "false", moduleType: "followWithHap" }); +//# sourceMappingURL=bindSheet.js.map \ No newline at end of file diff --git a/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForPartialUpdate/inner_component_transform/attrs/bindSheet.ets b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForPartialUpdate/inner_component_transform/attrs/bindSheet.ets new file mode 100644 index 000000000..b99e3b42b --- /dev/null +++ b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForPartialUpdate/inner_component_transform/attrs/bindSheet.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Entry +@ComponentV2 +struct BottomSheet { + @Param @Require title?:ResourceStr; + @Builder sheetBuilder() { + + } + build() { + Row() { + Blank() + .bindSheet( + this.title? true: false, + this.sheetBuilder(), + {} + ) + } + } +} \ No newline at end of file diff --git a/compiler/test/transform_ut/helpers/pathConfig.ts b/compiler/test/transform_ut/helpers/pathConfig.ts index 3c41b1341..b12b5d80f 100644 --- a/compiler/test/transform_ut/helpers/pathConfig.ts +++ b/compiler/test/transform_ut/helpers/pathConfig.ts @@ -88,6 +88,7 @@ export const UT_PARTIAL_UPFATE_PAGES: string[] = [ 'inner_component_transform/$$_component/$$_componentCheck7', 'inner_component_transform/$$_component/$$_componentCheck8', 'inner_component_transform/$$_component/$$_componentCheck9', + 'inner_component_transform/attrs/bindSheet', 'inner_component_transform/$$_component/$$_if_elseIf_else', 'inner_component_transform/custom_component/component_object', 'inner_component_transform/custom_component/custom_component', -- Gitee