Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
modify .removeClass() to accept functions as argument
  • Loading branch information
ekhaled committed May 3, 2011
1 parent 50ee09a commit 677054c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/zepto.js
Expand Up @@ -252,9 +252,9 @@ var Zepto = (function() {
})
},
removeClass: function(name){
return this.each(function() {
return this.each(function(idx) {
classList = this.className;
name.split(/\s+/g).forEach(function(klass) {
funcArg(this,name,idx,classList).split(/\s+/g).forEach(function(klass) {
classList = classList.replace(classRE(klass), " ")
});
this.className = classList.trim()
Expand Down
10 changes: 10 additions & 0 deletions test/zepto.html
Expand Up @@ -1067,6 +1067,16 @@ <h1>Zepto DOM unit tests</h1>
return "green";
});
t.assertEqual('red blue green', el.className);

//removeClass with function argument
$('#some_element').removeClass(function(idx,classes){
//test the value of "this"
t.assertEqualCollection($('#some_element'), $(this));
//test original classes are being passed
t.assertEqual('red blue green', this.className);
return "blue";
});
t.assertEqual('red green', el.className);
},

testHasClass: function(t){
Expand Down

0 comments on commit 677054c

Please sign in to comment.