aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorOleg Gaidarenko <markelog@gmail.com>2013-04-08 21:33:17 -0400
committerTimmy Willison <timmywillisn@gmail.com>2013-04-08 21:33:17 -0400
commitf1ba486ee3faeb70faeec1688b79ed085dd6a102 (patch)
tree12eb4c8dd3ee88d4eb78e448c3c9e4c11caa1cd3 /src
parent52394ba986794423e7855ece3b4f80a1f2fb7398 (diff)
downloadjquery-f1ba486ee3faeb70faeec1688b79ed085dd6a102.tar.gz
jquery-f1ba486ee3faeb70faeec1688b79ed085dd6a102.zip
Adjust tabIndex propHook for modern browsers and return -1 where appropriate. Close gh-1228.
Diffstat (limited to 'src')
-rw-r--r--src/attributes.js33
1 files changed, 10 insertions, 23 deletions
diff --git a/src/attributes.js b/src/attributes.js
index b68f773d8..4aabcfc1b 100644
--- a/src/attributes.js
+++ b/src/attributes.js
@@ -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;
}
}
}