mirror of
https://github.com/jquery/jquery.git
synced 2025-01-10 18:24:24 +00:00
Attributes: fix tabIndex on <img> in IE11
Fixes gh-2647 Closes gh-2664
This commit is contained in:
parent
3689963909
commit
c752a5030b
@ -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;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -735,6 +735,13 @@ QUnit.test( "prop('tabindex')", function( assert ) {
|
||||
assert.equal( jQuery( "#linkWithNoHrefWithNegativeTabIndex" ).prop( "tabindex" ), -1, "anchor without href, no tabindex set" );
|
||||
} );
|
||||
|
||||
QUnit.test( "image.prop( 'tabIndex' )", function( assert ) {
|
||||
assert.expect( 1 );
|
||||
var image = jQuery("<img src='data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7' />")
|
||||
.appendTo("#qunit-fixture");
|
||||
assert.equal( image.prop("tabIndex" ), -1, "tabIndex on image" );
|
||||
} );
|
||||
|
||||
QUnit.test( "prop('tabindex', value)", function( assert ) {
|
||||
assert.expect( 10 );
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user