]> source.dussan.org Git - jquery.git/commitdiff
Switch back to using Sizzle.matchesSelector.
authorjeresig <jeresig@gmail.com>
Sun, 10 Oct 2010 19:36:02 +0000 (15:36 -0400)
committerjeresig <jeresig@gmail.com>
Sun, 10 Oct 2010 19:36:02 +0000 (15:36 -0400)
speed/filter.html
src/traversing.js

index f24ed7d9455fbaec966844850da261970abb349b..43ee94e5209c6b55cdcc456ecfdeeaa91ebb499d 100644 (file)
@@ -14,8 +14,8 @@
        setTimeout(function(){
                name = "filter '" + item + "'";
                jQuery("#results").append("<li>" + name + "<ul>" +
-                       "<li>new: " + benchmarkString("$('div').filter('" + item + "')", 1000, name) + "</li>" +
-                       "<li>old: " + benchmarkString("old('div').filter('" + item + "')", 1000, name) + "</li>" +
+                       "<li>new: " + benchmarkString("$('div').filter('" + item + "')", 100, name) + "</li>" +
+                       "<li>old: " + benchmarkString("old('div').filter('" + item + "')", 100, name) + "</li>" +
                        "</ul></li>");
                jQuery("#results").append("<li>single " + name + "<ul>" +
                        "<li>new: " + benchmarkString("$('#nonexistant').filter('" + item + "')", 1000, name) + "</li>" +
index df431781a0b7189d76b6a9eb3b18c92d7b5737d5..c473c75833d4b5e10b6afbe5c66691fb44d6f4f2 100644 (file)
@@ -6,9 +6,8 @@ var runtil = /Until$/,
        rmultiselector = /,/,
        rchild = /^\s*>/,
        isSimple = /^.[^:#\[\.,]*$/,
-       slice = Array.prototype.slice;
-
-var POS = jQuery.expr.match.POS;
+       slice = Array.prototype.slice,
+       POS = jQuery.expr.match.POS;
 
 jQuery.fn.extend({
        find: function( selector ) {
@@ -100,13 +99,13 @@ jQuery.fn.extend({
                var pos = POS.test( selectors ) ? 
                        jQuery( selectors, context || this.context ) : null;
 
-               var ret = [];
+               ret = [];
 
                for ( var i = 0, j = this.length; i < j; i++ ) {
                        var cur = this[i];
 
                        while ( cur ) {
-                               if ( pos ? pos.index(cur) > -1 : jQuery.find.matches(selectors, cur) ) {
+                               if ( pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors) ) {
                                        ret.push( cur );
                                        break;
 
@@ -229,7 +228,9 @@ jQuery.extend({
                        expr = ":not(" + expr + ")";
                }
 
-               return jQuery.find.matches(expr, elems);
+               return elems.length === 1 ?
+                       jQuery.find.matchesSelector(elems[0], expr) ? [ elems[0] ] : [] :
+                       jQuery.find.matches(expr, elems);
        },
        
        dir: function( elem, dir, until ) {