Remove path data attributes when no active item

This commit is contained in:
Kevin Sawicki
2015-04-15 10:32:22 -07:00
parent 476cf4152c
commit 9a0c3f94a9
2 changed files with 9 additions and 3 deletions

View File

@@ -128,6 +128,12 @@ describe "PaneView", ->
it "adds the file name as a data attribute to the pane", ->
expect(pane).toHaveAttr('data-active-item-name')
describe "when the activeItem is destroyed", ->
it "removes the data attributes", ->
pane.destroyItems()
expect(pane).not.toHaveAttr('data-active-item-path')
expect(pane).not.toHaveAttr('data-active-item-name')
describe "when the new activeItem does not implement ::getPath", ->
beforeEach ->
paneModel.activateItem(editor1)

View File

@@ -67,6 +67,9 @@ class PaneElement extends HTMLElement
@classList.remove('active')
activeItemChanged: (item) ->
delete @dataset.activeItemName
delete @dataset.activeItemPath
return unless item?
hasFocus = @hasFocus()
@@ -75,9 +78,6 @@ class PaneElement extends HTMLElement
if itemPath = item.getPath?()
@dataset.activeItemName = path.basename(itemPath)
@dataset.activeItemPath = itemPath
else
delete @dataset.activeItemName
delete @dataset.activeItemPath
unless @itemViews.contains(itemView)
@itemViews.appendChild(itemView)