mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Merge pull request #7633 from atom/ns-pane-items-must-be-objects
Throw an exception when adding a non-object pane item
This commit is contained in:
@@ -108,6 +108,12 @@ describe "Pane", ->
|
||||
pane2 = pane1.splitRight()
|
||||
expect(-> pane2.addItem(item)).toThrow()
|
||||
|
||||
it "throws an exception if the item isn't an object", ->
|
||||
pane = new Pane(items: [])
|
||||
expect(-> pane.addItem(null)).toThrow()
|
||||
expect(-> pane.addItem('foo')).toThrow()
|
||||
expect(-> pane.addItem(1)).toThrow()
|
||||
|
||||
describe "::activateItem(item)", ->
|
||||
pane = null
|
||||
|
||||
|
||||
@@ -336,6 +336,8 @@ class Pane extends Model
|
||||
#
|
||||
# Returns the added item.
|
||||
addItem: (item, index=@getActiveItemIndex() + 1) ->
|
||||
throw new Error("Pane items must be objects. Attempted to add item #{item}.") unless item? and typeof item is 'object'
|
||||
|
||||
return if item in @items
|
||||
|
||||
if typeof item.onDidDestroy is 'function'
|
||||
|
||||
Reference in New Issue
Block a user