length as a mixedcollection key confuses things...
[roojs1] / Roo / util / MixedCollection.js
index 7886fc6..2a251ee 100644 (file)
@@ -289,7 +289,9 @@ mc.add(otherEl);
     indexOf : function(o){
         if(!this.items.indexOf){
             for(var i = 0, len = this.items.length; i < len; i++){
-                if(this.items[i] == o) return i;
+                if(this.items[i] == o) {
+                    return i;
+                }
             }
             return -1;
         }else{
@@ -305,7 +307,9 @@ mc.add(otherEl);
     indexOfKey : function(key){
         if(!this.keys.indexOf){
             for(var i = 0, len = this.keys.length; i < len; i++){
-                if(this.keys[i] == key) return i;
+                if(this.keys[i] == key) {
+                    return i;
+                }
             }
             return -1;
         }else{
@@ -319,6 +323,9 @@ mc.add(otherEl);
  * @return {Object} The item associated with the passed key.
  */
     item : function(key){
+        if (key === 'length') {
+            return null;
+        }
         var item = typeof this.map[key] != "undefined" ? this.map[key] : this.items[key];
         return typeof item != 'function' || this.allowFunctions ? item : null; // for prototype!
     },
@@ -387,21 +394,15 @@ mc.add(otherEl);
     },
     
     _sort : function(property, dir, fn){
-        Roo.log(property);
         var dsc = String(dir).toUpperCase() == "DESC" ? -1 : 1;
         fn = fn || function(a, b){
             return a-b;
         };
         var c = [], k = this.keys, items = this.items;
         for(var i = 0, len = items.length; i < len; i++){
-            var v = typeof(items[i].data[property]) == 'undefined' ? items[i] : items[i].data[property];
-            c[c.length] = {key: k[i], value: v, index: i};
+            c[c.length] = {key: k[i], value: items[i], index: i};
         }
         c.sort(function(a, b){
-            Roo.log(a);
-            Roo.log(b);
-            Roo.log(a[property]);
-            Roo.log(b[property]);
             var v = fn(a[property], b[property]) * dsc;
             if(v == 0){
                 v = (a.index < b.index ? -1 : 1);