Permalink
Browse files

Merge conflict in unit test

  • Loading branch information...
2 parents 772c1f6 + 69ecd01 commit 4bcc09702d6dadfd0b90c7de3c8b206e97ff97f4 timmywil committed Apr 17, 2011
Showing with 36 additions and 11 deletions.
  1. +1 −1 README
  2. +16 −9 sizzle.js
  3. +19 −1 test/unit/selector.js
View
2 README
@@ -7,7 +7,7 @@ Discussion:
http://groups.google.com/group/sizzlejs
Documentation:
- http://wiki.github.com/jeresig/sizzle
+ http://wiki.github.com/jquery/sizzle
Testing Sizzle:
- Open test/index.html in your browser to run the tests.
View
@@ -625,42 +625,49 @@ var Expr = Sizzle.selectors = {
var attr = elem.getAttribute( "type" ), type = elem.type;
// IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc)
// use getAttribute instead to test this case
- return "text" === type && ( attr === type || attr === null );
+ return elem.nodeName.toLowerCase() === "input" && "text" === type && ( attr === type || attr === null );
},
radio: function( elem ) {
- return "radio" === elem.type;
+ return elem.nodeName.toLowerCase() === "input" && "radio" === elem.type;
},
checkbox: function( elem ) {
- return "checkbox" === elem.type;
+ return elem.nodeName.toLowerCase() === "input" && "checkbox" === elem.type;
},
file: function( elem ) {
- return "file" === elem.type;
+ return elem.nodeName.toLowerCase() === "input" && "file" === elem.type;
},
+
password: function( elem ) {
- return "password" === elem.type;
+ return elem.nodeName.toLowerCase() === "input" && "password" === elem.type;
},
submit: function( elem ) {
- return "submit" === elem.type;
+ var name = elem.nodeName.toLowerCase();
+ return (name === "input" || name === "button") && "submit" === elem.type;
},
image: function( elem ) {
- return "image" === elem.type;
+ return elem.nodeName.toLowerCase() === "input" && "image" === elem.type;
},
reset: function( elem ) {
- return "reset" === elem.type;
+ return elem.nodeName.toLowerCase() === "input" && "reset" === elem.type;
},
button: function( elem ) {
- return "button" === elem.type || elem.nodeName.toLowerCase() === "button";
+ var name = elem.nodeName.toLowerCase();
+ return name === "input" && "button" === elem.type || name === "button";
},
input: function( elem ) {
return (/input|select|textarea|button/i).test( elem.nodeName );
+ },
+
+ focus: function( elem ) {
+ return elem === elem.ownerDocument.activeElement;
}
},
setFilters: {
View
@@ -406,7 +406,7 @@ test("pseudo - child", function() {
});
test("pseudo - misc", function() {
- expect(7);
+ expect(10);
t( "Headers", ":header", ["qunit-header", "qunit-banner", "qunit-userAgent"] );
t( "Has Children - :has()", "p:has(a)", ["firstp","ap","en","sap"] );
@@ -419,6 +419,24 @@ test("pseudo - misc", function() {
t( "Text Contains", "a:contains(Google Groups (Link))", ["groups"] );
t( "Text Contains", "a:contains((Link))", ["groups"] );
+
+ var input = document.createElement("input");
+ input.type = "text";
+ input.id = "focus-input";
+
+ document.body.appendChild( input );
+
+ input.focus();
+
+ t( "Element focused", "input:focus", [ "focus-input" ] );
+
+ ok( (window.Sizzle || window.jQuery.find).matchesSelector( input, ":focus" ), ":focus Matches" );
+
+ input.blur();
+
+ ok( !(window.Sizzle || window.jQuery.find).matchesSelector( input, ":focus" ), ":focus Doesn't Match" );
+
+ document.body.removeChild( input );
});

0 comments on commit 4bcc097

Please sign in to comment.