Permalink
Browse files

Make sure button:submit works, also simplify some of the nodeName acc…

…esses.
  • Loading branch information...
1 parent d2d8400 commit b079e80b4e05df891e25158e6ead3e2c4e59890b @jeresig jeresig committed Apr 12, 2011
Showing with 4 additions and 3 deletions.
  1. +4 −3 sizzle.js
View
@@ -645,7 +645,8 @@ var Expr = Sizzle.selectors = {
},
submit: function( elem ) {
- return elem.nodeName.toLowerCase() === "input" && "submit" === elem.type;
+ var name = elem.nodeName.toLowerCase();
+ return (name === "input" || name === "button") && "submit" === elem.type;
},
image: function( elem ) {
@@ -657,8 +658,8 @@ var Expr = Sizzle.selectors = {
},
button: function( elem ) {
- return elem.nodeName.toLowerCase() === "input" && "button" === elem.type ||
- elem.nodeName.toLowerCase() === "button";
+ var name = elem.nodeName.toLowerCase();
+ return name === "input" && "button" === elem.type || name === "button";
},
input: function( elem ) {

3 comments on commit b079e80

@staabm
Contributor
staabm commented on b079e80 Apr 13, 2011

there are also buttons with input type="image" which may trigger the form submit..

http://www.w3schools.com/tags/att_input_type.asp

@danheberden
Member

Actually any button will trigger it. The check on 649 is checking for any inputs or buttons with type === submit. You could have


Dont Submit

and it will still have type === submit (and of course, have a tagName of "BUTTON" )

@staabm
Contributor

be carefull, I'm talking about 'input type="image"' not a 'button'- tag...

at the moment 'input type="image"' won't be considered as a submit-button, but it is one per spec.

Please sign in to comment.