Skip to main content

Bug Tracker

Side navigation

#11874 closed bug (invalid)

Opened June 07, 2012 12:37PM UTC

Closed July 03, 2012 08:39AM UTC

Error Extending $.expr[':'] in IE7 and IE8

Reported by: jbowman@wizbit.net Owned by: jbowman@wizbit.net
Priority: low Milestone: None
Component: selector Version: 1.7.2
Keywords: Cc:
Blocked by: Blocking:
Description

It appears that extending $.expr[':'] in IE7 and IE8 has a bug.

This occurs whether extending by using:

$.extend($.expr[':'], { newexpr: function(elem, i, m, array) { ...

or just

$.expr.newexpr = function(elem, i, m, array) { ...

For example: $('.someclass:newexpr(#argument)) in Firefox, IE9 and WebKit browsers passes #argument as elem and $('.someclass') as array.

In IE7 and IE8 elem is passed okay BUT every tag on the page is passed to array.

In most cases this is not noticable especially if these erroneous tags don't satisfy the expression, but on long pages (with >1k tags) or if the tags do happen to satisfy the expression this can cause issues.

In my case (using Aaron Brandon's 'overlap' plugin) offset() was being called 1.4 million times, causing the script to 'hang' for 3.5 minutes!

I have tested this in 1.7.2, 1.7.1, 1.6.2, and 1.4.2 and the behaviour is consistent. I haven't tested different versions of JQUI as I believe this behaviour is not JQUI related.

I have created a shortened test case here -- Also as a Fiddle.

In IE9, FF, Chrome and Safari, on dragging any of the boxes (I have reduced this down from a real life situation) the expression is triggered on 'dragstop', and the first alert box shows the length of $(elem) [1 - correct]; the second box shows the length of array [5 - correct]. These boxes loop for each of the five elements in array.

In IE7 and IE8, the second alert shows 14. Looping through array, it lists 14 HTMLxxxxElement, starting with the HTMLCommentElement (DOCTYPE) and ending with the 5th HTMLDivElement.

I'm new to this bug-reporting lark, so if I've missed anything, please let me know!

Thanks.

Attachments (0)
Change History (4)

Changed June 07, 2012 12:45PM UTC by jbowman@wizbit.net comment:1

The second example should be:

$.expr[':']..newexpr = function(elem, i, m, array) { ... (missed the [':'])

Changed June 12, 2012 02:59PM UTC by dmethvin comment:2

component: unfiledselector
priority: undecidedlow
status: newopen

Changed June 19, 2012 06:48AM UTC by timmywil comment:3

owner: → jbowman@wizbit.net
status: openpending

There is far too much going on here. I've reduced the test case so it does not include jQuery UI and the custom selector is behaving as expected. http://jsfiddle.net/ghBzu/1/

Can you adjust the test case to demonstrate an issue with jQuery core?

Changed July 03, 2012 08:39AM UTC by trac-o-bot comment:4

resolution: → invalid
status: pendingclosed

Because we get so many tickets, we often need to return them to the initial reporter for more information. If that person does not reply within 14 days, the ticket will automatically be closed, and that has happened in this case. If you still are interested in pursuing this issue, feel free to add a comment with the requested information and we will be happy to reopen the ticket if it is still valid. Thanks!