diff options
Diffstat (limited to 'libs/bower_components/jquery/src/attributes/prop.js')
-rw-r--r-- | libs/bower_components/jquery/src/attributes/prop.js | 121 |
1 files changed, 56 insertions, 65 deletions
diff --git a/libs/bower_components/jquery/src/attributes/prop.js b/libs/bower_components/jquery/src/attributes/prop.js index 817a1b6211..e127bb08f9 100644 --- a/libs/bower_components/jquery/src/attributes/prop.js +++ b/libs/bower_components/jquery/src/attributes/prop.js @@ -1,117 +1,113 @@ -define([ +define( [ "../core", "../core/access", - "./support" + "./support", + "../selector" ], function( jQuery, access, support ) { -var rfocusable = /^(?:input|select|textarea|button|object)$/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 ) { - name = jQuery.propFix[ name ] || name; - return this.each(function() { - // try/catch handles cases where IE balks (such as removing a property on window) - try { - this[ name ] = undefined; - delete this[ name ]; - } catch( e ) {} - }); + 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 ) { + // Don't get/set properties on text, comment and attribute nodes + 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 ) { - // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set + + // 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; + rfocusable.test( elem.nodeName ) || + rclickable.test( elem.nodeName ) && elem.href ? + 0 : + -1; } } - } -}); - -// Some attributes require a special call on IE -// http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx -if ( !support.hrefNormalized ) { - // href/src property should get the full normalized URL (#10299/#12915) - jQuery.each([ "href", "src" ], function( i, name ) { - jQuery.propHooks[ name ] = { - get: function( elem ) { - return elem.getAttribute( name, 4 ); - } - }; - }); -} + }, -// Support: Safari, IE9+ -// mis-reports the default selected property of an option -// Accessing the parent's selectedIndex property fixes it + propFix: { + "for": "htmlFor", + "class": "className" + } +} ); + +// Support: IE <=11 only +// Accessing the selectedIndex property +// forces the browser to respect setting selected +// on the option +// The getter ensures a default option is selected +// when in an optgroup if ( !support.optSelected ) { jQuery.propHooks.selected = { get: function( elem ) { var parent = elem.parentNode; - + if ( parent && parent.parentNode ) { + parent.parentNode.selectedIndex; + } + return null; + }, + set: function( elem ) { + var parent = elem.parentNode; if ( parent ) { parent.selectedIndex; - // Make sure that it also works with optgroups, see #5701 if ( parent.parentNode ) { parent.parentNode.selectedIndex; } } - return null; } }; } -jQuery.each([ +jQuery.each( [ "tabIndex", "readOnly", "maxLength", @@ -124,11 +120,6 @@ jQuery.each([ "contentEditable" ], function() { jQuery.propFix[ this.toLowerCase() ] = this; -}); - -// IE6/7 call enctype encoding -if ( !support.enctype ) { - jQuery.propFix.enctype = "encoding"; -} +} ); -}); +} ); |