length as a mixedcollection key confuses things...
[roojs1] / Roo / util / MixedCollection.js
index 5238ed0..2a251ee 100644 (file)
@@ -75,23 +75,16 @@ Roo.extend(Roo.util.MixedCollection, Roo.util.Observable, {
  * @return {Object} The item added.
  */
     add : function(key, o){
-        
         if(arguments.length == 1){
             o = arguments[0];
             key = this.getKey(o);
         }
-        
-        Roo.log([key, o]);
-        
         if(typeof key == "undefined" || key === null){
             this.length++;
             this.items.push(o);
             this.keys.push(null);
         }else{
-            Roo.log(this);
-            var old = this.map[key * 1];
-            Roo.log('old.........................');
-            Roo.log(old);
+            var old = this.map[key];
             if(old){
                 return this.replace(key, o);
             }
@@ -146,15 +139,11 @@ mc.add(otherEl);
             o = arguments[0];
             key = this.getKey(o);
         }
-        Roo.log('replace.........................');
-            Roo.log([o, key]);
         var old = this.item(key);
         if(typeof key == "undefined" || key === null || typeof old == "undefined"){
              return this.add(key, o);
         }
         var index = this.indexOfKey(key);
-        Roo.log(index);
-        
         this.items[index] = o;
         this.map[key] = o;
         this.fireEvent("replace", key, old, o);
@@ -300,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{
@@ -316,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{
@@ -330,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!
     },