diff options
| author | niv-openerp <nicolas.vanhoren@openerp.com> | 2013-08-06 15:07:34 +0200 |
|---|---|---|
| committer | niv-openerp <nicolas.vanhoren@openerp.com> | 2013-08-06 15:07:34 +0200 |
| commit | e6e5fcde1ef2e530952b91899c3fbf70a603eff6 (patch) | |
| tree | 73fb9329bb7b057dd0abef53be8821b96adf6ee4 /addons/web/static/src/js/core.js | |
| parent | baef37aec64b21fbdb036345a740c35a5355bc8c (diff) | |
[IMP] Improved shim for function.bind
bzr revid: nicolas.vanhoren@openerp.com-20130806130734-lov3aq0m4b1r4sto
Diffstat (limited to 'addons/web/static/src/js/core.js')
| -rw-r--r-- | addons/web/static/src/js/core.js | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/addons/web/static/src/js/core.js b/addons/web/static/src/js/core.js index 6a4d85f7204..6a30868e8ec 100644 --- a/addons/web/static/src/js/core.js +++ b/addons/web/static/src/js/core.js @@ -11,6 +11,31 @@ if (typeof(console) === "undefined") { }); } +// shim provided by mozilla for function.bind +if (!Function.prototype.bind) { + Function.prototype.bind = function (oThis) { + if (typeof this !== "function") { + // closest thing possible to the ECMAScript 5 internal IsCallable function + throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable"); + } + + var aArgs = Array.prototype.slice.call(arguments, 1), + fToBind = this, + fNOP = function () {}, + fBound = function () { + return fToBind.apply(this instanceof fNOP && oThis + ? this + : oThis, + aArgs.concat(Array.prototype.slice.call(arguments))); + }; + + fNOP.prototype = this.prototype; + fBound.prototype = new fNOP(); + + return fBound; + }; +} + var instance = openerp; openerp.web.core = {}; |
