Skip to content
Permalink
Browse files

Make sure setting boolean attributes to the same name sets the proper…

…ty to a boolean type
  • Loading branch information...
timmywil
timmywil committed May 13, 2011
1 parent 6f676e6 commit bc82ff0ff9faba5e7e8c3e40f1351fb5e3fc1a41
Showing with 7 additions and 2 deletions.
  1. +1 −1 src/attributes.js
  2. +6 −1 test/unit/attributes.js
@@ -481,7 +481,7 @@ boolHook = {
propName = jQuery.propFix[ name ] || name;
if ( propName in elem ) {
// Only set the IDL specifically if it already exists on the element
elem[ propName ] = value;
elem[ propName ] = true;
}

elem.setAttribute( name, name.toLowerCase() );
@@ -150,7 +150,7 @@ test("attr(Hash)", function() {
});

test("attr(String, Object)", function() {
expect(66);
expect(69);

var div = jQuery("div").attr("foo", "bar"),
fail = false;
@@ -199,6 +199,11 @@ test("attr(String, Object)", function() {
equals( jQuery("#check2").prop("checked"), false, "Set checked attribute" );
equals( jQuery("#check2").attr("checked"), undefined, "Set checked attribute" );

jQuery("#check2").attr("checked", "checked");
equal( document.getElementById("check2").checked, true, "Set checked attribute with 'checked'" );
equal( jQuery("#check2").prop("checked"), true, "Set checked attribute" );
equal( jQuery("#check2").attr("checked"), "checked", "Set checked attribute" );

jQuery("#text1").prop("readOnly", true);
equals( document.getElementById("text1").readOnly, true, "Set readonly attribute" );
equals( jQuery("#text1").prop("readOnly"), true, "Set readonly attribute" );

0 comments on commit bc82ff0

Please sign in to comment.
You can’t perform that action at this time.