From 261b7efb5f86a5c9a3de8434f3cad858101e4249 Mon Sep 17 00:00:00 2001 From: jeresig Date: Tue, 22 Dec 2009 00:24:23 -0500 Subject: [PATCH] Fixed the issue where getting an empty value was impossible. Fixes #5697. --- src/attributes.js | 2 +- test/unit/manipulation.js | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/attributes.js b/src/attributes.js index 787c6bb..91a0fe1 100644 --- a/src/attributes.js +++ b/src/attributes.js @@ -164,7 +164,7 @@ jQuery.fn.extend({ var values = jQuery.makeArray(val); 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 ) { diff --git a/test/unit/manipulation.js b/test/unit/manipulation.js index 03f8f32..7521c76 100644 --- a/test/unit/manipulation.js +++ b/test/unit/manipulation.js @@ -619,7 +619,7 @@ test("clone() on XML nodes", function() { } test("val()", function() { - expect(9); + expect(11); document.getElementById('text1').value = "bla"; equals( jQuery("#text1").val(), "bla", "Check for modified value of input element" ); @@ -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('#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) { -- 1.7.10.4