diff --git a/src/attributes.js b/src/attributes.js index 017a32da..2da2e163 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 37e854d0..b1cfe3db 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("