Handle changing form attributes correctly when there is a child element with the same name. Fixes #4299

This commit is contained in:
David Petersen 2009-12-08 07:43:36 +08:00 committed by John Resig
parent d3dc2d1234
commit 841f9ff7a1
2 changed files with 9 additions and 2 deletions

View file

@ -218,7 +218,13 @@ jQuery.extend({
if ( name == "type" && /(button|input)/i.test(elem.nodeName) && elem.parentNode ) {
throw "type property can't be changed";
}
elem[ name ] = value;
// browsers index elements by id/name on forms, give priority to attributes.
if( jQuery.nodeName( elem, "form" ) ) {
// convert the value to a string (all browsers do this but IE) see #1070
elem.setAttribute( name, "" + value );
} else {
elem[ name ] = value;
}
}
// browsers index elements by id/name on forms, give priority to attributes.