-
Notifications
You must be signed in to change notification settings - Fork 264
/
Copy pathjQuery.uniqueSort.xml
46 lines (44 loc) · 2.06 KB
/
jQuery.uniqueSort.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?xml version="1.0"?>
<entry type="method" name="jQuery.uniqueSort" return="Array">
<title>jQuery.uniqueSort()</title>
<signature>
<added>1.12-and-2.2</added>
<argument name="array" type="ArrayLikeObject">
<desc>The Array or an Array-like object of DOM elements.</desc>
</argument>
</signature>
<desc>Sorts an array or an array-like object of DOM elements, in place, with the duplicates removed. Note that this only works on arrays/array-likes of DOM elements, not strings or numbers.</desc>
<longdesc>
<p>The <code>$.uniqueSort()</code> function searches through an array or an array-like object of DOM elements, sorting the array/array-like, and removing any duplicate nodes. A node is considered a duplicate if it is the <em>exact same</em> node as one already in the input; two different nodes with identical attributes are not considered to be duplicates. This function only works on plain JavaScript arrays/array-like objects of DOM elements, and is chiefly used internally by jQuery. You probably will never need to use it.</p>
<p>Prior to jQuery 3.0, this method was called <code><a href="/jQuery.unique/">jQuery.unique()</a></code>.</p>
<p>As of jQuery 1.4 the results will always be returned in document order.</p>
</longdesc>
<example>
<desc>Removes any duplicate elements from the array of divs.</desc>
<code><![CDATA[
// uniqueSort() must take a native array
var divs = $( "div" ).get();
// Add 3 elements of class dup too (they are divs)
divs = divs.concat( $( ".dup" ).get() );
$( "div" ).eq( 1 ).text( "Pre-uniqueSort there are " + divs.length + " elements." );
divs = jQuery.uniqueSort( divs );
$( "div" ).eq( 2 ).text( "Post-uniqueSort there are " + divs.length + " elements." )
.css( "color", "red" );
]]></code>
<css><![CDATA[
div {
color: blue;
}
]]></css>
<html><![CDATA[
<div>There are 6 divs in this document.</div>
<div></div>
<div class="dup"></div>
<div class="dup"></div>
<div class="dup"></div>
<div></div>
]]></html>
</example>
<category slug="utilities"/>
<category slug="version/1.12-and-2.2"/>
</entry>