 
   closeOtherTabs: (active) ->
     tabs = @getTabs()
-    active ?= @children('.right-clicked')[0]
+    active ?= @element.querySelector('.right-clicked')
     return unless active?
     @closeTab tab for tab in tabs when tab isnt active
 
   closeTabsToRight: (active) ->
     tabs = @getTabs()
-    active ?= @children('.right-clicked')[0]
+    active ?= @element.querySelector('.right-clicked')
     index = tabs.indexOf(active)
     return if index is -1
     @closeTab tab for tab, i in tabs when i > index

      @element.classList.remove('hidden')

  getTabs: ->
    @children('.tab').toArray()

  tabAtIndex: (index) ->
    @children(".tab:eq(#{index})")[0]

  tabForItem: (item) ->
    _.detect @getTabs(), (tab) -> tab.item is item

    @setActiveTab(@tabForItem(@pane.getActiveItem()))

  closeTab: (tab) ->
    tab ?= @element.querySelector('.right-clicked')
    @pane.destroyItem(tab.item) if tab?

  splitTab: (fn) ->
    if item = @element.querySelector('.right-clicked')?.item
      if copiedItem = @copyItem(item)
        @pane[fn](items: [copiedItem])

