REQUIRED INFORMATIONExt version tested:
  • Ext 4.1 ext-all-sandox-sandbox-dev
Browser versions tested against:
  • chrome 20.0.37
DOCTYPE tested against:
  • ____
Description:
  • PurgeAllListeners doesn't work for image : an error appears:Uncaught TypeError: Cannot read property 'length' of undefined
Steps to reproduce the problem:
  • add an image in html source
  • create an Ext.Element
  • call purAllListeners
The result that was expected:
  • none error
The result that occurs instead:
  • error : Uncaught TypeError : Cannot read property 'length' of undefined
Test Case:
Code:
<img id="test" src="http://www.sencha.com/img/20110215-feat-html5.png" />var elt = Ext4.get('test');
elt.purgeAllListeners();
HELPFUL INFORMATIONScreenshot or Video:
  • attached
See this URL for live test case: http://Debugging already done:
  • /**
    * Recursively removes all previous added listeners from an element and its children. Typically you will use {@link Ext.Element#purgeAllListeners}
    * directly on an Element in favor of calling this version.
    * @param {String/HTMLElement} el The id or html element from which to remove all event handlers.
    * @param {String} eventName (optional) The name of the event.
    */
    purgeElement : function(element, eventName) {
    var dom = Ext.getDom(element),
    i = 0, len;

    if (eventName) {
    EventManager.removeListener(element, eventName);
    }
    else {
    EventManager.removeAll(element);
    }

    if (dom && dom.childNodes) {
    for (len = element.childNodes.length; i < len; i++) {
    EventManager.purgeElement(element.childNodes[i], eventName);
    }
    }
    }
Possible fix:
  • /**
    * Recursively removes all previous added listeners from an element and its children. Typically you will use {@link Ext.Element#purgeAllListeners}
    * directly on an Element in favor of calling this version.
    * @param {String/HTMLElement} el The id or html element from which to remove all event handlers.
    * @param {String} eventName (optional) The name of the event.
    */
    purgeElement : function(element, eventName) {
    var dom = Ext.getDom(element),
    i = 0, len;

    if (eventName) {
    EventManager.removeListener(element, eventName);
    }
    else {
    EventManager.removeAll(element);
    }

    if (dom && dom.childNodes && element.childNodes) {
    for (len = element.childNodes.length; i < len; i++) {
    EventManager.purgeElement(element.childNodes[i], eventName);
    }
    }
    }
Additional CSS used:
  • only default ext-all-sandbox.css
Operating System:
  • fedora core 12