Skip to content

Commit

Permalink
fixes bind to prevent cycles
Browse files Browse the repository at this point in the history
  • Loading branch information
justinbmeyer committed May 1, 2013
1 parent 0e4a0cb commit d0fe33b
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions util/bind/bind.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@ steal('can/util',function(can){
// call bindsetup if the function exists.
if(!this._init){
if(!this._bindings ){
this._bindings = 1;
// setup live-binding
this._bindsetup && this._bindsetup();
this._bindings = 0;

} else {
this._bindings++;
}
this._bindings++;

}

return this;
Expand All @@ -29,15 +32,7 @@ steal('can/util',function(can){
can.unbindAndTeardown = function(ev, handler) {
// Remove the event handler
can.removeEvent.apply(this, arguments);
// This doesn't work as handler is never passed
// if(!handler){
// // This is not correct. We need to
// // have a way to know the number of event handlers
// // for a given item.
// this._bindings = 0
// } else {
// this._bindings--;
// }

this._bindings--;
// If there are no longer any bindings and
// there is a bindteardown method, call it.
Expand Down

0 comments on commit d0fe33b

Please sign in to comment.