Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Sencha User
    Join Date
    Sep 2012
    Posts
    7
    Vote Rating
    0
    danyaPostfactum is on a distinguished road

      0  

    Default Array.prototype.remove and Ext.apply - wtf ??? (bug with config of type of Array)

    Array.prototype.remove and Ext.apply - wtf ??? (bug with config of type of Array)


    Due to some reasons I use this code:

    Code:
    var config = ['a', 'b'];
    Ext.apply(o, config);
    Ext.apply , defined in ext-base.js looks like:
    Code:
    Ext.apply = function(o, c, defaults){
        // no "this" reference for friendly out of scope calls
        if(defaults){
            Ext.apply(o, defaults);
        }
        if(o && c && typeof c == 'object'){
            for(var p in c){
                o[p] = c[p];
            }
        }
        return o;
    };
    Ok, as we see, it MUST work with array (typeof array is 'object'), but wait, Ext has defined such stupid prototype methods:

    Code:
    Ext.applyIf(Array.prototype, {
        /**
         * Checks whether or not the specified object exists in the array.
         * @param {Object} o The object to check for
         * @param {Number} from (Optional) The index at which to begin the search
         * @return {Number} The index of o in the array (or -1 if it is not found)
         */
        indexOf : function(o, from){
            var len = this.length;
            from = from || 0;
            from += (from < 0) ? len : 0;
            for (; from < len; ++from){
                if(this[from] === o){
                    return from;
                }
            }
            return -1;
        },
    
    
        /**
         * Removes the specified object from the array.  If the object is not found nothing happens.
         * @param {Object} o The object to remove
         * @return {Array} this array
         */
        remove : function(o){
            var index = this.indexOf(o);
            if(index != -1){
                this.splice(index, 1);
            }
            return this;
        }
    });

    Nice, remove() is enumerable! This is great, because of this brokes all for (var p in o) iterations !

    Ext developers are happy, because of they can call [0,1].remove(0) instead of [0,1].splice(0,1).
    But I am sad because of my server-side provides component states as arrays, not objects.

    Is ExtJS 3 supported? Where is bug-tracker ? Can someone offer workaround, please (I am new to javascript and especially ExtJS)?

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,206
    Vote Rating
    856
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Ext JS 3 is supported if you were a support subscriber, any updates are only available to support subscribers since Ext JS 4 is the current version.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Sep 2012
    Posts
    7
    Vote Rating
    0
    danyaPostfactum is on a distinguished road

      0  

    Default


    No, I am not subscriber. I am developer of free extras for free CMS (MODx Revolution). So, public version will stay buggy? Fine...

  4. #4
    Sencha User
    Join Date
    Sep 2012
    Posts
    7
    Vote Rating
    0
    danyaPostfactum is on a distinguished road

      0  

    Default


    hasOwnProperty check brokes Ext.grid.RowExpander.
    Object.defineProperty doesnt work in IE6-8.

    Very bad...

    Used such workaround:

    Code:
    Object.defineProperty(Array.prototype, "remove", {
        value : function(o){
            var index = this.indexOf(o);
            if(index != -1){
                this.splice(index, 1);
            }
            return this;
        },
        enumerable : false
    });
    This works at least in modern browsers.

Thread Participants: 1

Tags for this Thread