UNPKG

can

Version:

MIT-licensed, client-side, JavaScript framework that makes building rich web applications easy.

43 lines (42 loc) 1.18 kB
/*! * CanJS - 2.3.34 * http://canjs.com/ * Copyright (c) 2018 Bitovi * Mon, 30 Apr 2018 20:56:51 GMT * Licensed MIT */ /*can@2.3.34#util/bind/bind*/ define(['can/util/library'], function (can) { can.bindAndSetup = function () { can.addEvent.apply(this, arguments); if (!this.__inSetup) { if (!this._bindings) { this._bindings = 1; if (this._bindsetup) { this._bindsetup(); } } else { this._bindings++; } } return this; }; can.unbindAndTeardown = function (event, handler) { if (!this.__bindEvents) { return this; } var handlers = this.__bindEvents[event] || []; var handlerCount = handlers.length; can.removeEvent.apply(this, arguments); if (this._bindings === null) { this._bindings = 0; } else { this._bindings = this._bindings - (handlerCount - handlers.length); } if (!this._bindings && this._bindteardown) { this._bindteardown(); } return this; }; return can; });