diff options
author | timmywil <tim.willison@thisismedium.com> | 2011-04-17 18:15:20 -0400 |
---|---|---|
committer | timmywil <tim.willison@thisismedium.com> | 2011-04-17 18:17:31 -0400 |
commit | 34d80709ce9bd583f6f5dd17e9bffa2fb7cff3c5 (patch) | |
tree | e96347967ab5ee24decd3b7e4674d44abecf8ecf /test | |
parent | 15da298f72bf94a95563abc12b8e6fec8c604099 (diff) | |
download | jquery-34d80709ce9bd583f6f5dd17e9bffa2fb7cff3c5.tar.gz jquery-34d80709ce9bd583f6f5dd17e9bffa2fb7cff3c5.zip |
Fix value attribute and val for value on button elements. Fixes #1954
Diffstat (limited to 'test')
-rw-r--r-- | test/unit/attributes.js | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/test/unit/attributes.js b/test/unit/attributes.js index a497effa7..80ccf71a8 100644 --- a/test/unit/attributes.js +++ b/test/unit/attributes.js @@ -77,7 +77,7 @@ test("prop(String, Object)", function() { }); test("attr(String)", function() { - expect(32); + expect(34); equals( jQuery("#text1").attr("type"), "text", "Check for type attribute" ); equals( jQuery("#radio1").attr("type"), "radio", "Check for type attribute" ); @@ -136,6 +136,11 @@ test("attr(String)", function() { ok( !!~jQuery("#dl").attr("style").indexOf("position"), "Check style attribute getter, also normalize css props to lowercase" ); ok( !!~jQuery("#foo").attr("style", "position:absolute;").attr("style").indexOf("position"), "Check style setter" ); + // Check value on button element (#1954) + var $button = jQuery("<button value='foobar'>text</button>").insertAfter("#button"); + equals( $button.attr("value"), "foobar", "Value retrieval on a button does not return innerHTML" ); + equals( $button.attr("value", "baz").html(), "text", "Setting the value does not change innerHTML" ); + ok( jQuery("<div/>").attr("doesntexist") === undefined, "Make sure undefined is returned when no attribute is found." ); ok( jQuery().attr("doesntexist") === undefined, "Make sure undefined is returned when no element is there." ); }); @@ -426,7 +431,7 @@ test("removeProp(String)", function() { }); test("val()", function() { - expect(23); + expect(25); document.getElementById("text1").value = "bla"; equals( jQuery("#text1").val(), "bla", "Check for modified value of input element" ); @@ -488,6 +493,10 @@ test("val()", function() { same( checks.serialize(), "test=1&test=on", "Get multiple checked values." ); checks.remove(); + + 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("baz").html(), "text", "Setting the value does not change innerHTML" ); }); var testVal = function(valueObj) { |