length as a mixedcollection key confuses things...
[roojs1] / Roo / util / MixedCollection.js
index 469d511..2a251ee 100644 (file)
@@ -96,35 +96,7 @@ Roo.extend(Roo.util.MixedCollection, Roo.util.Observable, {
         this.fireEvent("add", this.length-1, o, key);
         return o;
     },
-      
-/**
- * Adds an item to the collection.
- * @param {String} key The key to associate with the item
- * @param {Object} o The item to add.
- * @return {Object} The item added.
- */
-    unshift : function(key, o){
-        if(arguments.length == 1){
-            o = arguments[0];
-            key = this.getKey(o);
-        }
-        if(typeof key == "undefined" || key === null){
-            this.length++;
-            this.items.unshift(o);
-            this.keys.unshift(null);
-        }else{
-            var old = this.map[key];
-            if(old){
-                return this.replace(key, o);
-            }
-            this.length++;
-            this.items.unshift(o);
-            this.map[key] = o;
-            this.keys.unshift(key);
-        }
-        this.fireEvent("add", this.length-1, o, key);
-        return o;
-    },
+       
 /**
   * MixedCollection has a generic way to fetch keys if you implement getKey.
 <pre><code>
@@ -317,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{
@@ -333,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{
@@ -347,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!
     },