const getParent = function (vm) {
  let parent = vm.$parent
  let filterTag = new Set(['CatalogTree', 'catalog-tree'])
  while (parent != null && !filterTag.has(parent.$options._componentTag || parent.$options.name)) {
    parent = parent.$parent
  }
  return parent
}

export default {
  name: 'TreeSlot',
  props: {
    node: Object
  },
  render (h) {
    let parent = getParent(this)
    if (parent.$scopedSlots && parent.$scopedSlots.nodeOprate) {
      return h('div', {
        class: 'tree-node-oprates'
      }, [
        parent.$scopedSlots.nodeOprate({
          node: this.node
        })
      ])
    }
    return h('span', {
      class: 'tree-node-oprates'
    })
  }
}
