use ES5 bind() for better stack traces

bzr revid: al@openerp.com-20121110190014-ead1981ez6up6ri1
This commit is contained in:
Antony Lesuisse 2012-11-10 20:00:14 +01:00
parent fac7bea3a2
commit 3fe1945347
1 changed files with 1 additions and 7 deletions

View File

@ -429,17 +429,11 @@ instance.web.PropertiesMixin = _.extend({}, instance.web.EventDispatcherMixin, {
instance.web.CallbackEnabledMixin = _.extend({}, instance.web.PropertiesMixin, {
init: function() {
instance.web.PropertiesMixin.init.call(this);
var self = this;
// Transform on_/do_* methods into callbacks
var callback_maker = function(fn) {
return function() {
return fn.apply(self, arguments);
}
};
for (var name in this) {
if(typeof(this[name]) == "function") {
if((/^on_|^do_/).test(name)) {
this[name] = callback_maker(this[name]);
this[name] = this[name].bind(this);
}
}
}