Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
jQuery.uniqueSort: add new entry, deprecate jQuery.unique()
  • Loading branch information
arthurvr committed May 8, 2015
commit c759913f8af125d5455caa01615e6d37e2676d81
3 changes: 2 additions & 1 deletion entries/jQuery.unique.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
<entry type="method" name="jQuery.unique" return="Array">
<entry type="method" name="jQuery.unique" return="Array" deprecated="3.0">
<title>jQuery.unique()</title>
<signature>
<added>1.1.3</added>
Expand All @@ -9,6 +9,7 @@
</signature>
<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>
<longdesc>
<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>
<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>
<p>As of jQuery 1.4 the results will always be returned in document order.</p>
</longdesc>
Expand Down
45 changes: 45 additions & 0 deletions entries/jQuery.uniqueSort.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?xml version="1.0"?>
<entry type="method" name="jQuery.uniqueSort" return="Array">
<title>jQuery.uniqueSort()</title>
<signature>
<added>3.0</added>
<argument name="array" type="Array">
<desc>The Array of DOM elements.</desc>
</argument>
</signature>
<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>
<longdesc>
<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>
<p>Prior to jQuery 3.0, this method was called <code><a href="/jQuery.unique/">jQuery.unique()</a></code>.</p>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only really new thing to this page. Rest is copied from the jQuery.unique entry.

<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[
// unique() 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-unique there are " + divs.length + " elements." );

divs = jQuery.uniqueSort( divs );
$( "div:eq(2)" ).text( "Post-unique 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"/>
</entry>