Skip to content

Commit 6fd43da

Browse files
committed
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 1264373)
1 parent 413a9c9 commit 6fd43da

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
@@ -117,7 +117,7 @@ $.fn.extend({
117117
});
118118

119119
// selectors
120-
function focusable( element, isTabIndexNotNaN ) {
120+
function focusable( element, hasTabindex ) {
121121
var map, mapName, img,
122122
nodeName = element.nodeName.toLowerCase();
123123
if ( "area" === nodeName ) {
@@ -132,8 +132,8 @@ function focusable( element, isTabIndexNotNaN ) {
132132
return ( /^(input|select|textarea|button|object)$/.test( nodeName ) ?
133133
!element.disabled :
134134
"a" === nodeName ?
135-
element.href || isTabIndexNotNaN :
136-
isTabIndexNotNaN) &&
135+
element.href || hasTabindex :
136+
hasTabindex ) &&
137137
// the element and all of its ancestors must be visible
138138
visible( element );
139139
}
@@ -158,13 +158,13 @@ $.extend( $.expr[ ":" ], {
158158
},
159159

160160
focusable: function( element ) {
161-
return focusable( element, !isNaN( $.attr( element, "tabindex" ) ) );
161+
return focusable( element, $.attr( element, "tabindex" ) != null );
162162
},
163163

164164
tabbable: function( element ) {
165165
var tabIndex = $.attr( element, "tabindex" ),
166-
isTabIndexNaN = isNaN( tabIndex );
167-
return ( isTabIndexNaN || tabIndex >= 0 ) && focusable( element, !isTabIndexNaN );
166+
hasTabindex = tabIndex != null;
167+
return ( !hasTabindex || tabIndex >= 0 ) && focusable( element, hasTabindex );
168168
}
169169
});
170170

0 commit comments

Comments
 (0)