improve reselection list updates.

This commit is contained in:
Christopher Jeffrey 2014-01-19 01:20:37 -06:00
parent e3324d2216
commit 6777957ff2
1 changed files with 8 additions and 3 deletions

View File

@ -4223,7 +4223,7 @@ List.prototype.removeItem = function(child) {
List.prototype.setItems = function(items) {
var i = 0
, original = this.items.slice()
//, selected = this.selected
, selected = this.selected
, sel = this.ritems[this.selected];
this.select(0);
@ -4244,8 +4244,13 @@ List.prototype.setItems = function(items) {
// Try to find our old item if it still exists.
sel = items.indexOf(sel);
if (~sel) this.select(sel);
//this.select(~sel ? sel : selected);
if (~sel) {
this.select(sel);
} else if (items.length === original.length) {
this.select(selected);
} else {
this.select(Math.min(selected, items.length - 1));
}
};
List.prototype.select = function(index) {