Also test for single element filtering.

This commit is contained in:
jeresig 2010-10-10 14:51:11 -04:00
parent f2b028f736
commit 1f7bbd8939

View File

@ -13,11 +13,14 @@
jQuery.each([".zoo", "#zoo", "[data-foo=zoo]", "#nonexistant"], function(i, item) { jQuery.each([".zoo", "#zoo", "[data-foo=zoo]", "#nonexistant"], function(i, item) {
setTimeout(function(){ setTimeout(function(){
name = "filter '" + item + "'"; name = "filter '" + item + "'";
jQuery("#results").append("<li>" + name + "<ul>" + jQuery("#results").append("<li>" + name + "<ul>" +
"<li>new: " + benchmarkString("$('div').filter('" + item + "')", 1000, name) + "</li>" + "<li>new: " + benchmarkString("$('div').filter('" + item + "')", 1000, name) + "</li>" +
"<li>old: " + benchmarkString("old('div').filter('" + item + "')", 1000, name) + "</li>" "<li>old: " + benchmarkString("old('div').filter('" + item + "')", 1000, name) + "</li>" +
+ "</ul></li>"); "</ul></li>");
jQuery("#results").append("<li>single " + name + "<ul>" +
"<li>new: " + benchmarkString("$('#nonexistant').filter('" + item + "')", 1000, name) + "</li>" +
"<li>old: " + benchmarkString("old('#nonexistant').filter('" + item + "')", 1000, name) + "</li>" +
"</ul></li>");
}, 100); }, 100);
}); });
}); });
@ -26,6 +29,8 @@
<body> <body>
<div> <div>
<p>Hello</p> <p>Hello</p>
<div class="zoo" id="nonexistant" data-foo="bar"><div></div></div>
<div class="zoo" id="zoo" data-foo="bar"><div></div></div>
<div class="zoo" id="zoo" data-foo="bar"><div></div></div> <div class="zoo" id="zoo" data-foo="bar"><div></div></div>
<div class="zoo" id="zoo" data-foo="bar"><div></div></div> <div class="zoo" id="zoo" data-foo="bar"><div></div></div>
<div class="zoo" id="zoo" data-foo="bar"><div></div></div> <div class="zoo" id="zoo" data-foo="bar"><div></div></div>