Permalink
Browse files

Merge pull request #786 from dcporter/master

Clicking on a content-less collection view results in a thrown error.
  • Loading branch information...
2 parents e757e10 + c1ac473 commit 9fcbabae64ee3d09f4b5a00f4a0ef947651f5d78 @publickeating publickeating committed May 29, 2012
Showing with 17 additions and 1 deletion.
  1. +13 −0 frameworks/desktop/tests/views/collection/mouse.js
  2. +4 −1 frameworks/desktop/views/collection.js
View
13 frameworks/desktop/tests/views/collection/mouse.js
@@ -153,6 +153,19 @@ test("first responder", function() {
equals(view.get('isFirstResponder'), YES, 'view.isFirstResponder should be YES after mouse down');
});
+test("clicking on a collection view with null content should not throw an error", function() {
+ var failed = NO;
+ view.set('content', null);
+ try {
+ var l = view.get('layer'),
+ evt = SC.Event.simulateEvent(l, 'mousedown');
+ SC.Event.trigger(l, 'mousedown', [evt]);
+ }
+ catch (e) { failed = YES; }
+ ok(!failed, "clicking on a collection view with null content should not throw an error");
+});
+
+
// ..........................................................
// ctrl-click mouse down
//
View
5 frameworks/desktop/views/collection.js
@@ -2149,8 +2149,11 @@ SC.CollectionView = SC.View.extend(SC.CollectionViewDelegate, SC.CollectionConte
@returns {Boolean} Usually YES.
*/
mouseDown: function(ev) {
+ var content = this.get('content');
+
+ if (!content) return this.get('isSelectable');
+
var itemView = this.itemViewForEvent(ev),
- content = this.get('content'),
contentIndex = itemView ? itemView.get('contentIndex') : -1,
info, anchor, sel, isSelected, modifierKeyPressed, didSelect = NO,
allowsMultipleSel = content.get('allowsMultipleSelection');

0 comments on commit 9fcbaba

Please sign in to comment.