1
0
mirror of https://github.com/moparisthebest/mail synced 2024-11-29 12:22:22 -05:00

add Function.prototype.bind polyfill in tests because phantomjs is buggy

This commit is contained in:
Felix Hammerl 2014-07-02 16:46:17 +02:00
parent 0e46cdc624
commit c335fee0d5
2 changed files with 44 additions and 0 deletions

View File

@ -1,5 +1,27 @@
'use strict'; 'use strict';
// Mozilla bind polyfill because phantomjs is stupid
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;
};
}
require(['src/require-config'], function() { require(['src/require-config'], function() {
require.config({ require.config({
baseUrl: 'src/lib', baseUrl: 'src/lib',

View File

@ -1,5 +1,27 @@
'use strict'; 'use strict';
// Mozilla bind polyfill because phantomjs is stupid
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;
};
}
require(['../../src/require-config'], function() { require(['../../src/require-config'], function() {
require.config({ require.config({
baseUrl: '../../src/lib', baseUrl: '../../src/lib',