if ( name == "type" && jQuery.nodeName( elem, "input" ) && elem.parentNode )
throw "type property can't be changed";
- elem.setAttribute( name, value );
+ // convert the value to a string (all browsers do this but IE) see #1070
+ elem.setAttribute( name, "" + value );
}
if ( jQuery.browser.msie && /href|src/.test( name ) && !jQuery.isXMLDoc( elem ) )
});
test("attr(String, Object)", function() {
- expect(13);
+ expect(16);
var div = $("div");
div.attr("foo", "bar");
var pass = true;
$("#name").attr('maxLength', '10');
ok( document.getElementById('name').maxLength == '10', 'Set maxlength attribute' );
+ // for #1070
+ $("#name").attr('someAttr', '0');
+ equals( $("#name").attr('someAttr'), '0', 'Set attribute to a string of "0"' );
+ $("#name").attr('someAttr', 0);
+ equals( $("#name").attr('someAttr'), 0, 'Set attribute to the number 0' );
+ $("#name").attr('someAttr', 1);
+ equals( $("#name").attr('someAttr'), 1, 'Set attribute to the number 1' );
+
reset();
var type = $("#check2").attr('type');