var getter = attrHandle[ name ] || jQuery.find.attr;
attrHandle[ name ] = function( elem, name, isXML ) {
- var ret, handle;
+ var ret, handle,
+ lowercaseName = name.toLowerCase();
+
if ( !isXML ) {
// Avoid an infinite loop by temporarily removing this function from the getter
- handle = attrHandle[ name ];
- attrHandle[ name ] = ret;
+ handle = attrHandle[ lowercaseName ];
+ attrHandle[ lowercaseName ] = ret;
ret = getter( elem, name, isXML ) != null ?
- name.toLowerCase() :
+ lowercaseName :
null;
- attrHandle[ name ] = handle;
+ attrHandle[ lowercaseName ] = handle;
}
return ret;
};
assert.ok( !elem.hasClass( "awesome" ), "SVG element (" + this + ") toggles the class off" );
} );
} );
+
+QUnit.test( "non-lowercase boolean attribute getters should not crash", function( assert ) {
+ assert.expect( 3 );
+
+ var elem = jQuery( "<input checked required autofocus type='checkbox'>" );
+
+ jQuery.each( {
+ checked: "Checked",
+ required: "requiRed",
+ autofocus: "AUTOFOCUS"
+ }, function( lowercased, original ) {
+ try {
+ assert.strictEqual( elem.attr( original ), lowercased,
+ "The '" + this + "' attribute getter should return the lowercased name" );
+ } catch ( e ) {
+ assert.ok( false, "The '" + this + "' attribute getter threw" );
+ }
+ } );
+} );