Hybrid View

    You found a bug! We've classified it as EXTJSIII-100 . We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.
  1. #1
    Ext JS Premium Member
    Join Date
    Dec 2010
    Posts
    2
    Vote Rating
    0
    cscomkl is on a distinguished road

      0  

    Default Ext.EventManager.removeFromSpecialCache() iterating past end of array error

    Ext.EventManager.removeFromSpecialCache() iterating past end of array error


    Tested version: Ext JS 3.4.0, 3.4.1, 3.4.1.1 (Update May 2013)
    Browsers: All

    Code:
            //Ext 3.4.1.1, ext-all-debug.js, line 5357
            removeFromSpecialCache: function(o) {
                var i = 0,
                    len = specialElCache.length;
                    
                for (; i < len; ++i) {
                    if (specialElCache[i].el == o) {
                        specialElCache.splice(i, 1); 
                    }
                }
            },
    When "specialElCache.splice(i, 1);" removes an item from the "specialElCache" array, array length is no longer "len" and causes "TypeError: specialElCache[i] is undefined" (Firefox) when iterating past the end of the array.

    I am now using temporary fix:

    Update May 2013: The previous fix solved the problem in IE9 (the only version of IE I've tested this time around) and caused another - some elements no longer get automatically destroyed and stayed visible. This is not a detailed problem description because I don't have the time to look into it. My solution is simply to bypass the function entirely if browser is IE. Works great so far. New fix is below:

    Code:
            removeFromSpecialCache: function(o) {
                if(Ext.isIE){return}
    
                var i = 0,
                    len = specialElCache.length;
    
                for (; i < len; ++i) {
                    if (specialElCache[i].el == o) {
                        specialElCache.splice(i, 1);
                        len--;
                    }
                }
            },

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,118
    Vote Rating
    855
    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


    Thanks for the report! I have opened a bug in our bug tracker.

  3. #3
    Sencha User
    Join Date
    May 2009
    Posts
    18
    Vote Rating
    0
    padraig is on a distinguished road

      0  

    Default


    Any update on this bug? I'm getting it when I call destroy() on an Ext.Window component.
    Padraig.

  4. #4
    Sencha User
    Join Date
    Nov 2010
    Posts
    7
    Vote Rating
    0
    Sergeith is on a distinguished road

      0  

    Default


    I have the same bug on FireFox (Extjs 3.4.1)

  5. #5
    Sencha User
    Join Date
    May 2009
    Posts
    18
    Vote Rating
    0
    padraig is on a distinguished road

      0  

    Default


    For me it happens when I've got 2 htmleditor components on the window and I call destroy() on the window. With only 1 htmleditor on the window, the error does not occur.

    It happens on the 2nd call to
    Code:
    Ext.EventManager.removeFromSpecialCache(doc);
    in the beforeDestroy() function of Ext.form.HtmlEditor()
    Padraig.

  6. #6
    Sencha User
    Join Date
    Jun 2013
    Posts
    2
    Vote Rating
    0
    richwastaken is on a distinguished road

      0  

    Default


    Also experienced this defect on Extjs 3.4.1.1. but using the following for loop

    Code:
    for (; i < len; ) {
        if (specialElCache[i].el == o) {
            specialElCache.splice(i, 1);
            len--;
        } else {
            i++;
        }
    }
    because splice removes the element and moves the remaining elements down one index value. A four element array would look like 0,1,2,3 after splicing element with index 2, the array looks like 0,1,2.

    Developer @ Starfish Retention Solutions
    Software Developer
    Starfish Retention Solutions