mirror of
https://github.com/jquery/jquery-ui.git
synced 2025-01-07 20:34:24 +00:00
Core: Fix :focusable
and :tabbable
with jQuery git
jQuery now returns `null` for empty attributes instead of `undefined`
Ref gh-1516
(cherry picked from commit 12643739a9
)
This commit is contained in:
parent
413a9c99f8
commit
6fd43da409
12
ui/core.js
12
ui/core.js
@ -117,7 +117,7 @@ $.fn.extend({
|
|||||||
});
|
});
|
||||||
|
|
||||||
// selectors
|
// selectors
|
||||||
function focusable( element, isTabIndexNotNaN ) {
|
function focusable( element, hasTabindex ) {
|
||||||
var map, mapName, img,
|
var map, mapName, img,
|
||||||
nodeName = element.nodeName.toLowerCase();
|
nodeName = element.nodeName.toLowerCase();
|
||||||
if ( "area" === nodeName ) {
|
if ( "area" === nodeName ) {
|
||||||
@ -132,8 +132,8 @@ function focusable( element, isTabIndexNotNaN ) {
|
|||||||
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 || isTabIndexNotNaN :
|
element.href || hasTabindex :
|
||||||
isTabIndexNotNaN) &&
|
hasTabindex ) &&
|
||||||
// the element and all of its ancestors must be visible
|
// the element and all of its ancestors must be visible
|
||||||
visible( element );
|
visible( element );
|
||||||
}
|
}
|
||||||
@ -158,13 +158,13 @@ $.extend( $.expr[ ":" ], {
|
|||||||
},
|
},
|
||||||
|
|
||||||
focusable: function( element ) {
|
focusable: function( element ) {
|
||||||
return focusable( element, !isNaN( $.attr( element, "tabindex" ) ) );
|
return focusable( element, $.attr( element, "tabindex" ) != null );
|
||||||
},
|
},
|
||||||
|
|
||||||
tabbable: function( element ) {
|
tabbable: function( element ) {
|
||||||
var tabIndex = $.attr( element, "tabindex" ),
|
var tabIndex = $.attr( element, "tabindex" ),
|
||||||
isTabIndexNaN = isNaN( tabIndex );
|
hasTabindex = tabIndex != null;
|
||||||
return ( isTabIndexNaN || tabIndex >= 0 ) && focusable( element, !isTabIndexNaN );
|
return ( !hasTabindex || tabIndex >= 0 ) && focusable( element, hasTabindex );
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user