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: |
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 (8)
comment:1 Changed 12 years ago by
Component: | unfiled → selector |
---|---|
Milestone: | None → 1.next |
Priority: | undecided → low |
Status: | new → open |
comment:2 Changed 12 years ago by
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:4 Changed 12 years ago by
Do what? Applied selectors after filtering elements by class name.
comment:5 Changed 12 years ago by
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
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
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
Resolution: | → wontfix |
---|---|
Status: | open → closed |
Type: | bug → enhancement |
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.
That is a little strange: http://jsfiddle.net/timmywil/j29XG/5/