Skip to content

Commit

Permalink
One event binder callback now receives events in callback
Browse files Browse the repository at this point in the history
  • Loading branch information
philnash committed Jun 2, 2011
1 parent 7b75663 commit c36efa9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@
$.fn.one = function(event, callback){
return this.each(function(){
var self = this;
add(this, event, function wrapper(){
callback();
add(this, event, function wrapper(evt){
callback(evt);
remove(self, event, arguments.callee);
});
});
Expand Down
7 changes: 7 additions & 0 deletions test/zepto.html
Original file line number Diff line number Diff line change
Expand Up @@ -953,6 +953,13 @@ <h1>Zepto DOM unit tests</h1>
t.assertEqual(1, counter);
},

testOneCallbackEvent: function(t){
var target, someElement = $('#some_element').get(0);
$(document.body).one('click', function(evt){ target = evt.target; });
click(someElement);
t.assertEqual(someElement, target);
},

testAttr: function(t){
var els = $('#attr_1, #attr_2');

Expand Down

0 comments on commit c36efa9

Please sign in to comment.