mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-04-12 10:21:00 +00:00
37 lines
1.1 KiB
JavaScript
37 lines
1.1 KiB
JavaScript
/* _ES5_COMPAT_START_ */
|
|
(function() {
|
|
|
|
var slice = Array.prototype.slice,
|
|
apply = Function.prototype.apply,
|
|
Dummy = function() { };
|
|
|
|
if (!Function.prototype.bind) {
|
|
/**
|
|
* Cross-browser approximation of ES5 Function.prototype.bind (not fully spec conforming)
|
|
* @see <a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function/bind">Function#bind on MDN</a>
|
|
* @param {Object} thisArg Object to bind function to
|
|
* @param {Any[]} Values to pass to a bound function
|
|
* @return {Function}
|
|
*/
|
|
Function.prototype.bind = function(thisArg) {
|
|
var _this = this, args = slice.call(arguments, 1), bound;
|
|
if (args.length) {
|
|
bound = function() {
|
|
return apply.call(_this, this instanceof Dummy ? this : thisArg, args.concat(slice.call(arguments)));
|
|
};
|
|
}
|
|
else {
|
|
/** @ignore */
|
|
bound = function() {
|
|
return apply.call(_this, this instanceof Dummy ? this : thisArg, arguments);
|
|
};
|
|
}
|
|
Dummy.prototype = this.prototype;
|
|
bound.prototype = new Dummy();
|
|
|
|
return bound;
|
|
};
|
|
}
|
|
|
|
})();
|
|
/* _ES5_COMPAT_END_ */
|