Skip to content

Commit

Permalink
val(value) now accepts a function argument
Browse files Browse the repository at this point in the history
  • Loading branch information
mislav committed Sep 2, 2011
1 parent ca85920 commit 1f90bcb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/zepto.js
Expand Up @@ -314,8 +314,8 @@ var Zepto = (function() {
val: function(value){
return (value === undefined) ?
(this.length > 0 ? this[0].value : null) :
this.each(function(){
this.value = value;
this.each(function(idx){
this.value = funcArg(this, value, idx, this.value);
});
},
offset: function(){
Expand Down
3 changes: 3 additions & 0 deletions test/zepto.html
Expand Up @@ -1352,6 +1352,9 @@ <h1>Zepto DOM unit tests</h1>

input.get(0).value = 'Hello again';
t.assertEqual('Hello again', input.val());

input.val(function(i, val){ return val.replace('Hello', 'Bye') });
t.assertEqual('Bye again', input.val());
},

testChaining: function(t){
Expand Down

0 comments on commit 1f90bcb

Please sign in to comment.