Bug Tracker

Ticket #12314 (closed bug: fixed)

Opened 2 years ago

Last modified 2 years ago

$.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:
Blocking: Blocked by:

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

comment:1 follow-up: ↓ 2 Changed 2 years ago by dmethvin

  • Owner set to konp
  • Status changed from new to pending

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 2 years ago by konp

  • Status changed from pending to new

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 2 years ago by konp (previous) (diff)

comment:3 Changed 2 years ago by dmethvin

  • Priority changed from undecided to low
  • Status changed from new to open
  • Component changed from unfiled to selector
  • Milestone changed from None to 1.8.1

comment:4 Changed 2 years ago by Timmy Willison

  • Status changed from open to closed
  • Resolution set to fixed

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

Changeset: 2be615eaa16a5916d0a194e3c2f6bc2a2d62b236

Note: See TracTickets for help on using tickets.