Bug Tracker

Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#10395 closed enhancement (invalid)

a.comparedocumentposition is not a function

Reported by: [email protected] Owned by: [email protected]
Priority: low Milestone: None
Component: misc Version: 1.6.4
Keywords: Cc:
Blocked by: Blocking:


OS: Ubuntu Linux 10.4
Browser: Firefox 3.6.22
jQuery: 1.6.4
I just put some condition to check if function or not, error not throw anymore.

} else if ( document.documentElement.compareDocumentPosition ) {

Sizzle.contains = function( a, b ) {

return !!(a.compareDocumentPosition(b) & 16);


} else if ( document.documentElement.compareDocumentPosition ) {

Sizzle.contains = function( a, b ) {

if ( a.compareDocumentPosition instanceof Function ) {

return !!(a.compareDocumentPosition(b) & 16);

return false;


Change History (4)

comment:1 Changed 11 years ago by addyosmani

Component: unfiledmisc
Owner: set to [email protected]
Priority: undecidedlow
Status: newpending

Thanks for taking the time to contribute to the jQuery project! Please provide a complete reduced test case on jsFiddle to help us assess your ticket (along with some more information about the context of this ticket - eg. is this an isolated Sizzle issue or an issue related to something jQuery is specifically doing with Sizzle? what code resulted in the issues experienced?).

Additionally, be sure to test against the jQuery Edge version to ensure the issue still exists. To get you started, use this boilerplate: http://jsfiddle.net/FrKyN/ Open the link and click to "Fork" (in the top menu) to get started.

comment:2 Changed 11 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!

comment:3 Changed 11 years ago by [email protected]

I am getting an error due to the issue covered here: 'compareDocumentPosition' is not a function of 'a'.

Strangely this is only happens on FireFox, not on Chrome.

Issue seems to be because params 'a' and 'b' are Arrays containing the respective nodes rather than the nodes themselves.

comment:4 Changed 11 years ago by anonymous

The root of the issue is passing jQuery objects to 'contains' instead of basic elements.

  • under Chrome/WebKit it works as it tries to call the native 'contains' function on the object (a jQuery object) and this succeeds because jQuery has a function 'contains'...
  • under FireFox it fails because it tries to call compareDocumentPosition which doesn't exist on the params object.

I assume Chrome succeeding is just an unintended side effect.

Note: See TracTickets for help on using tickets.