mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Detach instead of remove when moved item is the view
Moving an item that extended the jQuery object between panes was previously wiping out all jQuery data since remove() was being called on the view item instead of detach().
This commit is contained in:
@@ -257,6 +257,13 @@ describe "Pane", ->
|
||||
expect(pane2.getItems()).toEqual [view3, editSession1]
|
||||
expect(editSession1.destroyed).toBeFalsy()
|
||||
|
||||
describe "when the item is a jQuery object", ->
|
||||
it "preserves data by detaching instead of removing", ->
|
||||
view1.data('preservative', 1234)
|
||||
pane.moveItemToPane(view1, pane2, 1)
|
||||
pane2.showItemAtIndex(1)
|
||||
expect(pane2.activeView.data('preservative')).toBe 1234
|
||||
|
||||
describe "core:close", ->
|
||||
it "destroys the active item and does not bubble the event", ->
|
||||
containerCloseHandler = jasmine.createSpy("containerCloseHandler")
|
||||
|
||||
@@ -214,7 +214,9 @@ class Pane extends View
|
||||
@trigger 'pane:item-moved', [item, newIndex]
|
||||
|
||||
moveItemToPane: (item, pane, index) ->
|
||||
@isMovingItem = true
|
||||
@removeItem(item)
|
||||
@isMovingItem = false
|
||||
pane.addItem(item, index)
|
||||
|
||||
itemForUri: (uri) ->
|
||||
@@ -235,8 +237,12 @@ class Pane extends View
|
||||
delete @viewsByClassName[viewClass.name]
|
||||
|
||||
if @items.length > 0
|
||||
viewToRemove?.remove()
|
||||
if @isMovingItem and item is viewToRemove
|
||||
viewToRemove?.detach()
|
||||
else
|
||||
viewToRemove?.remove()
|
||||
else
|
||||
viewToRemove?.detach() if @isMovingItem and item is viewToRemove
|
||||
@remove()
|
||||
|
||||
viewForItem: (item) ->
|
||||
|
||||
Reference in New Issue
Block a user