Bug Tracker

Opened 11 years ago

Closed 11 years ago

#12314 closed bug (fixed)

$.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/

Change History (4)

comment:1 Changed 11 years ago by dmethvin

Owner: set to 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!

comment:2 in reply to:  1 Changed 11 years ago by konp

Status: pendingnew

Replying to 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.

Last edited 11 years ago by konp (previous) (diff)

comment:3 Changed 11 years ago by dmethvin

Component: unfiledselector
Milestone: None1.8.1
Priority: undecidedlow
Status: newopen

comment:4 Changed 11 years ago by Timmy Willison

Resolution: fixed
Status: openclosed

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

Changeset: 2be615eaa16a5916d0a194e3c2f6bc2a2d62b236

Note: See TracTickets for help on using tickets.