Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Switch back to using Sizzle.matchesSelector.

  • Loading branch information...
commit ba149e78a93afa9eab544c7defe3ccf0d412345a 1 parent eb67d99
@jeresig jeresig authored
Showing with 9 additions and 8 deletions.
  1. +2 −2 speed/filter.html
  2. +7 −6 src/traversing.js
View
4 speed/filter.html
@@ -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>" +
View
13 src/traversing.js
@@ -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 ) {

11 comments on commit ba149e7

@rwaldron
Collaborator

Running the unit tests, I'm getting:

core: selector state (2, 18, 20)

Died on test #19: jQuery.find.matchesSelector is not a function

Unfortunately, I'm on my way out now and dont have time to write and submit a patch. Sorry.

@jeresig

You need to pull in the latest copy of Sizzle.

@rwaldron
Collaborator

ok cool, I just pulled this down and ran 'make' ... Should the build process be updated to check for new sizzle (and qunit while we're at it)?

@jeresig

It already does - running make runs make init - which pulls in the latest code from Sizzle and QUnit.

@rwaldron
Collaborator

So, that's what I thought - but I pulled down all the latest commits from jquery master and then ran make, followed by opening the test suites and getting the failure. I will check through all my local files when I get home (sorry, I'm posting from mobile)

@dmethvin
Owner

Rick, I use the Ant build and it definitely saw the change in Sizzle and rebuilt it.

@csnover

After I ran make, the Sizzle repo was reported as being up-to-date, but sizzle.js was in a modified state such that all of the new changes were removed (running git diff showed basically a reverse diff of the latest Sizzle update). I had to git reset --hard HEAD in src/sizzle to fix it. Dan Heberden also reported this problem and that this solution worked. Not sure if this is an artefact of making changes or if the Makefile is doing something wrong when pulling external dependencies or what.

@rwaldron
Collaborator

I'm still getting errors and i definitely have an updated version. The errors had gone away but have returned.... this is a comment i left on the sizzle.js commit ( http://github.com/jeresig/sizzle/commit/b6d5e1761da834fd213ecfb92d5e4c7f278ac2dc ) :

This change wasn't updated in jquery/src/traversing.js

http://github.com/jquery/jquery/blob/master/src/traversing.js#L99

which causes massive unit test failures. I patched my local copy and the tests that were failing are passing, but now there are massive selector related failures across the modules: attributes.js(71, 72, 73), events.js(103,105,106,107,108,109,110,112,113,114) traversing.js(133,136,141,142, 154,156,157,158, 161,162) manipulation.js(199,200,203,204,294, 299,304,309,314,319,324,329,331,333,336,338,342,348)

@jeresig

And to clarify for others: Make sure that you run 'make clean' before running 'make' - that seems to help these odd cases.

@rwaldron
Collaborator

Yes, exactly. I thought I had deleted this comment, as well as the one on sizzle. Apparently, deleting comments doesn't actually do anything except for remove them from the DOM.

Please sign in to comment.
Something went wrong with that request. Please try again.