aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit
diff options
context:
space:
mode:
authorruado1987 <ruado1987@gmail.com>2013-03-03 23:51:04 +0800
committerRichard Gibson <richard.gibson@gmail.com>2013-03-22 12:46:13 -0400
commit48d71d0c3e53d1bb1688fc6c0593b008ced3403b (patch)
treece43c6e0dfae7b2375a552acaa9b1f7230bb6b50 /test/unit
parentab5b0ff3f3f096c86dfbf74123d0a9a61f9a0528 (diff)
downloadjquery-48d71d0c3e53d1bb1688fc6c0593b008ced3403b.tar.gz
jquery-48d71d0c3e53d1bb1688fc6c0593b008ced3403b.zip
Fix #13514: Set selectedIndex to -1 when non-matching value is set on a select. Close gh-1191.
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/attributes.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/unit/attributes.js b/test/unit/attributes.js
index ccd1f4a99..f0ca137e6 100644
--- a/test/unit/attributes.js
+++ b/test/unit/attributes.js
@@ -850,6 +850,22 @@ test( "val()", function() {
equal( jQuery("<option/>").val("test").attr("value"), "test", "Setting value sets the value attribute" );
});
+test("val() with non-matching values on dropdown list", function() {
+ expect( 3 );
+
+ jQuery("#select5").val( "" );
+ equal( jQuery("#select5").val(), null, "Non-matching set on select-one" );
+
+ var select6 = jQuery("<select multiple id=\"select6\"><option value=\"1\">A</option><option value=\"2\">B</option></select>").appendTo("#form");
+ jQuery(select6).val( "nothing" );
+ equal( jQuery(select6).val(), null, "Non-matching set (single value) on select-multiple" );
+
+ jQuery(select6).val( ["nothing1", "nothing2"] );
+ equal( jQuery(select6).val(), null, "Non-matching set (array of values) on select-multiple" );
+
+ select6.remove();
+});
+
if ( "value" in document.createElement("meter") &&
"value" in document.createElement("progress") ) {