mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Core: reuse tabindex value. Fixed #7257 - optimize :tabbable.
This commit is contained in:
parent
5058ac3ce7
commit
fe3b36b8ef
42
ui/jquery.ui.core.js
vendored
42
ui/jquery.ui.core.js
vendored
@ -174,21 +174,8 @@ $.each( [ "Width", "Height" ], function( i, name ) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// selectors
|
// selectors
|
||||||
function visible( element ) {
|
function focusable( element, isTabIndexNotNaN ) {
|
||||||
return !$( element ).parents().andSelf().filter(function() {
|
var nodeName = element.nodeName.toLowerCase();
|
||||||
return $.curCSS( this, "visibility" ) === "hidden" ||
|
|
||||||
$.expr.filters.hidden( this );
|
|
||||||
}).length;
|
|
||||||
}
|
|
||||||
|
|
||||||
$.extend( $.expr[ ":" ], {
|
|
||||||
data: function( elem, i, match ) {
|
|
||||||
return !!$.data( elem, match[ 3 ] );
|
|
||||||
},
|
|
||||||
|
|
||||||
focusable: function( element ) {
|
|
||||||
var nodeName = element.nodeName.toLowerCase(),
|
|
||||||
tabIndex = $.attr( element, "tabindex" );
|
|
||||||
if ( "area" === nodeName ) {
|
if ( "area" === nodeName ) {
|
||||||
var map = element.parentNode,
|
var map = element.parentNode,
|
||||||
mapName = map.name,
|
mapName = map.name,
|
||||||
@ -202,15 +189,32 @@ $.extend( $.expr[ ":" ], {
|
|||||||
return ( /input|select|textarea|button|object/.test( nodeName )
|
return ( /input|select|textarea|button|object/.test( nodeName )
|
||||||
? !element.disabled
|
? !element.disabled
|
||||||
: "a" == nodeName
|
: "a" == nodeName
|
||||||
? element.href || !isNaN( tabIndex )
|
? element.href || isTabIndexNotNaN
|
||||||
: !isNaN( tabIndex ))
|
: isTabIndexNotNaN)
|
||||||
// the element and all of its ancestors must be visible
|
// the element and all of its ancestors must be visible
|
||||||
&& visible( element );
|
&& visible( element );
|
||||||
|
}
|
||||||
|
|
||||||
|
function visible( element ) {
|
||||||
|
return !$( element ).parents().andSelf().filter(function() {
|
||||||
|
return $.curCSS( this, "visibility" ) === "hidden" ||
|
||||||
|
$.expr.filters.hidden( this );
|
||||||
|
}).length;
|
||||||
|
}
|
||||||
|
|
||||||
|
$.extend( $.expr[ ":" ], {
|
||||||
|
data: function( elem, i, match ) {
|
||||||
|
return !!$.data( elem, match[ 3 ] );
|
||||||
|
},
|
||||||
|
|
||||||
|
focusable: function( element ) {
|
||||||
|
return focusable( element, !isNaN( $.attr( element, "tabindex" ) ) );
|
||||||
},
|
},
|
||||||
|
|
||||||
tabbable: function( element ) {
|
tabbable: function( element ) {
|
||||||
var tabIndex = $.attr( element, "tabindex" );
|
var tabIndex = $.attr( element, "tabindex" ),
|
||||||
return ( isNaN( tabIndex ) || tabIndex >= 0 ) && $( element ).is( ":focusable" );
|
isTabIndexNaN = isNaN( tabIndex );
|
||||||
|
return ( isTabIndexNaN || tabIndex >= 0 ) && focusable( element, !isTabIndexNaN );
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user