> From: Michael Geary > > The use of "this" inside an "each" loop is one of the two > major design errors in jQuery (the other being the event > system, which I'll get to another day).
Just to avoid any possible misunderstanding, I think everyone knows I consider jQuery to be a brilliant piece of work. Even so, it would be surprising if there were *no* design flaws. :-) (And "major design errors" is probably overstating it quite a bit!) The event system is actually a more subtle and interesting problem. jQuery's event system is derived from Dean Edwards' entry in the famous addEvent() recoding contest [1] that took place in September 2005. The contest specified an addEvent interface that looked good on paper but added complexity to the implementation. A small change to the specification allows for a simpler event system, like the one I coded recently for my Zvents event calendar widgets. Unfortunately, the original contest specification is gone from quirksmode, org, and the Wayback Machine at archive.org is broken right now too. Once I get a hold of the original specs I'll write up an article about this. It's a fairly interesting design exercise (of course I would say that!), even if it is too late for it to do much good for existing libraries that based their event systems on the contest entries. -Mike [1] http://www.quirksmode.org/blog/archives/2005/09/addevent_recodi.html