Commit 4ac2fdda authored by timmywil's avatar timmywil

Fix setting value attributes on option elements. Fixes #9071.

parent 6d2fd57f
...@@ -199,7 +199,7 @@ jQuery.fn.extend({ ...@@ -199,7 +199,7 @@ jQuery.fn.extend({
hooks = jQuery.valHooks[ this.nodeName.toLowerCase() ] || jQuery.valHooks[ this.type ]; hooks = jQuery.valHooks[ this.nodeName.toLowerCase() ] || jQuery.valHooks[ this.type ];
// If set returns undefined, fall back to normal setting // 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; this.value = val;
} }
}); });
......
...@@ -447,7 +447,7 @@ test("removeProp(String)", function() { ...@@ -447,7 +447,7 @@ test("removeProp(String)", function() {
}); });
test("val()", function() { test("val()", function() {
expect(25); expect(26);
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" );
...@@ -513,6 +513,8 @@ test("val()", function() { ...@@ -513,6 +513,8 @@ test("val()", function() {
var $button = jQuery("<button value='foobar'>text</button>").insertAfter("#button"); var $button = jQuery("<button value='foobar'>text</button>").insertAfter("#button");
equals( $button.val(), "foobar", "Value retrieval on a button does not return innerHTML" ); 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( $button.val("baz").html(), "text", "Setting the value does not change innerHTML" );
equals( jQuery("<option/>").val("test").attr("value"), "test", "Setting value sets the value attribute" );
}); });
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