return elem.getAttribute( name );
}
ret = elem.getAttributeNode( name );
- // Return undefined if not specified instead of empty string
- return ret && ret.specified ?
+ // Return undefined if nodeValue is empty string
+ return ret && ret.nodeValue !== "" ?
ret.nodeValue :
undefined;
},
});
test("attr(String, Object)", function() {
- expect(57);
+ expect(58);
var div = jQuery("div").attr("foo", "bar"),
fail = false;
equals( jQuery("#name").attr("name"), "something", "Set name attribute" );
jQuery("#name").attr("name", null);
equals( jQuery("#name").attr("name"), undefined, "Remove name attribute" );
+ var $input = jQuery("<input>", { name: "something" });
+ equals( $input.attr("name"), "something", "Check element creation gets/sets the name attribute." );
jQuery("#check2").prop("checked", true).prop("checked", false).attr("checked", true);
equals( document.getElementById("check2").checked, true, "Set checked attribute" );