Skip to content

Commit 1264373

Browse files
committed
Core: Fix :focusable and :tabbable with jQuery git
jQuery now returns `null` for empty attributes instead of `undefined` Ref gh-1516
1 parent 76c2755 commit 1264373

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

ui/core.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ $.fn.extend( {
123123
} );
124124

125125
// selectors
126-
function focusable( element, isTabIndexNotNaN ) {
126+
function focusable( element, hasTabindex ) {
127127
var map, mapName, img,
128128
nodeName = element.nodeName.toLowerCase();
129129
if ( "area" === nodeName ) {
@@ -138,8 +138,8 @@ function focusable( element, isTabIndexNotNaN ) {
138138
return ( /^(input|select|textarea|button|object)$/.test( nodeName ) ?
139139
!element.disabled :
140140
"a" === nodeName ?
141-
element.href || isTabIndexNotNaN :
142-
isTabIndexNotNaN ) &&
141+
element.href || hasTabindex :
142+
hasTabindex ) &&
143143
// the element and all of its ancestors must be visible
144144
visible( element );
145145
}
@@ -164,13 +164,13 @@ $.extend( $.expr[ ":" ], {
164164
},
165165

166166
focusable: function( element ) {
167-
return focusable( element, !isNaN( $.attr( element, "tabindex" ) ) );
167+
return focusable( element, $.attr( element, "tabindex" ) != null );
168168
},
169169

170170
tabbable: function( element ) {
171171
var tabIndex = $.attr( element, "tabindex" ),
172-
isTabIndexNaN = isNaN( tabIndex );
173-
return ( isTabIndexNaN || tabIndex >= 0 ) && focusable( element, !isTabIndexNaN );
172+
hasTabindex = tabIndex != null;
173+
return ( !hasTabindex || tabIndex >= 0 ) && focusable( element, hasTabindex );
174174
}
175175
} );
176176

0 commit comments

Comments
 (0)