Ticket #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: | ||
| Blocking: | Blocked by: |
Description
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
comment:1 Changed 20 months ago by timmywil
- Priority changed from undecided to low
- Status changed from new to open
- Component changed from unfiled to selector
- Milestone changed from None to 1.next
comment:2 Changed 20 months 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 20 months ago by rwaldron
Investigate and then do what? The alternatives are terrifying.
comment:4 Changed 20 months ago by anonymous
Do what? Applied selectors after filtering elements by class name.
comment:5 Changed 20 months 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 20 months 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 20 months 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",...
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

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