Permalink
Browse files

Fix issue with matching :reset selector, add unit tests for :submit, …

…:reset, and :button. Fixes #9154.
  • Loading branch information...
1 parent 4bcc097 commit e300eeb0547a5a6fe60e6d5c48d2a3d3020367a9 @jeresig jeresig committed May 9, 2011
Showing with 27 additions and 2 deletions.
  1. +2 −1 sizzle.js
  2. +25 −1 test/unit/selector.js
View
@@ -654,7 +654,8 @@ var Expr = Sizzle.selectors = {
},
reset: function( elem ) {
- return elem.nodeName.toLowerCase() === "input" && "reset" === elem.type;
+ var name = elem.nodeName.toLowerCase();
+ return (name === "input" || name === "button") && "reset" === elem.type;
},
button: function( elem ) {
View
@@ -406,7 +406,7 @@ test("pseudo - child", function() {
});
test("pseudo - misc", function() {
- expect(10);
+ expect(19);
t( "Headers", ":header", ["qunit-header", "qunit-banner", "qunit-userAgent"] );
t( "Has Children - :has()", "p:has(a)", ["firstp","ap","en","sap"] );
@@ -420,6 +420,30 @@ test("pseudo - misc", function() {
t( "Text Contains", "a:contains(Google Groups (Link))", ["groups"] );
t( "Text Contains", "a:contains((Link))", ["groups"] );
+ var tmp = document.createElement("div");
+ tmp.id = "tmp_input";
+ document.body.appendChild( tmp );
+
+ jQuery.each( [ "button", "submit", "reset" ], function( i, type ) {
+ var input = document.createElement( "input" );
+ input.id = "input_" + type;
+ input.setAttribute( "type", type );
+ tmp.appendChild( input );
+
+ var button = document.createElement( "button" );
+ button.id = "button_" + type;
+ button.setAttribute( "type", type );
+ tmp.appendChild( button );
+
+ t( "Input Buttons :" + type, "#tmp_input :" + type, [ "input_" + type, "button_" + type ] );
+
+ ok( (window.Sizzle || window.jQuery.find).matchesSelector( input, ":" + type ), "Input Matches :" + type );
+ ok( (window.Sizzle || window.jQuery.find).matchesSelector( button, ":" + type ), "Button Matches :" + type );
+ });
+
+
+ document.body.removeChild( tmp );
+
var input = document.createElement("input");
input.type = "text";
input.id = "focus-input";

0 comments on commit e300eeb

Please sign in to comment.