Brought back the compareDocumentPosition code. While it is redundant in Firefox it's much faster than using indexOf.
This commit is contained in:
parent
8d9aa015c1
commit
4b7e1c906f
|
@ -684,7 +684,15 @@ try {
|
||||||
|
|
||||||
var sortOrder;
|
var sortOrder;
|
||||||
|
|
||||||
if ( Array.prototype.indexOf ) {
|
if ( document.documentElement.compareDocumentPosition ) {
|
||||||
|
sortOrder = function( a, b ) {
|
||||||
|
var ret = a.compareDocumentPosition(b) & 4 ? -1 : a === b ? 0 : 1;
|
||||||
|
if ( ret === 0 ) {
|
||||||
|
hasDuplicate = true;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
};
|
||||||
|
} else if ( Array.prototype.indexOf ) {
|
||||||
var indexOf = Array.prototype.indexOf,
|
var indexOf = Array.prototype.indexOf,
|
||||||
allSort = document.getElementsByTagName("*");
|
allSort = document.getElementsByTagName("*");
|
||||||
|
|
||||||
|
@ -695,7 +703,7 @@ if ( Array.prototype.indexOf ) {
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
};
|
};
|
||||||
} else if ( document.documentElement.sourceIndex === 1 ) {
|
} else if ( "sourceIndex" in document.documentElement ) {
|
||||||
sortOrder = function( a, b ) {
|
sortOrder = function( a, b ) {
|
||||||
var ret = a.sourceIndex - b.sourceIndex;
|
var ret = a.sourceIndex - b.sourceIndex;
|
||||||
if ( ret === 0 ) {
|
if ( ret === 0 ) {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
module("selector");
|
module("selector");
|
||||||
|
|
||||||
test("element", function() {
|
test("element", function() {
|
||||||
expect(17);
|
expect(18);
|
||||||
reset();
|
reset();
|
||||||
|
|
||||||
ok( jQuery("*").size() >= 30, "Select all" );
|
ok( jQuery("*").size() >= 30, "Select all" );
|
||||||
|
@ -25,7 +25,7 @@ test("element", function() {
|
||||||
ok( jQuery("#lengthtest input").length, '<input name="length"> cannot be found under IE, see #945' );
|
ok( jQuery("#lengthtest input").length, '<input name="length"> cannot be found under IE, see #945' );
|
||||||
|
|
||||||
// Check for unique-ness and sort order
|
// Check for unique-ness and sort order
|
||||||
//isSet( jQuery("*"), jQuery("*, *"), "Check for duplicates: *, *" );
|
isSet( jQuery("*"), jQuery("*, *"), "Check for duplicates: *, *" );
|
||||||
isSet( jQuery("p"), jQuery("p, div p"), "Check for duplicates: p, div p" );
|
isSet( jQuery("p"), jQuery("p, div p"), "Check for duplicates: p, div p" );
|
||||||
|
|
||||||
t( "Checking sort order", "h2, h1", ["header", "banner", "userAgent"] );
|
t( "Checking sort order", "h2, h1", ["header", "banner", "userAgent"] );
|
||||||
|
|
Loading…
Reference in a new issue