From d03a9a019229c6896688e504cbd9179a7b5899bd Mon Sep 17 00:00:00 2001 From: JC Brand Date: Sun, 26 Oct 2014 23:11:58 +0100 Subject: [PATCH] bugfix in positionGroup. Index must always be 0 if there aren't any group elements in the dom yet. --- converse.js | 5 +++-- spec/profiling.js | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/converse.js b/converse.js index 332043b1c..749bb8758 100644 --- a/converse.js +++ b/converse.js @@ -4077,13 +4077,14 @@ /* Place the group's DOM element in the correct alphabetical * position amongst the other groups in the roster. */ - var index = this.model.indexOf(view.model); + var $groups = this.$('.roster-group'), + index = $groups.length ? this.model.indexOf(view.model) : 0; if (index === 0) { this.$roster.prepend(view.$el); } else if (index == (this.model.length-1)) { this.appendGroup(view); } else { - $(this.$('.roster-group').eq(index)).before(view.$el); + $($groups.eq(index)).before(view.$el); } return this; }, diff --git a/spec/profiling.js b/spec/profiling.js index 22c8659a7..7e082f901 100644 --- a/spec/profiling.js +++ b/spec/profiling.js @@ -53,7 +53,7 @@ }); _.each(['Friends', 'Colleagues', 'Family', 'Acquaintances'], function (group) { var i; - for (i=0; i<500; i++) { + for (i=0; i<100; i++) { stanza = stanza.c('item', { jid: Math.random().toString().replace('0.', '')+'@example.net', subscription:'both'