aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2011-01-14 09:55:40 -0500
committerScott González <scott.gonzalez@gmail.com>2011-01-14 09:55:40 -0500
commite5ee89ec9a11804b39e9722f47eeeb00648f37ea (patch)
treed6657a8c90925e00ff653c5e4d79647ce9436095 /src
parenta8fa5f2ec1030bceb9a65d0237f0c92ae4e014dd (diff)
downloadjquery-e5ee89ec9a11804b39e9722f47eeeb00648f37ea.tar.gz
jquery-e5ee89ec9a11804b39e9722f47eeeb00648f37ea.zip
Avoid running jQuery.unique() for methods that are guaranteed to produce a unique result set. Fixes #7964 - Some traversal methods perform an unnecessary uniqueness check.
Diffstat (limited to 'src')
-rw-r--r--src/traversing.js11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/traversing.js b/src/traversing.js
index 689e90196..e169be084 100644
--- a/src/traversing.js
+++ b/src/traversing.js
@@ -6,7 +6,14 @@ var runtil = /Until$/,
rmultiselector = /,/,
isSimple = /^.[^:#\[\.,]*$/,
slice = Array.prototype.slice,
- POS = jQuery.expr.match.POS;
+ POS = jQuery.expr.match.POS,
+ // methods guaranteed to produce a unique set when starting from a unique set
+ guaranteedUnique = {
+ children: true,
+ contents: true,
+ next: true,
+ prev: true
+ };
jQuery.fn.extend({
find: function( selector ) {
@@ -206,7 +213,7 @@ jQuery.each({
ret = jQuery.filter( selector, ret );
}
- ret = this.length > 1 ? jQuery.unique( ret ) : ret;
+ ret = this.length > 1 && !guaranteedUnique[ name ] ? jQuery.unique( ret ) : ret;
if ( (this.length > 1 || rmultiselector.test( selector )) && rparentsprev.test( name ) ) {
ret = ret.reverse();