mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-01-15 02:38:16 +00:00
refactor: prop 的子实例不再延迟初始化, 也不再 node 未初始化完成之前就调用 dispose 方法
This commit is contained in:
parent
a10641daff
commit
3f2cd667d0
@ -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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user