diff --git a/spec/pane-spec.coffee b/spec/pane-spec.coffee index 6ee7d1bab..3453ac44d 100644 --- a/spec/pane-spec.coffee +++ b/spec/pane-spec.coffee @@ -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 diff --git a/src/pane.coffee b/src/pane.coffee index 53980c8d1..f77da9d58 100644 --- a/src/pane.coffee +++ b/src/pane.coffee @@ -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'