mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-01-27 12:58:22 +00:00
fix: refactor splice method to remove and purge nodes***
This commit is contained in:
parent
a423a7dab5
commit
4c83b945a7
@ -307,10 +307,16 @@ export class NodeChildren implements Omit<IPublicModelNodeChildren<INode>,
|
||||
*
|
||||
*/
|
||||
splice(start: number, deleteCount: number, node?: INode): INode[] {
|
||||
let removedNode;
|
||||
if (node) {
|
||||
return this.children.splice(start, deleteCount, node);
|
||||
removedNode = this.children.splice(start, deleteCount, node);
|
||||
} else {
|
||||
removedNode = this.children.splice(start, deleteCount);
|
||||
}
|
||||
return this.children.splice(start, deleteCount);
|
||||
|
||||
removedNode.forEach(d => d?.purge());
|
||||
|
||||
return removedNode;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -97,8 +97,9 @@ export class NodeChildren implements IPublicModelNodeChildren {
|
||||
* @param deleteCount
|
||||
* @param node
|
||||
*/
|
||||
splice(start: number, deleteCount: number, node?: IPublicModelNode): any {
|
||||
this[nodeChildrenSymbol].splice(start, deleteCount, (node as any)?.[nodeSymbol]);
|
||||
splice(start: number, deleteCount: number, node?: IPublicModelNode): IPublicModelNode[] {
|
||||
const removedNode = this[nodeChildrenSymbol].splice(start, deleteCount, (node as any)?.[nodeSymbol]);
|
||||
return removedNode.map((item: InnerNode) => ShellNode.create(item)!);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -78,7 +78,7 @@ export interface IPublicModelNodeChildren<
|
||||
* @param deleteCount
|
||||
* @param node
|
||||
*/
|
||||
splice(start: number, deleteCount: number, node?: Node): any;
|
||||
splice(start: number, deleteCount: number, node?: Node): Node[];
|
||||
|
||||
/**
|
||||
* 返回指定下标的节点
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user