Skip to main content

Bug Tracker

Side navigation

#12314 closed bug (fixed)

Opened August 15, 2012 11:24PM UTC

Closed August 24, 2012 10:08PM UTC

$.contains fatal error in IE9 when 2nd parameter is null

Reported by: konp Owned by: konp
Priority: low Milestone: 1.8.1
Component: selector Version: 1.8.0
Keywords: Cc:
Blocked by: Blocking:
Description

Summary

Calls to $.contains fail when parameter is null, breaks all scripts.

Reason

The reason for failure is that when element.''compareDocumentPosition'' is called with null in IE9 it returns invalid argument. Returns false in Chrome as expected.

jQuery Version: 1.8.0

Browser: IE9 RTM

jsFiddle: http://jsfiddle.net/Zj8VQ/

Attachments (0)
Change History (4)

Changed August 15, 2012 11:27PM UTC by dmethvin comment:1

owner: → konp
status: newpending

1) Is there some place within jQuery that calls $.contains with the second arg of null? Or was this a direct use inside your own code?

2) DO NOT TAUNT HAPPY FUN $.CONTAINS!

Changed August 16, 2012 12:11AM UTC by konp comment:2

_comment0: Replying to [comment:1 dmethvin]: \ > 1) Is there some place within jQuery that calls $.contains with the second arg of `null`? Or was this a direct use inside your own code? \ \ From within jQuery UI animations callback to removeWrapper() function - the document.activeElement is used as the second parameter. In IE9, active element can be null (such is the case with certain animations and calls to .blur()). Although I found this bug in jQuery UI, I am considering this a bug in jQuery as it is a breaking change between 1.7.2 and 1.8.0. Again, please look at the same code working with 1.7.2 - http://jsfiddle.net/Zj8VQ/1 \ \ > \ > 2) DO NOT TAUNT HAPPY FUN $.CONTAINS! \ \ SRR \ \ ---- \ \ Either way, the expected behavior should be the same across browsers.1345076065521383
_comment1: Replying to [comment:1 dmethvin]: \ > 1) Is there some place within jQuery that calls $.contains with the second arg of `null`? Or was this a direct use inside your own code? \ \ From within jQuery UI animations callback to removeWrapper() function - the document.activeElement is used as the second parameter. In IE9, active element can be null (such is the case with certain animations and calls to .blur()). Although I found this bug in jQuery UI, I am considering this a bug in jQuery as it is a breaking change between 1.7.2 and 1.8.0. Again, please look at the same code working with 1.7.2 - http://jsfiddle.net/Zj8VQ/1 \ \ EDIT: In Chrome, activeElement returns body instead of null. \ \ > \ > 2) DO NOT TAUNT HAPPY FUN $.CONTAINS! \ \ SRR \ \ ---- \ \ Either way, the expected behavior should be the same across browsers.1345076397337453
status: pendingnew

Replying to [comment:1 dmethvin]:

1) Is there some place within jQuery that calls $.contains with the second arg of null? Or was this a direct use inside your own code?

From within jQuery UI animations callback to removeWrapper() function - the document.activeElement is used as the second parameter. In IE9, active element can be null (such is the case with certain animations and calls to .blur()). Although I found this bug by using jQuery UI, I am considering this a bug in jQuery as it is a breaking change between 1.7.2 and 1.8.0. Again, please look at the same code working with 1.7.2 - http://jsfiddle.net/Zj8VQ/1

EDIT: In Chrome, activeElement returns body instead of null.

2) DO NOT TAUNT HAPPY FUN $.CONTAINS!

SRR


Either way, the expected behavior should be the same across browsers.

Changed August 21, 2012 12:33AM UTC by dmethvin comment:3

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

Changed August 24, 2012 10:08PM UTC by Timmy Willison comment:4

resolution: → fixed
status: openclosed

Update Sizzle: passing null to $.contains should not throw an error. Fixes #12314

Changeset: 2be615eaa16a5916d0a194e3c2f6bc2a2d62b236