aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJoelle Fleurantin <joasqueeniebee@gmail.com>2015-10-18 16:20:25 -0400
committerMichał Gołębiowski <m.goleb@gmail.com>2015-10-18 16:36:52 -0400
commitc752a5030bc00eb5b45dea9c28963f824a5c4f44 (patch)
tree364e9d3e188b768d4f72034ce04ef53561198e33 /src
parent3689963909880ed832ac17eabf7b9260927a68d8 (diff)
downloadjquery-c752a5030bc00eb5b45dea9c28963f824a5c4f44.tar.gz
jquery-c752a5030bc00eb5b45dea9c28963f824a5c4f44.zip
Attributes: fix tabIndex on <img> in IE11
Fixes gh-2647 Closes gh-2664
Diffstat (limited to 'src')
-rw-r--r--src/attributes/prop.js20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/attributes/prop.js b/src/attributes/prop.js
index 06528b0a5..da7bc1e86 100644
--- a/src/attributes/prop.js
+++ b/src/attributes/prop.js
@@ -5,7 +5,8 @@ define( [
"../selector"
], function( jQuery, access, support ) {
-var rfocusable = /^(?:input|select|textarea|button)$/i;
+var rfocusable = /^(?:input|select|textarea|button)$/i,
+ rclickable = /^(?:a|area)$/i;
jQuery.fn.extend( {
prop: function( name, value ) {
@@ -55,10 +56,19 @@ jQuery.extend( {
propHooks: {
tabIndex: {
get: function( elem ) {
- return elem.hasAttribute( "tabindex" ) ||
- rfocusable.test( elem.nodeName ) || elem.href ?
- elem.tabIndex :
- -1;
+
+ // 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/
+ // Use proper attribute retrieval(#12072)
+ var tabindex = jQuery.find.attr( elem, "tabindex" );
+
+ return tabindex ?
+ parseInt( tabindex, 10 ) :
+ rfocusable.test( elem.nodeName ) ||
+ rclickable.test( elem.nodeName ) && elem.href ?
+ 0 :
+ -1;
}
}
},