mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-01-15 18:58:11 +00:00
refactor: prop 的子实例不再延迟初始化, 也不再 node 未初始化完成之前就调用 dispose 方法
This commit is contained in:
parent
a10641daff
commit
ec31bf9ea5
@ -157,7 +157,7 @@ export class Node<Schema extends NodeSchema = NodeSchema> {
|
|||||||
return this.componentMeta.icon;
|
return this.componentMeta.icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
private isInited = false;
|
isInited = false;
|
||||||
|
|
||||||
constructor(readonly document: DocumentModel, nodeSchema: Schema, options: any = {}) {
|
constructor(readonly document: DocumentModel, nodeSchema: Schema, options: any = {}) {
|
||||||
const { componentName, id, children, props, ...extras } = nodeSchema;
|
const { componentName, id, children, props, ...extras } = nodeSchema;
|
||||||
@ -168,9 +168,6 @@ export class Node<Schema extends NodeSchema = NodeSchema> {
|
|||||||
children: isDOMText(children) || isJSExpression(children) ? children : '',
|
children: isDOMText(children) || isJSExpression(children) ? children : '',
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// 这里 props 被初始化两次,一次 new,一次 import,new 的实例需要给 propsReducer 的钩子去使用,
|
|
||||||
// import 是为了使用钩子返回的值,并非完全幂等的操作,部分行为执行两次会有 bug,
|
|
||||||
// 所以在 props 里会对 new / import 做一些区别化的解析
|
|
||||||
this.props = new Props(this, props, extras);
|
this.props = new Props(this, props, extras);
|
||||||
this._children = new NodeChildren(this as ParentalNode, this.initialChildren(children));
|
this._children = new NodeChildren(this as ParentalNode, this.initialChildren(children));
|
||||||
this._children.internalInitParent();
|
this._children.internalInitParent();
|
||||||
|
|||||||
@ -55,6 +55,12 @@ export class Prop implements IPropParent {
|
|||||||
if (value !== UNSET) {
|
if (value !== UNSET) {
|
||||||
this.setValue(value);
|
this.setValue(value);
|
||||||
}
|
}
|
||||||
|
this.setupItems();
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: 先用调用方式触发子 prop 的初始化,后续须重构
|
||||||
|
private setupItems() {
|
||||||
|
return this.items;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -247,7 +253,9 @@ export class Prop implements IPropParent {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
this.dispose();
|
if (this.owner.isInited) {
|
||||||
|
this.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
if (oldValue !== this._value) {
|
if (oldValue !== this._value) {
|
||||||
editor?.emit('node.innerProp.change', {
|
editor?.emit('node.innerProp.change', {
|
||||||
@ -302,7 +310,6 @@ export class Prop implements IPropParent {
|
|||||||
owner.addSlot(this._slotNode);
|
owner.addSlot(this._slotNode);
|
||||||
this._slotNode.internalSetSlotFor(this);
|
this._slotNode.internalSetSlotFor(this);
|
||||||
}
|
}
|
||||||
this.dispose();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -166,7 +166,7 @@ Object {
|
|||||||
"labelTextAlign": "right",
|
"labelTextAlign": "right",
|
||||||
"labelTipsIcon": "",
|
"labelTipsIcon": "",
|
||||||
"labelTipsText": Object {
|
"labelTipsText": Object {
|
||||||
"en_US": null,
|
"en_US": "",
|
||||||
"type": "i18n",
|
"type": "i18n",
|
||||||
"use": "zh_CN",
|
"use": "zh_CN",
|
||||||
"zh_CN": "",
|
"zh_CN": "",
|
||||||
@ -240,7 +240,7 @@ Object {
|
|||||||
"labelTextAlign": "right",
|
"labelTextAlign": "right",
|
||||||
"labelTipsIcon": "",
|
"labelTipsIcon": "",
|
||||||
"labelTipsText": Object {
|
"labelTipsText": Object {
|
||||||
"en_US": null,
|
"en_US": "",
|
||||||
"type": "i18n",
|
"type": "i18n",
|
||||||
"use": "zh_CN",
|
"use": "zh_CN",
|
||||||
"zh_CN": "",
|
"zh_CN": "",
|
||||||
@ -310,7 +310,7 @@ Object {
|
|||||||
"labelTextAlign": "right",
|
"labelTextAlign": "right",
|
||||||
"labelTipsIcon": "",
|
"labelTipsIcon": "",
|
||||||
"labelTipsText": Object {
|
"labelTipsText": Object {
|
||||||
"en_US": null,
|
"en_US": "",
|
||||||
"type": "i18n",
|
"type": "i18n",
|
||||||
"use": "zh_CN",
|
"use": "zh_CN",
|
||||||
"zh_CN": "",
|
"zh_CN": "",
|
||||||
@ -392,7 +392,7 @@ Object {
|
|||||||
"labelTextAlign": "right",
|
"labelTextAlign": "right",
|
||||||
"labelTipsIcon": "",
|
"labelTipsIcon": "",
|
||||||
"labelTipsText": Object {
|
"labelTipsText": Object {
|
||||||
"en_US": null,
|
"en_US": "",
|
||||||
"type": "i18n",
|
"type": "i18n",
|
||||||
"use": "zh_CN",
|
"use": "zh_CN",
|
||||||
"zh_CN": "",
|
"zh_CN": "",
|
||||||
@ -478,7 +478,7 @@ Object {
|
|||||||
"labelTextAlign": "right",
|
"labelTextAlign": "right",
|
||||||
"labelTipsIcon": "",
|
"labelTipsIcon": "",
|
||||||
"labelTipsText": Object {
|
"labelTipsText": Object {
|
||||||
"en_US": null,
|
"en_US": "",
|
||||||
"type": "i18n",
|
"type": "i18n",
|
||||||
"use": "zh_CN",
|
"use": "zh_CN",
|
||||||
"zh_CN": "",
|
"zh_CN": "",
|
||||||
@ -620,7 +620,7 @@ Object {
|
|||||||
"labelTextAlign": "right",
|
"labelTextAlign": "right",
|
||||||
"labelTipsIcon": "",
|
"labelTipsIcon": "",
|
||||||
"labelTipsText": Object {
|
"labelTipsText": Object {
|
||||||
"en_US": null,
|
"en_US": "",
|
||||||
"type": "i18n",
|
"type": "i18n",
|
||||||
"use": "zh_CN",
|
"use": "zh_CN",
|
||||||
"zh_CN": "",
|
"zh_CN": "",
|
||||||
@ -694,7 +694,7 @@ Object {
|
|||||||
"labelTextAlign": "right",
|
"labelTextAlign": "right",
|
||||||
"labelTipsIcon": "",
|
"labelTipsIcon": "",
|
||||||
"labelTipsText": Object {
|
"labelTipsText": Object {
|
||||||
"en_US": null,
|
"en_US": "",
|
||||||
"type": "i18n",
|
"type": "i18n",
|
||||||
"use": "zh_CN",
|
"use": "zh_CN",
|
||||||
"zh_CN": "",
|
"zh_CN": "",
|
||||||
@ -776,7 +776,7 @@ Object {
|
|||||||
"labelTextAlign": "right",
|
"labelTextAlign": "right",
|
||||||
"labelTipsIcon": "",
|
"labelTipsIcon": "",
|
||||||
"labelTipsText": Object {
|
"labelTipsText": Object {
|
||||||
"en_US": null,
|
"en_US": "",
|
||||||
"type": "i18n",
|
"type": "i18n",
|
||||||
"use": "zh_CN",
|
"use": "zh_CN",
|
||||||
"zh_CN": "",
|
"zh_CN": "",
|
||||||
|
|||||||
@ -99,7 +99,7 @@ describe('document-model 测试', () => {
|
|||||||
expect(doc.suspensed).toBeFalsy();
|
expect(doc.suspensed).toBeFalsy();
|
||||||
|
|
||||||
doc.suspense();
|
doc.suspense();
|
||||||
doc.active();
|
doc.activate();
|
||||||
doc.close();
|
doc.close();
|
||||||
doc.remove();
|
doc.remove();
|
||||||
|
|
||||||
|
|||||||
@ -27,6 +27,7 @@ const mockedOwner = {
|
|||||||
},
|
},
|
||||||
designer: {},
|
designer: {},
|
||||||
},
|
},
|
||||||
|
isInited: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
const mockedPropsInst = {
|
const mockedPropsInst = {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user