diff options
author | Matthieu Aubry <mattab@users.noreply.github.com> | 2016-06-28 08:50:40 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-06-28 08:50:40 +0300 |
commit | 02daed6db8fb7269d1b3a466cbb32ed7fab76e85 (patch) | |
tree | a534b2905593d44eece6a9f896522e524cb0d28f /libs/bower_components/jquery/src/attributes/val.js | |
parent | f981b2579a95ce60a2b7d2aa146925b4d2222e0a (diff) |
Update JQuery to the latest 1.12.4 version (#10260)
* Update JQuery to the latest 1.* version
* UI tests: Updated Jquery to latest version
Diffstat (limited to 'libs/bower_components/jquery/src/attributes/val.js')
-rw-r--r-- | libs/bower_components/jquery/src/attributes/val.js | 65 |
1 files changed, 39 insertions, 26 deletions
diff --git a/libs/bower_components/jquery/src/attributes/val.js b/libs/bower_components/jquery/src/attributes/val.js index 4a3b0e5c17..33b1dbea63 100644 --- a/libs/bower_components/jquery/src/attributes/val.js +++ b/libs/bower_components/jquery/src/attributes/val.js @@ -1,29 +1,37 @@ -define([ +define( [ "../core", "./support", "../core/init" ], function( jQuery, support ) { -var rreturn = /\r/g; +var rreturn = /\r/g, + rspaces = /[\x20\t\r\n\f]+/g; -jQuery.fn.extend({ +jQuery.fn.extend( { val: function( value ) { var hooks, ret, isFunction, - elem = this[0]; + elem = this[ 0 ]; if ( !arguments.length ) { if ( elem ) { - hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ]; - - if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) { + hooks = jQuery.valHooks[ elem.type ] || + jQuery.valHooks[ elem.nodeName.toLowerCase() ]; + + if ( + hooks && + "get" in hooks && + ( ret = hooks.get( elem, "value" ) ) !== undefined + ) { return ret; } ret = elem.value; return typeof ret === "string" ? + // handle most common string cases - ret.replace(rreturn, "") : + ret.replace( rreturn, "" ) : + // handle cases where value is null/undef or number ret == null ? "" : ret; } @@ -33,7 +41,7 @@ jQuery.fn.extend({ isFunction = jQuery.isFunction( value ); - return this.each(function( i ) { + return this.each( function( i ) { var val; if ( this.nodeType !== 1 ) { @@ -54,29 +62,32 @@ jQuery.fn.extend({ } else if ( jQuery.isArray( val ) ) { val = jQuery.map( val, function( value ) { return value == null ? "" : value + ""; - }); + } ); } hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ]; // If set returns undefined, fall back to normal setting - if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) { + if ( !hooks || !( "set" in hooks ) || hooks.set( this, val, "value" ) === undefined ) { this.value = val; } - }); + } ); } -}); +} ); -jQuery.extend({ +jQuery.extend( { valHooks: { option: { get: function( elem ) { var val = jQuery.find.attr( elem, "value" ); return val != null ? val : + // Support: IE10-11+ // option.text throws exceptions (#14686, #14858) - jQuery.trim( jQuery.text( elem ) ); + // Strip and collapse whitespace + // https://html.spec.whatwg.org/#strip-and-collapse-whitespace + jQuery.trim( jQuery.text( elem ) ).replace( rspaces, " " ); } }, select: { @@ -97,9 +108,13 @@ jQuery.extend({ // oldIE doesn't update selected after form reset (#2551) if ( ( option.selected || i === index ) && + // Don't return options that are disabled or in a disabled optgroup - ( support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null ) && - ( !option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) { + ( support.optDisabled ? + !option.disabled : + option.getAttribute( "disabled" ) === null ) && + ( !option.parentNode.disabled || + !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) { // Get the specific value for the option value = jQuery( option ).val(); @@ -126,7 +141,7 @@ jQuery.extend({ while ( i-- ) { option = options[ i ]; - if ( jQuery.inArray( jQuery.valHooks.option.get( option ), values ) >= 0 ) { + if ( jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1 ) { // Support: IE6 // When new option element is added to select box we need to @@ -155,24 +170,22 @@ jQuery.extend({ } } } -}); +} ); // Radios and checkboxes getter/setter -jQuery.each([ "radio", "checkbox" ], function() { +jQuery.each( [ "radio", "checkbox" ], function() { jQuery.valHooks[ this ] = { set: function( elem, value ) { if ( jQuery.isArray( value ) ) { - return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 ); + return ( elem.checked = jQuery.inArray( jQuery( elem ).val(), value ) > -1 ); } } }; if ( !support.checkOn ) { jQuery.valHooks[ this ].get = function( elem ) { - // Support: Webkit - // "" is returned instead of "on" if a value isn't specified - return elem.getAttribute("value") === null ? "on" : elem.value; + return elem.getAttribute( "value" ) === null ? "on" : elem.value; }; } -}); +} ); -}); +} ); |