Loading ...
Sorry, an error occurred while loading the content.

YAHOO.util.Event.getEl bug/issue

Expand Messages
  • lukechambers7
    I wanted to alert the YUI guys to a problem with YAHOO.util.Event.getEl The functionality of this method is deprecated as such: /*** We cache elements bound by
    Message 1 of 1 , Aug 1, 2007
    • 0 Attachment
      I wanted to alert the YUI guys to a problem with YAHOO.util.Event.getEl

      The functionality of this method is deprecated as such:

      /**
      * We cache elements bound by id because when the unload event
      * fires, we can no longer use document.getElementById
      * @method getEl
      * @static
      * @private
      * @deprecated Elements are not cached any longer
      */
      getEl: function(id) {
          return document.getElementById(id);
      },

      However, this causes a problem as many of the calling functions will pass either a String id or an actual HTMLElement. In the later case,
      document.getElementById will return null.

      I propose rewriting this method as the following:

      getEl: function(el) {
          return YAHOO.Dom.get(el);
      },


      We came across this issue when some profiling revealed that YAHOO.util.Event.getEl was being called nearly 15000 times in only a few seconds. Investigation revealed that our YUI buttons which are created by passing actual HTMLElements (not ids) used YAHOO.util.Event.onAvailable to poll for the availability of the element. onAvailable in turn uses getEl to determine if the element in question is available, but since getEl was being called with an element rather than an id, null was always returned and polling continued....
    Your message has been successfully submitted and would be delivered to recipients shortly.