Bug Tracker

Opened 12 years ago

Closed 11 years ago

#10346 closed enhancement (wontfix)

Customized Selector loop over uneccesarry elements in IE (browser can be frozen)

Reported by: anonymous Owned by:
Priority: low Milestone: 1.next
Component: selector Version: 1.6.4
Keywords: Cc:
Blocked by: Blocking:


IE is buggy as usually. Customized Selector loop over far more elements than necessarry.

See it in action: http://jsfiddle.net/j29XG/1/

Change History (8)

comment:1 Changed 12 years ago by Timmy Willison

Component: unfiledselector
Milestone: None1.next
Priority: undecidedlow
Status: newopen

That is a little strange: http://jsfiddle.net/timmywil/j29XG/5/

comment:2 Changed 12 years ago by anonymous

After reported it, I investigated this bug a little bit. My guess is that in IE 7,8 there is no "getElementsByClassName" function, so jquery is looking for all elements in document by using "getElementsByTagName('*')" and test each element against for the class name. When I add my customized selector, it check every elements for the class name and for my selector instead of applied my customized selector after filtering elements by class name. The jQuery team should investigate if this bug occurs also for jquery selectors such as ":visible", ":hidden", ... It would slow things down for browsers who doesn't have the "getElementsByClassName" function.

comment:3 Changed 12 years ago by Rick Waldron

Investigate and then do what? The alternatives are terrifying.

comment:4 Changed 12 years ago by anonymous

Do what? Applied selectors after filtering elements by class name.

comment:5 Changed 12 years ago by anonymous

Check this: http://jsfiddle.net/j29XG/9/

It apply ":mySelector" on all document elements (meta, script, div, ...) because of ".className:mySelector" and apply ":mySelector" again on elements returned by ".className:mySelector".

So, I think there is a problem. But if you are too lazy to investigate if this bug apply also on jquery selectors and to fix this bug, fine, just forget this bug report.

comment:6 Changed 12 years ago by anonymous

This bug also apply for jquery selectors such as ":visible", ...


By fixing this bug, jQuery selectors will be faster on browsers which doesn't support "getElementsByClassName" function.

comment:7 Changed 12 years ago by anonymous

A other improvement for "getElementsByClassName" jquery fallback would be:

var arrElems=document.body.getElementsByTagName('*'); arrElems.push(document.body);

instead of: var arrElems=document.getElementsByTagName('*');

We are looking for elements with class attribute, we doesn't need to catch useless elements such as "comments", "meta", "script", "style",...

comment:8 Changed 11 years ago by Timmy Willison

Resolution: wontfix
Status: openclosed
Type: bugenhancement

This would only be changed by adding another function call to the stack, which most of the time would be a bigger performance cost than extra loops.

Note: See TracTickets for help on using tickets.