POGOserver/merges/android/scripts/android2.3-jscompat.js
2016-11-06 11:45:15 +01:00

31 lines
1.2 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Polyfill pour la prise en charge de Function.prototype.bind() sur Android 2.3
(function () {
if (!Function.prototype.bind) {
Function.prototype.bind = function (thisValue) {
if (typeof this !== "function") {
throw new TypeError(this + " cannot be bound as it is not a function");
}
// bind() permet également d'ajouter des arguments au début de l'appel
var preArgs = Array.prototype.slice.call(arguments, 1);
// Fonction réelle à laquelle lier la valeur et les arguments "this"
var functionToBind = this;
var noOpFunction = function () { };
// Argument "this" à utiliser
var thisArg = this instanceof noOpFunction && thisValue ? this : thisValue;
// Fonction liée résultante
var boundFunction = function () {
return functionToBind.apply(thisArg, preArgs.concat(Array.prototype.slice.call(arguments)));
};
noOpFunction.prototype = this.prototype;
boundFunction.prototype = new noOpFunction();
return boundFunction;
};
}
}());