From 6fd43da409b02a078bb697d93abec9d2e15b8d30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Mon, 23 Mar 2015 18:10:17 -0400 Subject: [PATCH] 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 12643739a93b1f39d0934321973b96989845a606) --- ui/core.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ui/core.js b/ui/core.js index 462d10bb8..1e40c9443 100644 --- a/ui/core.js +++ b/ui/core.js @@ -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 ); } });