Commit 261b7efb authored by jeresig's avatar jeresig

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

parent c97e914d
...@@ -164,7 +164,7 @@ jQuery.fn.extend({ ...@@ -164,7 +164,7 @@ jQuery.fn.extend({
var values = jQuery.makeArray(val); var values = jQuery.makeArray(val);
jQuery( "option", this ).each(function() { jQuery( "option", this ).each(function() {
this.selected = jQuery.inArray( this.value || this.text, values ) >= 0; this.selected = jQuery.inArray( this.value, values ) >= 0;
}); });
if ( !values.length ) { if ( !values.length ) {
......
...@@ -619,7 +619,7 @@ test("clone() on XML nodes", function() { ...@@ -619,7 +619,7 @@ test("clone() on XML nodes", function() {
} }
test("val()", function() { test("val()", function() {
expect(9); expect(11);
document.getElementById('text1').value = "bla"; document.getElementById('text1').value = "bla";
equals( jQuery("#text1").val(), "bla", "Check for modified value of input element" ); equals( jQuery("#text1").val(), "bla", "Check for modified value of input element" );
...@@ -641,6 +641,11 @@ test("val()", function() { ...@@ -641,6 +641,11 @@ test("val()", function() {
equals( jQuery('#option3e').val(), 'no value', 'Call val() on a option element with no value attribute' ); equals( jQuery('#option3e').val(), 'no value', 'Call val() on a option element with no value attribute' );
equals( jQuery('#option3a').val(), '', 'Call val() on a option element with no value attribute' );
jQuery('#select3').val("");
same( jQuery('#select3').val(), [''], 'Call val() on a multiple="multiple" select' );
}); });
var testVal = function(valueObj) { var testVal = function(valueObj) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment