mirror of
https://gitee.com/openharmony/developtools_ace_ets2bundle
synced 2024-12-04 23:37:22 +00:00
fix @Reusable error Signed-off-by: BoJiang <jiangbo91@huawei.com> Change-Id: Ibc3ed81f288298a4a7914946e8a02678c16fa5d0
This commit is contained in:
parent
a5c89c6ac7
commit
547dcef805
@ -873,7 +873,8 @@ function createNewRecycleComponent(newNode: ts.NewExpression, componentNode: ts.
|
||||
if (componentNode.arguments && componentNode.arguments.length > 0 &&
|
||||
ts.isObjectLiteralExpression(componentNode.arguments[0]) && componentNode.arguments[0].properties) {
|
||||
componentNode.arguments[0].properties.forEach((propertyItem: ts.PropertyAssignment) => {
|
||||
const newPropertyItem: ts.PropertyAssignment = createReference(propertyItem, [], false, false, true);
|
||||
const newPropertyItem: ts.PropertyAssignment = isProperty(propertyItem) ?
|
||||
createReference(propertyItem, [], false, false, true) : propertyItem;
|
||||
componentParam.push(newPropertyItem);
|
||||
});
|
||||
argNode = [ts.factory.createObjectLiteralExpression(componentParam, false)];
|
||||
|
@ -0,0 +1,178 @@
|
||||
/*
|
||||
* Copyright (c) 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/LICENSE2.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.
|
||||
*/
|
||||
|
||||
exports.source = `
|
||||
@Reusable
|
||||
@Component
|
||||
struct Chind {
|
||||
@Prop header: string
|
||||
@BuilderParam closer: () => void
|
||||
build() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
struct Index {
|
||||
@State text: string = 'header'
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
Chind({header: this.text}){}
|
||||
}
|
||||
}
|
||||
}`
|
||||
|
||||
exports.expectResult =
|
||||
`"use strict";
|
||||
if (!("finalizeConstruction" in ViewPU.prototype)) {
|
||||
Reflect.set(ViewPU.prototype, "finalizeConstruction", () => { });
|
||||
}
|
||||
if (PUV2ViewBase.contextStack === undefined) {
|
||||
Reflect.set(PUV2ViewBase, "contextStack", []);
|
||||
}
|
||||
class Chind extends ViewPU {
|
||||
constructor(parent, params, __localStorage, elmtId = -1, paramsLambda = undefined, extraInfo) {
|
||||
super(parent, __localStorage, elmtId, extraInfo);
|
||||
if (typeof paramsLambda === "function") {
|
||||
this.paramsGenerator_ = paramsLambda;
|
||||
}
|
||||
this.__header = new SynchedPropertySimpleOneWayPU(params.header, this, "header");
|
||||
this.closer = undefined;
|
||||
this.setInitiallyProvidedValue(params);
|
||||
this.finalizeConstruction();
|
||||
}
|
||||
setInitiallyProvidedValue(params) {
|
||||
if (params.closer !== undefined) {
|
||||
this.closer = params.closer;
|
||||
}
|
||||
}
|
||||
updateStateVars(params) {
|
||||
this.__header.reset(params.header);
|
||||
}
|
||||
purgeVariableDependenciesOnElmtId(rmElmtId) {
|
||||
this.__header.purgeDependencyOnElmtId(rmElmtId);
|
||||
}
|
||||
aboutToBeDeleted() {
|
||||
this.__header.aboutToBeDeleted();
|
||||
SubscriberManager.Get().delete(this.id__());
|
||||
this.aboutToBeDeletedInternal();
|
||||
}
|
||||
updateRecycleElmtId(oldElmtId, newElmtId) {
|
||||
this.__header.updateElmtId(oldElmtId, newElmtId);
|
||||
}
|
||||
get header() {
|
||||
return this.__header.get();
|
||||
}
|
||||
set header(newValue) {
|
||||
this.__header.set(newValue);
|
||||
}
|
||||
initialRender() {
|
||||
}
|
||||
rerender() {
|
||||
PUV2ViewBase.contextStack && PUV2ViewBase.contextStack.push(this);
|
||||
this.updateDirtyElements();
|
||||
PUV2ViewBase.contextStack && PUV2ViewBase.contextStack.pop();
|
||||
}
|
||||
}
|
||||
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.__text = new ObservedPropertySimplePU('header', this, "text");
|
||||
this.setInitiallyProvidedValue(params);
|
||||
this.finalizeConstruction();
|
||||
}
|
||||
setInitiallyProvidedValue(params) {
|
||||
if (params.text !== undefined) {
|
||||
this.text = params.text;
|
||||
}
|
||||
}
|
||||
updateStateVars(params) {
|
||||
}
|
||||
purgeVariableDependenciesOnElmtId(rmElmtId) {
|
||||
this.__text.purgeDependencyOnElmtId(rmElmtId);
|
||||
}
|
||||
aboutToBeDeleted() {
|
||||
this.__text.aboutToBeDeleted();
|
||||
SubscriberManager.Get().delete(this.id__());
|
||||
this.aboutToBeDeletedInternal();
|
||||
}
|
||||
get text() {
|
||||
return this.__text.get();
|
||||
}
|
||||
set text(newValue) {
|
||||
this.__text.set(newValue);
|
||||
}
|
||||
initialRender() {
|
||||
PUV2ViewBase.contextStack && PUV2ViewBase.contextStack.push(this);
|
||||
this.observeComponentCreation2((elmtId, isInitialRender) => {
|
||||
Column.create();
|
||||
}, Column);
|
||||
this.observeComponentCreation2((elmtId, isInitialRender) => {
|
||||
__Recycle__.create();
|
||||
}, __Recycle__);
|
||||
{
|
||||
this.observeRecycleComponentCreation("Chind", (elmtId, isInitialRender, recycleNode = null) => {
|
||||
ViewStackProcessor.StartGetAccessRecordingFor(elmtId);
|
||||
if (isInitialRender) {
|
||||
let componentCall = recycleNode ? recycleNode : new Chind(this, {
|
||||
header: this.text,
|
||||
closer: () => { }
|
||||
}, undefined, elmtId, () => { }, { page: "recycle_builderParam.ets", line: 19, col: 7 });
|
||||
ViewPU.createRecycle(componentCall, recycleNode !== null, "Chind", () => {
|
||||
if (recycleNode && typeof recycleNode.aboutToReuseInternal === "function") {
|
||||
recycleNode.aboutToReuseInternal();
|
||||
}
|
||||
else {
|
||||
if (recycleNode.aboutToReuse && typeof recycleNode.aboutToReuse === "function") {
|
||||
recycleNode.aboutToReuse({ header: this.text, closer: () => { } });
|
||||
}
|
||||
recycleNode.rerender();
|
||||
}
|
||||
});
|
||||
let paramsLambda = () => {
|
||||
return {
|
||||
header: this.text,
|
||||
closer: () => { }
|
||||
};
|
||||
};
|
||||
componentCall.paramsGenerator_ = paramsLambda;
|
||||
}
|
||||
else {
|
||||
this.updateStateVarsOfChildByElmtId(elmtId, {
|
||||
header: this.text
|
||||
});
|
||||
}
|
||||
ViewStackProcessor.StopGetAccessRecording();
|
||||
});
|
||||
}
|
||||
__Recycle__.pop();
|
||||
Column.pop();
|
||||
PUV2ViewBase.contextStack && PUV2ViewBase.contextStack.pop();
|
||||
}
|
||||
rerender() {
|
||||
PUV2ViewBase.contextStack && PUV2ViewBase.contextStack.push(this);
|
||||
this.updateDirtyElements();
|
||||
PUV2ViewBase.contextStack && PUV2ViewBase.contextStack.pop();
|
||||
}
|
||||
}
|
||||
ViewStackProcessor.StartGetAccessRecordingFor(ViewStackProcessor.AllocateNewElmetIdForNextComponent());
|
||||
loadDocument(new Index(undefined, {}));
|
||||
ViewStackProcessor.StopGetAccessRecording();
|
||||
`
|
Loading…
Reference in New Issue
Block a user