A follow-up to [6578] (which stopped adding expandos to elements that didn't have...
[jquery.git] / src / selector.js
index c6fc025..de8830a 100644 (file)
@@ -144,6 +144,8 @@ Sizzle.uniqueSort = function(results){
                        }
                }
        }
+
+       return results;
 };
 
 Sizzle.matches = function(expr, set){
@@ -551,7 +553,7 @@ var Expr = Sizzle.selectors = {
                        } else if ( name === "not" ) {
                                var not = match[3];
 
-                               for ( i = 0, l = not.length; i < l; i++ ) {
+                               for ( var i = 0, l = not.length; i < l; i++ ) {
                                        if ( not[i] === elem ) {
                                                return false;
                                        }
@@ -661,7 +663,7 @@ for ( var type in Expr.match ) {
 }
 
 var makeArray = function(array, results) {
-       array = Array.prototype.slice.call( array );
+       array = Array.prototype.slice.call( array, 0 );
 
        if ( results ) {
                results.push.apply( results, array );
@@ -674,7 +676,7 @@ var makeArray = function(array, results) {
 // Perform a simple check to determine if the browser is capable of
 // converting a NodeList to an array using builtin methods.
 try {
-       Array.prototype.slice.call( document.documentElement.childNodes );
+       Array.prototype.slice.call( document.documentElement.childNodes, 0 );
 
 // Provide a fallback method if it does not work
 } catch(e){
@@ -703,6 +705,13 @@ var sortOrder;
 
 if ( document.documentElement.compareDocumentPosition ) {
        sortOrder = function( a, b ) {
+               if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) {
+                       if ( a == b ) {
+                               hasDuplicate = true;
+                       }
+                       return 0;
+               }
+
                var ret = a.compareDocumentPosition(b) & 4 ? -1 : a === b ? 0 : 1;
                if ( ret === 0 ) {
                        hasDuplicate = true;
@@ -711,6 +720,13 @@ if ( document.documentElement.compareDocumentPosition ) {
        };
 } else if ( "sourceIndex" in document.documentElement ) {
        sortOrder = function( a, b ) {
+               if ( !a.sourceIndex || !b.sourceIndex ) {
+                       if ( a == b ) {
+                               hasDuplicate = true;
+                       }
+                       return 0;
+               }
+
                var ret = a.sourceIndex - b.sourceIndex;
                if ( ret === 0 ) {
                        hasDuplicate = true;
@@ -719,6 +735,13 @@ if ( document.documentElement.compareDocumentPosition ) {
        };
 } else if ( document.createRange ) {
        sortOrder = function( a, b ) {
+               if ( !a.ownerDocument || !b.ownerDocument ) {
+                       if ( a == b ) {
+                               hasDuplicate = true;
+                       }
+                       return 0;
+               }
+
                var aRange = a.ownerDocument.createRange(), bRange = b.ownerDocument.createRange();
                aRange.selectNode(a);
                aRange.collapse(true);
@@ -1036,6 +1059,8 @@ jQuery.sibling = function(n, elem){
        return r;
 };
 
+jQuery.unique = Sizzle.uniqueSort;
+
 return;
 
 window.Sizzle = Sizzle;