diff --git a/compiler/src/process_ui_syntax.ts b/compiler/src/process_ui_syntax.ts index 72ec22d692fe56ffc17a664da0a2d3d8c9499f3b..878b2b929cff040589d93b546d389bdaa7c4676f 100644 --- a/compiler/src/process_ui_syntax.ts +++ b/compiler/src/process_ui_syntax.ts @@ -736,7 +736,7 @@ export function isAnimateToOrImmediately(node: ts.Node): boolean { export function processResourceData(node: ts.CallExpression, filePath: string, previewLog: {isAcceleratePreview: boolean, log: LogInfo[]} = {isAcceleratePreview: false, log: []}): ts.Node { - if (ts.isStringLiteral(node.arguments[0])) { + if (ts.isStringLiteral(node.arguments[0]) || ts.isNoSubstitutionTemplateLiteral(node.arguments[0])) { const resourceData: string[] = (node.arguments[0] as ts.StringLiteral).text.trim().split('.'); const isResourceModule: boolean = resourceData.length && /^\[.*\]$/g.test(resourceData[0]); if (node.expression.getText() === RESOURCE_RAWFILE) { diff --git a/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForPartialUpdate/resource/resourceTest.js.sample b/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForPartialUpdate/resource/resourceTest.js.sample new file mode 100644 index 0000000000000000000000000000000000000000..f3d898bf4baae425fd65e34408008ec9ea749f7f --- /dev/null +++ b/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForPartialUpdate/resource/resourceTest.js.sample @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2022-2024 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"; +if (!("finalizeConstruction" in ViewPU.prototype)) { + Reflect.set(ViewPU.prototype, "finalizeConstruction", () => { }); +} +class Index extends ViewPU { + constructor(parent, params, __localStorage, elmtId = -1, paramsLambda = undefined, extraInfo) { + super(parent, __localStorage, elmtId, extraInfo); + if (typeof paramsLambda === "function") { + this.paramsGenerator_ = paramsLambda; + } + this.setInitiallyProvidedValue(params); + this.finalizeConstruction(); + } + setInitiallyProvidedValue(params) { + } + updateStateVars(params) { + } + purgeVariableDependenciesOnElmtId(rmElmtId) { + } + aboutToBeDeleted() { + SubscriberManager.Get().delete(this.id__()); + this.aboutToBeDeletedInternal(); + } + initialRender() { + this.observeComponentCreation2((elmtId, isInitialRender) => { + Row.create(); + }, Row); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Image.create({ "id": 0, "type": 30000, params: ['foreground.png'], "bundleName": "com.example.application", "moduleName": "application" }); + }, Image); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Image.create({ "id": 0, "type": 30000, params: [`foreground.png`], "bundleName": "com.example.application", "moduleName": "application" }); + }, Image); + Row.pop(); + } + rerender() { + this.updateDirtyElements(); + } + static getEntryName() { + return "Index"; + } +} +registerNamedRoute(() => new Index(undefined, {}), "", { bundleName: "com.example.application", moduleName: "application", pagePath: "pages/utForPartialUpdate/resource/resourceTest", pageFullPath: "application/entry/src/main/ets/pages/utForPartialUpdate/resource/resourceTest", integratedHsp: "false", moduleType: "followWithHap" }); +//# sourceMappingURL=resourceTest.js.map \ No newline at end of file diff --git a/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForPartialUpdate/resource/resourceTest.ets b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForPartialUpdate/resource/resourceTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..57402fbdbb6f935106626ba60966cc3e3c43df65 --- /dev/null +++ b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForPartialUpdate/resource/resourceTest.ets @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2022-2024 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. + */ +// Reusable test +@Entry +@Component +struct Index { + build() { + Row() { + Image($rawfile('foreground.png')) + Image($rawfile(`foreground.png`)) + } + } +} \ 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 936ccfdc3161dfb66e49640788536a2194773850..14a3de177907a9f06934862fc2792078f98fb85e 100644 --- a/compiler/test/transform_ut/helpers/pathConfig.ts +++ b/compiler/test/transform_ut/helpers/pathConfig.ts @@ -213,6 +213,8 @@ export const UT_PARTIAL_UPFATE_PAGES: string[] = [ 'v2_component_decorator/reusableV2/reusableV2_initialRender', 'v2_component_decorator/reusableV2/reusableV2_members', 'v2_component_decorator/reusableV2/reusableV2_component_nesting', + + 'resource/resourceTest', ]; export const UT_VALIDATE_PAGES_PREVIEW: string[] = [];