Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed the issue where getting an empty value was impossible. Fixes #5…

…697.
  • Loading branch information...
commit 261b7efb5f86a5c9a3de8434f3cad858101e4249 1 parent c97e914
John Resig authored December 22, 2009
2  src/attributes.js
@@ -164,7 +164,7 @@ jQuery.fn.extend({
164 164
 				var values = jQuery.makeArray(val);
165 165
 
166 166
 				jQuery( "option", this ).each(function() {
167  
-					this.selected = jQuery.inArray( this.value || this.text, values ) >= 0;
  167
+					this.selected = jQuery.inArray( this.value, values ) >= 0;
168 168
 				});
169 169
 
170 170
 				if ( !values.length ) {
7  test/unit/manipulation.js
@@ -619,7 +619,7 @@ test("clone() on XML nodes", function() {
619 619
 }
620 620
 
621 621
 test("val()", function() {
622  
-	expect(9);
  622
+	expect(11);
623 623
 
624 624
 	document.getElementById('text1').value = "bla";
625 625
 	equals( jQuery("#text1").val(), "bla", "Check for modified value of input element" );
@@ -641,6 +641,11 @@ test("val()", function() {
641 641
 
642 642
 	equals( jQuery('#option3e').val(), 'no value', 'Call val() on a option element with no value attribute' );
643 643
 
  644
+	equals( jQuery('#option3a').val(), '', 'Call val() on a option element with no value attribute' );
  645
+
  646
+	jQuery('#select3').val("");
  647
+	same( jQuery('#select3').val(), [''], 'Call val() on a multiple="multiple" select' );
  648
+
644 649
 });
645 650
 
646 651
 var testVal = function(valueObj) {

0 notes on commit 261b7ef

Please sign in to comment.
Something went wrong with that request. Please try again.