#1292 ✓resolved

getUniqueElementID wrong for 1st invokation

Reported by Victor | December 5th, 2011 @ 10:36 AM

When invoking getUniqueElementID() for the first time (e.g. from Element#observe) it returns zero UID as for window:

  var UID = 0;

  GLOBAL.Element.Storage = { UID: 0 };

  function getUniqueElementID(element) {
    if (element === window) return 0;

    // Need to use actual `typeof` operator to prevent errors in some
    // environments when accessing node expandos.
    if (typeof element._prototypeUID === 'undefined')
      element._prototypeUID = Element.Storage.UID++; // this line first time returns 0
    return element._prototypeUID;

Either initial value of UID should be at least 1, or preincrement should be used element._prototypeUID = ++Element.Storage.UID;.

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

The Prototype JavaScript library.

Shared Ticket Bins

People watching this ticket