mirror of
https://github.com/jquery/jquery.git
synced 2026-04-20 03:01:22 -04:00
Adjust tabIndex propHook for modern browsers and return -1 where appropriate. Close gh-1228.
This commit is contained in:
committed by
Timmy Willison
parent
52394ba986
commit
f1ba486ee3
@@ -1,8 +1,7 @@
|
||||
var nodeHook, boolHook,
|
||||
rclass = /[\t\r\n]/g,
|
||||
rreturn = /\r/g,
|
||||
rfocusable = /^(?:input|select|textarea|button|object)$/i,
|
||||
rclickable = /^(?:a|area)$/i;
|
||||
rfocusable = /^(?:input|select|textarea|button)$/i;
|
||||
|
||||
jQuery.fn.extend({
|
||||
attr: function( name, value ) {
|
||||
@@ -395,35 +394,23 @@ jQuery.extend({
|
||||
}
|
||||
|
||||
if ( value !== undefined ) {
|
||||
if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
|
||||
return ret;
|
||||
|
||||
} else {
|
||||
return ( elem[ name ] = value );
|
||||
}
|
||||
return hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ?
|
||||
ret :
|
||||
( elem[ name ] = value );
|
||||
|
||||
} else {
|
||||
if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) {
|
||||
return ret;
|
||||
|
||||
} else {
|
||||
return elem[ name ];
|
||||
}
|
||||
return hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ?
|
||||
ret :
|
||||
elem[ name ];
|
||||
}
|
||||
},
|
||||
|
||||
propHooks: {
|
||||
tabIndex: {
|
||||
get: function( elem ) {
|
||||
// elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
|
||||
// http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
|
||||
var attributeNode = elem.getAttributeNode("tabindex");
|
||||
|
||||
return attributeNode && attributeNode.specified ?
|
||||
parseInt( attributeNode.value, 10 ) :
|
||||
rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ?
|
||||
0 :
|
||||
undefined;
|
||||
return elem.hasAttribute( "tabindex" ) || rfocusable.test( elem.nodeName ) || elem.href ?
|
||||
elem.tabIndex :
|
||||
-1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user