<commit_before>jQuery.fn.extend({
	attr: function( name, value ) {
		var elem, options, isFunction = jQuery.isFunction(value);

		if ( typeof name === "string" ) {     // A single attribute
			if ( value === undefined ) {        // Query it on first element
				return this.length ?
					jQuery.attr( this[0], name ) :
					null;
			} else {                            // Set it on all elements
				for ( var i = 0, l = this.length; i < l; i++ ) {
					elem = this[i];
					if ( isFunction )
						value = value.call(elem,i);
					jQuery.attr( elem, name, value );
				}
			}
		} else {                              // Multiple attributes to set on all
			options = name;
			for ( var i = 0, l = this.length; i < l; i++ ) {
				elem = this[i];
				for ( name in options ) {
					value = options[name];
					if ( jQuery.isFunction(value) )
						value = value.call(elem,i);
					jQuery.attr( elem, name, value );
				}
			}
		}

		return this;
	},

	hasClass: function( selector ) {
		return !!selector && this.is( "." + selector );
	},

	val: function( value ) {
		if ( value === undefined ) {
			var elem = this[0];

			if ( elem ) {
				if( jQuery.nodeName( elem, 'option' ) )
					return (elem.attributes.value || {}).specified ? elem.value : elem.text;

				// We need to handle select boxes special
				if ( jQuery.nodeName( elem, "select" ) ) {
					var index = elem.selectedIndex,
						values = [],
						options = elem.options,
						one = elem.type == "select-one";

					// Nothing was selected
					if ( index < 0 )
						return null;

					// Loop through all the selected options
					for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) {
						var option = options[ i ];

						if ( option.selected ) {
							// Get the specifc value for the option
							value = jQuery(option).val();

							// We don't need an array for one selects
							if ( one )
								return value;

							// Multi-Selects return an array
							values.push( value );
						}
					}

					return values;
				}

				// Everything else, we just grab the value
				return (elem.value || "").replace(/\r/g, "");

			}

			return undefined;
		}

		// Typecast once if the value is a number
		if ( typeof value === "number" )
			value += '';
			
		var val = value;

		return this.each(function(){
			if(jQuery.isFunction(value)) {
				val = value.call(this);
				// Typecast each time if the value is a Function and the appended
				// value is therefore different each time.
				if( typeof val === "number" ) val += '';
			}
			
			if ( this.nodeType != 1 )
				return;

			if ( jQuery.isArray(val) && /radio|checkbox/.test( this.type ) )
				this.checked = (jQuery.inArray(this.value, val) >= 0 ||
					jQuery.inArray(this.name, val) >= 0);

			else if ( jQuery.nodeName( this, "select" ) ) {
				var values = jQuery.makeArray(val);

				jQuery( "option", this ).each(function(){
					this.selected = (jQuery.inArray( this.value, values ) >= 0 ||
						jQuery.inArray( this.text, values ) >= 0);
				});

				if ( !values.length )
					this.selectedIndex = -1;

			} else
				this.value = val;
		});
	}
});

jQuery.each({
	removeAttr: function( name ) {
		jQuery.attr( this, name, "" );<commit_msg>Fix for incorrect options being selected (noticed same problem with radio/checkbox and fixed it there, as well). Fixes #4962.<commit_after>jQuery.fn.extend({
	attr: function( name, value ) {
		var elem, options, isFunction = jQuery.isFunction(value);

		if ( typeof name === "string" ) {     // A single attribute
			if ( value === undefined ) {        // Query it on first element
				return this.length ?
					jQuery.attr( this[0], name ) :
					null;
			} else {                            // Set it on all elements
				for ( var i = 0, l = this.length; i < l; i++ ) {
					elem = this[i];
					if ( isFunction )
						value = value.call(elem,i);
					jQuery.attr( elem, name, value );
				}
			}
		} else {                              // Multiple attributes to set on all
			options = name;
			for ( var i = 0, l = this.length; i < l; i++ ) {
				elem = this[i];
				for ( name in options ) {
					value = options[name];
					if ( jQuery.isFunction(value) )
						value = value.call(elem,i);
					jQuery.attr( elem, name, value );
				}
			}
		}

		return this;
	},

	hasClass: function( selector ) {
		return !!selector && this.is( "." + selector );
	},

	val: function( value ) {
		if ( value === undefined ) {
			var elem = this[0];

			if ( elem ) {
				if( jQuery.nodeName( elem, 'option' ) )
					return (elem.attributes.value || {}).specified ? elem.value : elem.text;

				// We need to handle select boxes special
				if ( jQuery.nodeName( elem, "select" ) ) {
					var index = elem.selectedIndex,
						values = [],
						options = elem.options,
						one = elem.type == "select-one";

					// Nothing was selected
					if ( index < 0 )
						return null;

					// Loop through all the selected options
					for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) {
						var option = options[ i ];

						if ( option.selected ) {
							// Get the specifc value for the option
							value = jQuery(option).val();

							// We don't need an array for one selects
							if ( one )
								return value;

							// Multi-Selects return an array
							values.push( value );
						}
					}

					return values;
				}

				// Everything else, we just grab the value
				return (elem.value || "").replace(/\r/g, "");

			}

			return undefined;
		}

		// Typecast once if the value is a number
		if ( typeof value === "number" )
			value += '';
			
		var val = value;

		return this.each(function(){
			if(jQuery.isFunction(value)) {
				val = value.call(this);
				// Typecast each time if the value is a Function and the appended
				// value is therefore different each time.
				if( typeof val === "number" ) val += '';
			}
			
			if ( this.nodeType != 1 )
				return;

			if ( jQuery.isArray(val) && /radio|checkbox/.test( this.type ) )
				this.checked = jQuery.inArray(this.value || this.name, val) >= 0;

			else if ( jQuery.nodeName( this, "select" ) ) {
				var values = jQuery.makeArray(val);

				jQuery( "option", this ).each(function(){
					this.selected = jQuery.inArray( this.value || this.text, values ) >= 0;
				});

				if ( !values.length )
					this.selectedIndex = -1;

			} else
				this.value = val;
		});
	}
});

jQuery.each({
	removeAttr: function( name ) {
		jQuery.attr( this, name, "" );
{'fraction_non_alphanumeric': 0.14543491671807526, 'fraction_numerical': 0.00431832202344232, 'mean_word_length': 2.0720037896731407, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4180727', 'n_tokens_mistral': 2645, 'n_tokens_neox': 2004, 'n_words': 629}