Coerce all array values to strings before comparison in val(). Fixes bug #7123.
[jquery.git] / test / unit / attributes.js
index a483195..c6007aa 100644 (file)
@@ -409,7 +409,19 @@ test("val(String/Number)", function() {
 
 test("val(Function)", function() {
        testVal(functionReturningObj);
-})
+});
+
+test( "val(Array of Numbers) (Bug #7123)", function() {
+       expect(4);
+       jQuery('#form').append('<input type="checkbox" name="arrayTest" value="1" /><input type="checkbox" name="arrayTest" value="2" /><input type="checkbox" name="arrayTest" value="3" checked="checked" /><input type="checkbox" name="arrayTest" value="4" />');
+       var elements = jQuery('input[name=arrayTest]').val([ 1, 2 ]);
+       ok( elements[0].checked, "First element was checked" );
+       ok( elements[1].checked, "Second element was checked" );
+       ok( !elements[2].checked, "Third element was unchecked" );
+       ok( !elements[3].checked, "Fourth element remained unchecked" );
+       
+       elements.remove();
+});
 
 test("val(Function) with incoming value", function() {
        expect(10);