Skip to main content

Bug Tracker

Side navigation

#10395 closed enhancement (invalid)

Opened October 01, 2011 11:02AM UTC

Closed October 16, 2011 07:52AM UTC

Last modified November 29, 2011 12:31PM UTC

a.comparedocumentposition is not a function

Reported by: mohd.nawawi@gmail.com Owned by: mohd.nawawi@gmail.com
Priority: low Milestone: None
Component: misc Version: 1.6.4
Keywords: Cc:
Blocked by: Blocking:
Description

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.

Original:

=

} else if ( document.documentElement.compareDocumentPosition ) {

Sizzle.contains = function( a, b ) {

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

};

Fixed:

=

} else if ( document.documentElement.compareDocumentPosition ) {

Sizzle.contains = function( a, b ) {

if ( a.compareDocumentPosition instanceof Function ) {

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

}

return false;

};

Attachments (0)
Change History (4)

Changed October 01, 2011 04:19PM UTC by addyosmani comment:1

component: unfiledmisc
owner: → mohd.nawawi@gmail.com
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.

Changed October 16, 2011 07:52AM UTC by trac-o-bot comment:2

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!

Changed November 29, 2011 12:16PM UTC by robertedgar@netvigator.com comment:3

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.

Changed November 29, 2011 12:31PM UTC by anonymous comment:4

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.