diff options
Diffstat (limited to 'js/vendor/jquery/src/attributes/prop.js')
-rw-r--r-- | js/vendor/jquery/src/attributes/prop.js | 79 |
1 files changed, 47 insertions, 32 deletions
diff --git a/js/vendor/jquery/src/attributes/prop.js b/js/vendor/jquery/src/attributes/prop.js index d4ee8b6b9..da7bc1e86 100644 --- a/js/vendor/jquery/src/attributes/prop.js +++ b/js/vendor/jquery/src/attributes/prop.js @@ -1,68 +1,83 @@ -define([ +define( [ "../core", "../core/access", - "./support" + "./support", + "../selector" ], function( jQuery, access, support ) { -var rfocusable = /^(?:input|select|textarea|button)$/i; +var rfocusable = /^(?:input|select|textarea|button)$/i, + rclickable = /^(?:a|area)$/i; -jQuery.fn.extend({ +jQuery.fn.extend( { prop: function( name, value ) { return access( this, jQuery.prop, name, value, arguments.length > 1 ); }, removeProp: function( name ) { - return this.each(function() { + return this.each( function() { delete this[ jQuery.propFix[ name ] || name ]; - }); + } ); } -}); - -jQuery.extend({ - propFix: { - "for": "htmlFor", - "class": "className" - }, +} ); +jQuery.extend( { prop: function( elem, name, value ) { - var ret, hooks, notxml, + var ret, hooks, nType = elem.nodeType; // Don't get/set properties on text, comment and attribute nodes - if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { + if ( nType === 3 || nType === 8 || nType === 2 ) { return; } - notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); + if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) { - if ( notxml ) { // Fix name and attach hooks name = jQuery.propFix[ name ] || name; hooks = jQuery.propHooks[ name ]; } if ( value !== undefined ) { - return hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ? - ret : - ( elem[ name ] = value ); - - } else { - return hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ? - ret : - elem[ name ]; + if ( hooks && "set" in hooks && + ( ret = hooks.set( elem, value, name ) ) !== undefined ) { + return ret; + } + + return ( elem[ name ] = value ); + } + + if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) { + return ret; } + + return elem[ name ]; }, propHooks: { tabIndex: { get: function( elem ) { - return elem.hasAttribute( "tabindex" ) || rfocusable.test( elem.nodeName ) || elem.href ? - elem.tabIndex : - -1; + + // 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/ + // Use proper attribute retrieval(#12072) + var tabindex = jQuery.find.attr( elem, "tabindex" ); + + return tabindex ? + parseInt( tabindex, 10 ) : + rfocusable.test( elem.nodeName ) || + rclickable.test( elem.nodeName ) && elem.href ? + 0 : + -1; } } + }, + + propFix: { + "for": "htmlFor", + "class": "className" } -}); +} ); if ( !support.optSelected ) { jQuery.propHooks.selected = { @@ -76,7 +91,7 @@ if ( !support.optSelected ) { }; } -jQuery.each([ +jQuery.each( [ "tabIndex", "readOnly", "maxLength", @@ -89,6 +104,6 @@ jQuery.each([ "contentEditable" ], function() { jQuery.propFix[ this.toLowerCase() ] = this; -}); +} ); -}); +} ); |