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

Method internalSetParent

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

* 内部方法,请勿使用 * @param useMutator 是否触发联动逻辑

(parent: INode | null, useMutator = false)

Source from the content-addressed store, hash-verified

560 * @param useMutator 是否触发联动逻辑
561 */
562 internalSetParent(parent: INode | null, useMutator = false) {
563 if (this._parent === parent) {
564 return;
565 }
566
567 // 解除老的父子关系,但不需要真的删除节点
568 if (this._parent) {
569 if (this.isSlot()) {
570 this._parent.unlinkSlot(this);
571 } else {
572 this._parent.children?.unlinkChild(this);
573 }
574 }
575 if (useMutator) {
576 this._parent?.didDropOut(this);
577 }
578 if (parent) {
579 // 建立新的父子关系,尤其注意:对于 parent 为 null 的场景,不会赋值,因为 subtreeModified 等事件可能需要知道该 node 被删除前的父子关系
580 this._parent = parent;
581 this.document.removeWillPurge(this);
582 /* istanbul ignore next */
583 if (!this.conditionGroup) {
584 // initial conditionGroup
585 const grp = this.getExtraProp('conditionGroup', false)?.getAsString();
586 if (grp) {
587 this.setConditionGroup(grp);
588 }
589 }
590
591 if (useMutator) {
592 parent.didDropIn(this);
593 }
594 }
595 }
596
597 internalSetSlotFor(slotFor: Prop | null | undefined) {
598 this._slotFor = slotFor;

Callers 1

internalSetWillPurgeMethod · 0.95

Calls 9

isSlotMethod · 0.95
getExtraPropMethod · 0.95
setConditionGroupMethod · 0.95
unlinkSlotMethod · 0.65
unlinkChildMethod · 0.65
didDropOutMethod · 0.65
removeWillPurgeMethod · 0.65
getAsStringMethod · 0.65
didDropInMethod · 0.65

Tested by

no test coverage detected