Add tests data- and aria- attributes and the autofocus boolean attribute and some style updates in jQuery.attr
This commit is contained in:
parent
83e9ce95d7
commit
5165033883
2 changed files with 17 additions and 6 deletions
|
@ -6,7 +6,7 @@ var rclass = /[\n\t\r]/g,
|
|||
rtype = /^(?:button|input)$/i,
|
||||
rfocusable = /^(?:button|input|object|select|textarea)$/i,
|
||||
rclickable = /^a(?:rea)?$/i,
|
||||
special = /^(?:data-|aria-)/,
|
||||
rspecial = /^(?:data-|aria-)/,
|
||||
formHook;
|
||||
|
||||
jQuery.fn.extend({
|
||||
|
@ -312,7 +312,7 @@ jQuery.extend({
|
|||
|
||||
if ( value !== undefined ) {
|
||||
|
||||
if ( value === null || (value === false && !special.test( name )) ) {
|
||||
if ( value === null || (value === false && !rspecial.test( name )) ) {
|
||||
jQuery.removeAttr( elem, name );
|
||||
return undefined;
|
||||
|
||||
|
@ -320,9 +320,12 @@ jQuery.extend({
|
|||
return ret;
|
||||
|
||||
} else {
|
||||
if( value === true && !special.test( name ) ){
|
||||
|
||||
// Set boolean attributes to the same name
|
||||
if ( value === true && !rspecial.test( name ) ) {
|
||||
value = name;
|
||||
}
|
||||
|
||||
elem.setAttribute( name, "" + value );
|
||||
return value;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue