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

Infinitely-growing YAHOO.util.Event listeners array and proposal for fix

Expand Messages
  • Erik Bruchez
    All, I have a situation where the listeners array keeps growing. This occurs when: * A modal dialog is shown, with a background mask * This registers, in my
    Message 1 of 3 , May 1 3:24 PM
    • 0 Attachment
      All,

      I have a situation where the "listeners" array keeps growing. This
      occurs when:

      * A modal dialog is shown, with a background mask

      * This registers, in my case, 572 focus listeners in that array

      * Upon closing the dialog and removing the mask, the 572 listeners are
      set to null in the listeners array

      * Upon a second dialog show, the dialog grows by 572 elements again
      because of the allocation strategy:

      var index = listeners.length in event.js

      * Over (little) time, showing the dialog takes seconds, and causes
      slow script dialogs to occur in IE

      It seems to me that:

      1. Allocation in this array is not optimal

      2. Focus events could possibly be registered globally anyway (upon
      capture phase with IE)

      For now, in event.js's addListner() function, I managed to improve
      allocation with the following:

      var index = -1;
      for (var i = listeners.length - 1; i >= 0; i--) {
      if (listeners[i] == null) {
      index = i;
      break;
      }
      }

      if (index == -1)
      index = listeners.length;

      It's maybe not the most efficient possible way, but at least it
      prevents the array from growing indefinitely.

      Any thoughts on this are welcome.

      -Erik

      --
      Orbeon Forms - Web Forms for the Enterprise Done the Right Way
      http://www.orbeon.com/
    • Adam Moore
      ... Erik, What version are you using? This issue was addressed in version 2.5.1. -Adam
      Message 2 of 3 , May 1 3:35 PM
      • 0 Attachment
        On Thu, May 01, 2008 at 03:24:43PM -0700, Erik Bruchez wrote:
        > I have a situation where the "listeners" array keeps growing. This
        > occurs when:

        Erik,

        What version are you using? This issue was addressed in version 2.5.1.

        -Adam
      • Erik Bruchez
        ... A slightly older version. It seems like I need to upgrade then. Thanks, -Erik
        Message 3 of 3 , May 1 4:22 PM
        • 0 Attachment
          --- In ydn-javascript@yahoogroups.com, Adam Moore <adamoore@...> wrote:
          >
          > On Thu, May 01, 2008 at 03:24:43PM -0700, Erik Bruchez wrote:
          > > I have a situation where the "listeners" array keeps growing. This
          > > occurs when:
          >
          > Erik,
          >
          > What version are you using? This issue was addressed in version 2.5.1.

          A slightly older version. It seems like I need to upgrade then.

          Thanks,

          -Erik
        Your message has been successfully submitted and would be delivered to recipients shortly.