diff options
author | timmywil <timmywillisn@gmail.com> | 2011-08-04 15:47:53 -0400 |
---|---|---|
committer | timmywil <timmywillisn@gmail.com> | 2011-08-04 18:16:15 -0400 |
commit | fd4ee2a39752cc40e35fbcb1bfd48634ffe4bfd4 (patch) | |
tree | 5d1b9be7cf1ab6bf7c768503e8721fa8c68894f7 /src/attributes.js | |
parent | 3cfb134ab41d204a71977c0b4c73640f250c7112 (diff) | |
download | jquery-fd4ee2a39752cc40e35fbcb1bfd48634ffe4bfd4.tar.gz jquery-fd4ee2a39752cc40e35fbcb1bfd48634ffe4bfd4.zip |
Make the tabIndex hook first a propHook and add it to attrHooks for back-compat reasons. Fixes #9979.
Diffstat (limited to 'src/attributes.js')
-rw-r--r-- | src/attributes.js | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/src/attributes.js b/src/attributes.js index d4d923d9b..df87e23b4 100644 --- a/src/attributes.js +++ b/src/attributes.js @@ -405,19 +405,6 @@ jQuery.extend({ } } }, - tabIndex: { - get: function( elem ) { - // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set - // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/ - var attributeNode = elem.getAttributeNode("tabIndex"); - - return attributeNode && attributeNode.specified ? - parseInt( attributeNode.value, 10 ) : - rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ? - 0 : - undefined; - } - }, // Use the value property for back compat // Use the formHook for button elements in IE6/7 (#1954) value: { @@ -480,7 +467,7 @@ jQuery.extend({ } } else { - if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== undefined ) { + if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) { return ret; } else { @@ -489,9 +476,26 @@ jQuery.extend({ } }, - propHooks: {} + propHooks: { + tabIndex: { + get: function( elem ) { + // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set + // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/ + var attributeNode = elem.getAttributeNode("tabIndex"); + + return attributeNode && attributeNode.specified ? + parseInt( attributeNode.value, 10 ) : + rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ? + 0 : + undefined; + } + } + } }); +// Add the tabindex propHook to attrHooks for back-compat +jQuery.attrHooks.tabIndex = jQuery.propHooks.tabIndex; + // Hook for boolean attributes boolHook = { get: function( elem, name ) { @@ -604,6 +608,7 @@ if ( !jQuery.support.optSelected ) { parent.parentNode.selectedIndex; } } + return null; } }); } |