Skip to main content

Bug Tracker

Side navigation

#10346 closed enhancement (wontfix)

Opened September 26, 2011 04:56PM UTC

Closed May 28, 2012 11:57PM UTC

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/

Attachments (0)
Change History (8)

Changed September 27, 2011 03:54PM UTC by timmywil comment:1

component: unfiledselector
milestone: None1.next
priority: undecidedlow
status: newopen

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

Changed September 27, 2011 04:35PM UTC by anonymous comment:2

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.

Changed September 27, 2011 04:40PM UTC by rwaldron comment:3

Investigate and then do what? The alternatives are terrifying.

Changed September 27, 2011 04:45PM UTC by anonymous comment:4

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

Changed September 27, 2011 05:01PM UTC by anonymous comment:5

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.

Changed September 27, 2011 05:54PM UTC by anonymous comment:6

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

http://jsfiddle.net/mRYn9/

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

Changed September 28, 2011 12:17PM UTC by anonymous comment:7

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",...

Changed May 28, 2012 11:57PM UTC by timmywil comment:8

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.