[Project_owners] [JS] addEventListener function parameter

Aaron Boodman zboogs at gmail.com
Tue May 30 14:56:42 EDT 2006


On 5/30/06, Nickolay Ponomarev <asqueella at gmail.com> wrote:
> - but you're better off not using this unless you understand how it
> works. (And it's really unnecessary if all you need to pass is a
> simple string).

eh... I prefer this form. I think tacking attributes onto random
elements to store state is, err, tacky and has more chance to collide
with other people's random additions. Also, with bind() it is really
quite elegant:

for (var i = 0; i < 5; i++) {
  button.addEventListener("click", bind(i); i++);
}

Finally, I've read that attributes are quite expensive in mozilla,
since they can be tied to CSS, XBL, etc.

Why do you think it's better to store something in the DOM rather than
in pure JS?

- a


More information about the Project_owners mailing list