MCPcopy Index your code
hub / github.com/alibaba/lowcode-engine / replaceChild

Method replaceChild

packages/designer/src/document/node/node.ts:774–794  ·  view source on GitHub ↗

* 替换子节点 * * @param {INode} node * @param {object} data

(node: INode, data: any)

Source from the content-addressed store, hash-verified

772 * @param {object} data
773 */
774 replaceChild(node: INode, data: any): INode | null {
775 if (this.children?.has(node)) {
776 const selected = this.document.selection.has(node.id);
777
778 delete data.id;
779 const newNode = this.document.createNode(data);
780
781 if (!isNode(newNode)) {
782 return null;
783 }
784
785 this.insertBefore(newNode, node, false);
786 node.remove(false);
787
788 if (selected) {
789 this.document.selection.select(newNode.id);
790 }
791 return newNode;
792 }
793 return node;
794 }
795
796 setVisible(flag: boolean): void {
797 this.getExtraProp('hidden')?.setValue(!flag);

Callers

nothing calls this directly

Calls 6

insertBeforeMethod · 0.95
isNodeFunction · 0.85
hasMethod · 0.65
createNodeMethod · 0.65
removeMethod · 0.65
selectMethod · 0.65

Tested by

no test coverage detected