[FIX] add a correct rounding algorithm to be able to duplicate server-side financial...
[odoo/odoo.git] / addons / web / static / src / fixbind.js
1 // Fix old versions of Webkit (such as ones used on iOS < 6 or PhantomJS <= 1.7)
2 // which does not have Function.prototype.bind function
3
4 // Use moz polyfill:
5 // https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Function/bind#Compatibility
6 if (!Function.prototype.bind) {
7   Function.prototype.bind = function (oThis) {
8     if (typeof this !== "function") {
9       // closest thing possible to the ECMAScript 5 internal IsCallable function
10       throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");
11     }
12
13     var aArgs = Array.prototype.slice.call(arguments, 1),
14         fToBind = this,
15         fNOP = function () {},
16         fBound = function () {
17           return fToBind.apply(this instanceof fNOP && oThis
18                                  ? this
19                                  : oThis,
20                                aArgs.concat(Array.prototype.slice.call(arguments)));
21         };
22
23     fNOP.prototype = this.prototype;
24     fBound.prototype = new fNOP();
25
26     return fBound;
27   };
28 }