[jQuery] dashes in attribute names illegal?

[jQuery] dashes in attribute names illegal?


> Something else I've noticed in my debugging is that $.attr is getting
> called many,many times in the course of a single $() call such as this:
> $('input[@x-hover]')
> I'm guessing it's being called for each input element matched, but it
> shouldn't have to translate the attribute name every time it does it.
This brings up a good point about performance. The DOM only provides two
good functions for grabbing specific nodes: getElementById and
getElementsByTagName. It looks like $.Select uses both when it can, but in
many cases it has to crawl through a good chunk of the document tree to find
the right nodes. In the case above it can use gEBTN to get all the input
nodes in the document, but it still has to go through each one of them
checking for an x-hover attribute.
If the page doesn't have input nodes added or removed at runtime, it's
fastest to select the nodes on document ready/load and cache that in a
global variable. JQuery can't do the caching since it doesn't know whether
or how the document tree will change at runtime. I'm not sure that $.attr
needs to have the translation in there at all, but if so it's only two lines
of code. I suspect that any attempt to cache the translated attribute names
would involve a lot more runtime and code than that.
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/