Skip to content

Commit 742c377

Browse files
committed
jQuery.uniqueSort: add new entry, deprecate jQuery.unique()
Fixes gh-731 Closes gh-736
1 parent b3d0a3f commit 742c377

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed

entries/jQuery.unique.xml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0"?>
2-
<entry type="method" name="jQuery.unique" return="Array">
2+
<entry type="method" name="jQuery.unique" return="Array" deprecated="3.0">
33
<title>jQuery.unique()</title>
44
<signature>
55
<added>1.1.3</added>
@@ -9,6 +9,7 @@
99
</signature>
1010
<desc>Sorts an array of DOM elements, in place, with the duplicates removed. Note that this only works on arrays of DOM elements, not strings or numbers.</desc>
1111
<longdesc>
12+
<p><strong>As of jQuery 3.0, this method is deprecated and just an alias of <code><a href="/jQuery.uniqueSort/">jQuery.uniqueSort()</a></code>. Please use that method instead.</strong></p>
1213
<p>The <code>$.unique()</code> function searches through an array of objects, sorting the array, 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 array; two different nodes with identical attributes are not considered to be duplicates. This function only works on plain JavaScript arrays of DOM elements, and is chiefly used internally by jQuery. You probably will never need to use it.</p>
1314
<p>As of jQuery 1.4 the results will always be returned in document order.</p>
1415
</longdesc>

entries/jQuery.uniqueSort.xml

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

0 commit comments

Comments
 (0)