Update test case to feature-detect Opera's lack of defaultPrevented and skip the...
[jquery.git] / speed / closest.html
1 <!doctype html>
2 <html>
3 <head>
4         <title>Test .closest() Performance</title>
5         <script src="benchmark.js"></script>
6         <script src="jquery-basis.js"></script>
7         <script>var old = jQuery.noConflict(true);</script>
8         <script src="../dist/jquery.js"></script>
9   <script>
10     jQuery(function ready() {
11       var node = $("#child"), name;
12
13       jQuery.each([".zoo", "#zoo", "[data-foo=zoo]", "#nonexistant"], function(i, item) {
14         setTimeout(function(){
15                 name = "closest '" + item + "'";
16
17                 jQuery("#results").append("<li>" + name + "<ul>" +
18                         "<li>new: " + benchmarkString("$('#child').closest('" + item + "')", 2500, name) + "</li>" +
19                         "<li>old: " + benchmarkString("old('#child').closest('" + item + "')", 2500, name) + "</li>"
20                         + "</ul></li>");
21         }, 100);
22       });
23     });
24   </script>
25 </head>
26 <body>
27   <div>
28     <p>Hello</p>
29     <div class="zoo" id="zoo" data-foo="bar">
30       <div>
31         <p id="child">lorem ipsum</p>
32         <p>dolor sit amet</p>
33       </div>
34     </div>
35   </div>
36   <ul id="results"></ul>
37 </body>
38 </html>
39