set child()

in packages/core/src/rendering/render-single-child.ts [18:39]


  set child(value) {
    if (this._child === value) {
      return
    }
    if (this._child) {
      if (this._yogaNode && this._child.yogaNode) {
        assert(this._child.yogaNode.getParent() === this._yogaNode)
        this._yogaNode.removeChild(this._child.yogaNode)
      }
      this.dropChild(this._child)
      this._childCount--
    }
    this._child = value
    if (this._child) {
      this.adoptChild(this._child)
      if (this._yogaNode && this._child.yogaNode) {
        assert(!this._child.yogaNode.getParent(), '子节点的 yogaNode 不能已有 parent')
        this._yogaNode.insertChild(this._child.yogaNode, 0)
      }
      this._childCount++
    }
  }