* 内部方法,请勿使用 * @param useMutator 是否触发联动逻辑
(parent: INode | null, useMutator = false)
| 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; |
no test coverage detected