mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-01-13 01:21:58 +00:00
Merge branch 'fix/onNodeAdd' into 'release/0.9.0'
fix: props.getNode 防死循环 防止死循环调用 See merge request !907974
This commit is contained in:
commit
89c6abbb5c
@ -313,9 +313,10 @@ export class NodeChildren {
|
||||
return;
|
||||
}
|
||||
const callbacks = owner.componentMeta.getMetadata().experimental?.callbacks;
|
||||
if (callbacks?.onSubtreeModified) {
|
||||
if (callbacks?.onSubtreeModified && options?.type !== 'insert') {
|
||||
try {
|
||||
callbacks?.onSubtreeModified.call(node, owner, options);
|
||||
// 此处传入的 owner节点需要对getChildren进行处理,兼容老的数据结构
|
||||
callbacks?.onSubtreeModified.call(node, owner.getVisionCapabledNode(), options);
|
||||
} catch (e) {
|
||||
console.error('error when excute experimental.callbacks.onNodeAdd', e);
|
||||
}
|
||||
@ -323,7 +324,7 @@ export class NodeChildren {
|
||||
|
||||
if (callbacks?.onNodeAdd && options?.type === 'insert') {
|
||||
try {
|
||||
callbacks?.onNodeAdd.call(owner, node, owner);
|
||||
callbacks?.onNodeAdd.call(owner, node.getVisionCapabledNode(), owner);
|
||||
} catch (e) {
|
||||
console.error('error when excute experimental.callbacks.onNodeAdd', e);
|
||||
}
|
||||
|
||||
@ -818,6 +818,33 @@ export class Node<Schema extends NodeSchema = NodeSchema> {
|
||||
toString() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* 慎用,可能有极端未知后果
|
||||
* @deprecated
|
||||
*/
|
||||
getVisionCapabledNode() {
|
||||
// 判断是否已经是 nodeForVision
|
||||
if (!this.isVisionNode) {
|
||||
const children = this.getChildren();
|
||||
this.getChildren = () => {
|
||||
return children?.getChildrenArray() || [];
|
||||
};
|
||||
this.getProps = () => {
|
||||
const props = this.props.export();
|
||||
props.getPropValue = (key) => {
|
||||
return this.props.getPropValue(key);
|
||||
};
|
||||
props.getNode = () => {
|
||||
return this;
|
||||
};
|
||||
return props;
|
||||
};
|
||||
this.isVisionNode = true;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export interface ParentalNode<T extends NodeSchema = NodeSchema> extends Node<T> {
|
||||
|
||||
@ -335,10 +335,7 @@ export class Props implements IPropParent {
|
||||
* 兼容vision体系
|
||||
*/
|
||||
getNode() {
|
||||
const nodeForVision = this.owner;
|
||||
nodeForVision.getChildren = () => {
|
||||
return this.owner?.getChildren()?.getChildrenArray() || [];
|
||||
};
|
||||
const nodeForVision = this.owner?.getVisionCapabledNode();
|
||||
return nodeForVision;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user