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 follow-up: 2 Changed 11 years ago by
Owner: | set to konp |
---|---|
Status: | new → pending |
comment:2 Changed 11 years ago by
Status: | pending → 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.
comment:3 Changed 11 years ago by
Component: | unfiled → selector |
---|---|
Milestone: | None → 1.8.1 |
Priority: | undecided → low |
Status: | new → open |
comment:4 Changed 11 years ago by
Resolution: | → fixed |
---|---|
Status: | open → closed |
Update Sizzle: passing null to $.contains should not throw an error. Fixes #12314
Changeset: 2be615eaa16a5916d0a194e3c2f6bc2a2d62b236
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!