From: Marek Lewandowski Date: Mon, 13 Jul 2015 12:39:52 +0000 (+0200) Subject: Selector: Define jQuery.uniqueSort in selector-native too X-Git-Tag: 2.2.0~181 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=bf591fb597a056bf2fc9bc474010374695b18d1a;p=jquery.git Selector: Define jQuery.uniqueSort in selector-native too Fixes gh-2466 Closes gh-2467 --- diff --git a/src/selector-native.js b/src/selector-native.js index 5717918bc..2d5cb3026 100644 --- a/src/selector-native.js +++ b/src/selector-native.js @@ -67,6 +67,28 @@ var hasDuplicate, // Not directly comparable, sort on existence of method return a.compareDocumentPosition ? -1 : 1; + }, + uniqueSort = function( results ) { + var elem, + duplicates = [], + i = 0, + j = 0; + + hasDuplicate = false; + results.sort( sortOrder ); + + if ( hasDuplicate ) { + while ( (elem = results[i++]) ) { + if ( elem === results[ i ] ) { + j = duplicates.push( i ); + } + } + while ( j-- ) { + results.splice( duplicates[ j ], 1 ); + } + } + + return results; }; jQuery.extend({ @@ -99,28 +121,8 @@ jQuery.extend({ return results; }, - unique: function( results ) { - var elem, - duplicates = [], - i = 0, - j = 0; - - hasDuplicate = false; - results.sort( sortOrder ); - - if ( hasDuplicate ) { - while ( (elem = results[i++]) ) { - if ( elem === results[ i ] ) { - j = duplicates.push( i ); - } - } - while ( j-- ) { - results.splice( duplicates[ j ], 1 ); - } - } - - return results; - }, + uniqueSort: uniqueSort, + unique: uniqueSort, text: function( elem ) { var node, ret = "",