Skip to content
Permalink
Browse files

Merge branch 'bug7123' of http://github.com/csnover/jquery into csnov…

…er-bug7123
  • Loading branch information...
jeresig committed Oct 9, 2010
2 parents 9b655a1 + b034169 commit 4a0759dc79fd0ad540d946c346a5afe9ce9db4ad
Showing with 17 additions and 1 deletion.
  1. +4 −0 src/attributes.js
  2. +13 −1 test/unit/attributes.js
@@ -215,6 +215,10 @@ jQuery.fn.extend({
val = "";
} else if ( typeof val === "number" ) {
val += "";
} else if ( jQuery.isArray(val) ) {
val = jQuery.map(val, function (value) {
return value == null ? "" : value + "";
});
}

if ( jQuery.isArray(val) && rradiocheck.test( this.type ) ) {
@@ -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);

0 comments on commit 4a0759d

Please sign in to comment.
You can’t perform that action at this time.