diff options
Diffstat (limited to 'js/vendor/jquery/src/attributes')
-rw-r--r-- | js/vendor/jquery/src/attributes/attr.js | 97 | ||||
-rw-r--r-- | js/vendor/jquery/src/attributes/classes.js | 153 | ||||
-rw-r--r-- | js/vendor/jquery/src/attributes/prop.js | 79 | ||||
-rw-r--r-- | js/vendor/jquery/src/attributes/support.js | 11 | ||||
-rw-r--r-- | js/vendor/jquery/src/attributes/val.js | 65 |
5 files changed, 225 insertions, 180 deletions
diff --git a/js/vendor/jquery/src/attributes/attr.js b/js/vendor/jquery/src/attributes/attr.js index a4414d11f..f88808324 100644 --- a/js/vendor/jquery/src/attributes/attr.js +++ b/js/vendor/jquery/src/attributes/attr.js @@ -1,39 +1,38 @@ -define([ +define( [ "../core", - "../var/rnotwhite", - "../var/strundefined", "../core/access", "./support", + "../var/rnotwhite", "../selector" -], function( jQuery, rnotwhite, strundefined, access, support ) { +], function( jQuery, access, support, rnotwhite ) { -var nodeHook, boolHook, +var boolHook, attrHandle = jQuery.expr.attrHandle; -jQuery.fn.extend({ +jQuery.fn.extend( { attr: function( name, value ) { return access( this, jQuery.attr, name, value, arguments.length > 1 ); }, removeAttr: function( name ) { - return this.each(function() { + return this.each( function() { jQuery.removeAttr( this, name ); - }); + } ); } -}); +} ); -jQuery.extend({ +jQuery.extend( { attr: function( elem, name, value ) { - var hooks, ret, + var ret, hooks, nType = elem.nodeType; - // don't get/set attributes on text, comment and attribute nodes - if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { + // Don't get/set attributes on text, comment and attribute nodes + if ( nType === 3 || nType === 8 || nType === 2 ) { return; } // Fallback to prop when attributes are not supported - if ( typeof elem.getAttribute === strundefined ) { + if ( typeof elem.getAttribute === "undefined" ) { return jQuery.prop( elem, name, value ); } @@ -42,32 +41,47 @@ jQuery.extend({ if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) { name = name.toLowerCase(); hooks = jQuery.attrHooks[ name ] || - ( jQuery.expr.match.bool.test( name ) ? boolHook : nodeHook ); + ( jQuery.expr.match.bool.test( name ) ? boolHook : undefined ); } if ( value !== undefined ) { - if ( value === null ) { jQuery.removeAttr( elem, name ); + return; + } - } else if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) { + if ( hooks && "set" in hooks && + ( ret = hooks.set( elem, value, name ) ) !== undefined ) { return ret; - - } else { - elem.setAttribute( name, value + "" ); - return value; } - } else if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) { + elem.setAttribute( name, value + "" ); + return value; + } + + if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) { return ret; + } - } else { - ret = jQuery.find.attr( elem, name ); + ret = jQuery.find.attr( elem, name ); + + // Non-existent attributes return null, we normalize to undefined + return ret == null ? undefined : ret; + }, - // Non-existent attributes return null, we normalize to undefined - return ret == null ? - undefined : - ret; + attrHooks: { + type: { + set: function( elem, value ) { + if ( !support.radioValue && value === "radio" && + jQuery.nodeName( elem, "input" ) ) { + var val = elem.value; + elem.setAttribute( "type", value ); + if ( val ) { + elem.value = val; + } + return value; + } + } } }, @@ -77,11 +91,12 @@ jQuery.extend({ attrNames = value && value.match( rnotwhite ); if ( attrNames && elem.nodeType === 1 ) { - while ( (name = attrNames[i++]) ) { + while ( ( name = attrNames[ i++ ] ) ) { propName = jQuery.propFix[ name ] || name; // Boolean attributes get special treatment (#10870) if ( jQuery.expr.match.bool.test( name ) ) { + // Set corresponding property to false elem[ propName ] = false; } @@ -89,29 +104,14 @@ jQuery.extend({ elem.removeAttribute( name ); } } - }, - - attrHooks: { - type: { - set: function( elem, value ) { - if ( !support.radioValue && value === "radio" && - jQuery.nodeName( elem, "input" ) ) { - var val = elem.value; - elem.setAttribute( "type", value ); - if ( val ) { - elem.value = val; - } - return value; - } - } - } } -}); +} ); // Hooks for boolean attributes boolHook = { set: function( elem, value, name ) { if ( value === false ) { + // Remove boolean attributes when set to false jQuery.removeAttr( elem, name ); } else { @@ -126,6 +126,7 @@ jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) attrHandle[ name ] = function( elem, name, isXML ) { var ret, handle; if ( !isXML ) { + // Avoid an infinite loop by temporarily removing this function from the getter handle = attrHandle[ name ]; attrHandle[ name ] = ret; @@ -136,6 +137,6 @@ jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) } return ret; }; -}); +} ); -}); +} ); diff --git a/js/vendor/jquery/src/attributes/classes.js b/js/vendor/jquery/src/attributes/classes.js index 101138415..7933873c4 100644 --- a/js/vendor/jquery/src/attributes/classes.js +++ b/js/vendor/jquery/src/attributes/classes.js @@ -1,49 +1,47 @@ -define([ +define( [ "../core", "../var/rnotwhite", - "../var/strundefined", - "../data/var/data_priv", + "../data/var/dataPriv", "../core/init" -], function( jQuery, rnotwhite, strundefined, data_priv ) { +], function( jQuery, rnotwhite, dataPriv ) { var rclass = /[\t\r\n\f]/g; -jQuery.fn.extend({ +function getClass( elem ) { + return elem.getAttribute && elem.getAttribute( "class" ) || ""; +} + +jQuery.fn.extend( { addClass: function( value ) { - var classes, elem, cur, clazz, j, finalValue, - proceed = typeof value === "string" && value, - i = 0, - len = this.length; + var classes, elem, cur, curValue, clazz, j, finalValue, + i = 0; if ( jQuery.isFunction( value ) ) { - return this.each(function( j ) { - jQuery( this ).addClass( value.call( this, j, this.className ) ); - }); + return this.each( function( j ) { + jQuery( this ).addClass( value.call( this, j, getClass( this ) ) ); + } ); } - if ( proceed ) { - // The disjunction here is for better compressibility (see removeClass) - classes = ( value || "" ).match( rnotwhite ) || []; + if ( typeof value === "string" && value ) { + classes = value.match( rnotwhite ) || []; - for ( ; i < len; i++ ) { - elem = this[ i ]; - cur = elem.nodeType === 1 && ( elem.className ? - ( " " + elem.className + " " ).replace( rclass, " " ) : - " " - ); + while ( ( elem = this[ i++ ] ) ) { + curValue = getClass( elem ); + cur = elem.nodeType === 1 && + ( " " + curValue + " " ).replace( rclass, " " ); if ( cur ) { j = 0; - while ( (clazz = classes[j++]) ) { + while ( ( clazz = classes[ j++ ] ) ) { if ( cur.indexOf( " " + clazz + " " ) < 0 ) { cur += clazz + " "; } } - // only assign if different to avoid unneeded rendering. + // Only assign if different to avoid unneeded rendering. finalValue = jQuery.trim( cur ); - if ( elem.className !== finalValue ) { - elem.className = finalValue; + if ( curValue !== finalValue ) { + elem.setAttribute( "class", finalValue ); } } } @@ -53,40 +51,43 @@ jQuery.fn.extend({ }, removeClass: function( value ) { - var classes, elem, cur, clazz, j, finalValue, - proceed = arguments.length === 0 || typeof value === "string" && value, - i = 0, - len = this.length; + var classes, elem, cur, curValue, clazz, j, finalValue, + i = 0; if ( jQuery.isFunction( value ) ) { - return this.each(function( j ) { - jQuery( this ).removeClass( value.call( this, j, this.className ) ); - }); + return this.each( function( j ) { + jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) ); + } ); + } + + if ( !arguments.length ) { + return this.attr( "class", "" ); } - if ( proceed ) { - classes = ( value || "" ).match( rnotwhite ) || []; - for ( ; i < len; i++ ) { - elem = this[ i ]; + if ( typeof value === "string" && value ) { + classes = value.match( rnotwhite ) || []; + + while ( ( elem = this[ i++ ] ) ) { + curValue = getClass( elem ); + // This expression is here for better compressibility (see addClass) - cur = elem.nodeType === 1 && ( elem.className ? - ( " " + elem.className + " " ).replace( rclass, " " ) : - "" - ); + cur = elem.nodeType === 1 && + ( " " + curValue + " " ).replace( rclass, " " ); if ( cur ) { j = 0; - while ( (clazz = classes[j++]) ) { + while ( ( clazz = classes[ j++ ] ) ) { + // Remove *all* instances - while ( cur.indexOf( " " + clazz + " " ) >= 0 ) { + while ( cur.indexOf( " " + clazz + " " ) > -1 ) { cur = cur.replace( " " + clazz + " ", " " ); } } // Only assign if different to avoid unneeded rendering. - finalValue = value ? jQuery.trim( cur ) : ""; - if ( elem.className !== finalValue ) { - elem.className = finalValue; + finalValue = jQuery.trim( cur ); + if ( curValue !== finalValue ) { + elem.setAttribute( "class", finalValue ); } } } @@ -103,20 +104,26 @@ jQuery.fn.extend({ } if ( jQuery.isFunction( value ) ) { - return this.each(function( i ) { - jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal ); - }); + return this.each( function( i ) { + jQuery( this ).toggleClass( + value.call( this, i, getClass( this ), stateVal ), + stateVal + ); + } ); } - return this.each(function() { + return this.each( function() { + var className, i, self, classNames; + if ( type === "string" ) { + // Toggle individual class names - var className, - i = 0, - self = jQuery( this ), - classNames = value.match( rnotwhite ) || []; + i = 0; + self = jQuery( this ); + classNames = value.match( rnotwhite ) || []; + + while ( ( className = classNames[ i++ ] ) ) { - while ( (className = classNames[ i++ ]) ) { // Check each className given, space separated list if ( self.hasClass( className ) ) { self.removeClass( className ); @@ -126,33 +133,45 @@ jQuery.fn.extend({ } // Toggle whole class name - } else if ( type === strundefined || type === "boolean" ) { - if ( this.className ) { - // store className if set - data_priv.set( this, "__className__", this.className ); + } else if ( value === undefined || type === "boolean" ) { + className = getClass( this ); + if ( className ) { + + // Store className if set + dataPriv.set( this, "__className__", className ); } // If the element has a class name or if we're passed `false`, // then remove the whole classname (if there was one, the above saved it). // Otherwise bring back whatever was previously saved (if anything), // falling back to the empty string if nothing was stored. - this.className = this.className || value === false ? "" : data_priv.get( this, "__className__" ) || ""; + if ( this.setAttribute ) { + this.setAttribute( "class", + className || value === false ? + "" : + dataPriv.get( this, "__className__" ) || "" + ); + } } - }); + } ); }, hasClass: function( selector ) { - var className = " " + selector + " ", - i = 0, - l = this.length; - for ( ; i < l; i++ ) { - if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) >= 0 ) { + var className, elem, + i = 0; + + className = " " + selector + " "; + while ( ( elem = this[ i++ ] ) ) { + if ( elem.nodeType === 1 && + ( " " + getClass( elem ) + " " ).replace( rclass, " " ) + .indexOf( className ) > -1 + ) { return true; } } return false; } -}); +} ); -}); +} ); 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; -}); +} ); -}); +} ); diff --git a/js/vendor/jquery/src/attributes/support.js b/js/vendor/jquery/src/attributes/support.js index 5db5c5212..e8d02b5c9 100644 --- a/js/vendor/jquery/src/attributes/support.js +++ b/js/vendor/jquery/src/attributes/support.js @@ -1,8 +1,9 @@ -define([ +define( [ + "../var/document", "../var/support" -], function( support ) { +], function( document, support ) { -(function() { +( function() { var input = document.createElement( "input" ), select = document.createElement( "select" ), opt = select.appendChild( document.createElement( "option" ) ); @@ -28,8 +29,8 @@ define([ input.value = "t"; input.type = "radio"; support.radioValue = input.value === "t"; -})(); +} )(); return support; -}); +} ); diff --git a/js/vendor/jquery/src/attributes/val.js b/js/vendor/jquery/src/attributes/val.js index 4a1358a65..9999d985b 100644 --- a/js/vendor/jquery/src/attributes/val.js +++ b/js/vendor/jquery/src/attributes/val.js @@ -1,4 +1,4 @@ -define([ +define( [ "../core", "./support", "../core/init" @@ -6,24 +6,30 @@ define([ var rreturn = /\r/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() ]; + hooks = jQuery.valHooks[ elem.type ] || + jQuery.valHooks[ elem.nodeName.toLowerCase() ]; - if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) { + 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 +39,7 @@ jQuery.fn.extend({ isFunction = jQuery.isFunction( value ); - return this.each(function( i ) { + return this.each( function( i ) { var val; if ( this.nodeType !== 1 ) { @@ -56,29 +62,27 @@ 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 ) ); + + // Support: IE<11 + // option.value not trimmed (#14858) + return jQuery.trim( elem.value ); } }, select: { @@ -97,11 +101,14 @@ jQuery.extend({ for ( ; i < max; i++ ) { option = options[ i ]; - // IE6-9 doesn't update selected after form reset (#2551) + // IE8-9 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(); @@ -127,7 +134,9 @@ jQuery.extend({ while ( i-- ) { option = options[ i ]; - if ( (option.selected = jQuery.inArray( option.value, values ) >= 0) ) { + if ( option.selected = + jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1 + ) { optionSet = true; } } @@ -140,22 +149,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 ) { - return elem.getAttribute("value") === null ? "on" : elem.value; + return elem.getAttribute( "value" ) === null ? "on" : elem.value; }; } -}); +} ); -}); +} ); |