]> source.dussan.org Git - jquery-ui.git/commitdiff
Core: Fix `:focusable` and `:tabbable` with jQuery git
authorScott González <scott.gonzalez@gmail.com>
Mon, 23 Mar 2015 22:10:17 +0000 (18:10 -0400)
committerScott González <scott.gonzalez@gmail.com>
Thu, 9 Jun 2016 17:13:35 +0000 (13:13 -0400)
jQuery now returns `null` for empty attributes instead of `undefined`

Ref gh-1516

(cherry picked from commit 12643739a93b1f39d0934321973b96989845a606)

ui/core.js

index 462d10bb8dbf9dbb517021a604eb0415bb6f0287..1e40c94432b76cd7e577478c2f6629af67a30f0a 100644 (file)
@@ -117,7 +117,7 @@ $.fn.extend({
 });
 
 // selectors
-function focusable( element, isTabIndexNotNaN ) {
+function focusable( element, hasTabindex ) {
        var map, mapName, img,
                nodeName = element.nodeName.toLowerCase();
        if ( "area" === nodeName ) {
@@ -132,8 +132,8 @@ function focusable( element, isTabIndexNotNaN ) {
        return ( /^(input|select|textarea|button|object)$/.test( nodeName ) ?
                !element.disabled :
                "a" === nodeName ?
-                       element.href || isTabIndexNotNaN :
-                       isTabIndexNotNaN) &&
+                       element.href || hasTabindex :
+                       hasTabindex ) &&
                // the element and all of its ancestors must be visible
                visible( element );
 }
@@ -158,13 +158,13 @@ $.extend( $.expr[ ":" ], {
                },
 
        focusable: function( element ) {
-               return focusable( element, !isNaN( $.attr( element, "tabindex" ) ) );
+               return focusable( element, $.attr( element, "tabindex" ) != null );
        },
 
        tabbable: function( element ) {
                var tabIndex = $.attr( element, "tabindex" ),
-                       isTabIndexNaN = isNaN( tabIndex );
-               return ( isTabIndexNaN || tabIndex >= 0 ) && focusable( element, !isTabIndexNaN );
+                       hasTabindex = tabIndex != null;
+               return ( !hasTabindex || tabIndex >= 0 ) && focusable( element, hasTabindex );
        }
 });