From 4ac2fdda2c26e9b64502b9ef50748427bed2f3c6 Mon Sep 17 00:00:00 2001 From: timmywil Date: Tue, 3 May 2011 14:48:36 -0400 Subject: [PATCH] Fix setting value attributes on option elements. Fixes #9071. --- src/attributes.js | 2 +- test/unit/attributes.js | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/attributes.js b/src/attributes.js index 017a32da4..2da2e1639 100644 --- a/src/attributes.js +++ b/src/attributes.js @@ -199,7 +199,7 @@ jQuery.fn.extend({ hooks = jQuery.valHooks[ this.nodeName.toLowerCase() ] || jQuery.valHooks[ this.type ]; // 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; } }); diff --git a/test/unit/attributes.js b/test/unit/attributes.js index 37e854d06..b1cfe3db2 100644 --- a/test/unit/attributes.js +++ b/test/unit/attributes.js @@ -447,7 +447,7 @@ test("removeProp(String)", function() { }); test("val()", function() { - expect(25); + expect(26); document.getElementById("text1").value = "bla"; equals( jQuery("#text1").val(), "bla", "Check for modified value of input element" ); @@ -513,6 +513,8 @@ test("val()", function() { var $button = jQuery("").insertAfter("#button"); equals( $button.val(), "foobar", "Value retrieval on a button does not return innerHTML" ); equals( $button.val("baz").html(), "text", "Setting the value does not change innerHTML" ); + + equals( jQuery("