Bug Tracker

Opened 7 years ago

Closed 7 years ago

#11874 closed bug (invalid)

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

Reported by: jbowman@… Owned by: jbowman@…
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.

Change History (4)

comment:1 Changed 7 years ago by jbowman@…

The second example should be:

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

comment:2 Changed 7 years ago by dmethvin

Component: unfiledselector
Priority: undecidedlow
Status: newopen

comment:3 Changed 7 years ago by timmywil

Owner: set to jbowman@…
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?

comment:4 Changed 7 years ago by trac-o-bot

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!

Note: See TracTickets for help on using tickets.