Polyfill Function.prototype.bind during tests.

This commit is contained in:
Ben Newman
2013-06-03 13:20:13 -04:00
parent f8af93237a
commit 03f92bb155
2 changed files with 21 additions and 20 deletions
+21
View File
@@ -2,6 +2,27 @@
// modules in src/test and to specify an ordering on those modules, since
// some still have implicit dependencies on others.
var Ap = Array.prototype;
var slice = Ap.slice;
var Fp = Function.prototype;
if (!Fp.bind) {
// PhantomJS doesn't support Function.prototype.bind natively, so
// polyfill it whenever this module is required.
Fp.bind = function(context) {
var func = this;
var args = slice.call(arguments, 1);
return args.length > 0 ? function() {
return func.apply(
context || this,
args.concat(slice.call(arguments))
);
} : function() {
return func.apply(context || this, arguments);
};
};
}
require("ReactTestUtils");
require("reactComponentExpect");
require("mocks");
-20
View File
@@ -19,26 +19,6 @@
var console = require("./console");
var global = Function("return this")();
var Ap = Array.prototype;
var slice = Ap.slice;
var Fp = Function.prototype;
if (!Fp.bind) {
// PhantomJS doesn't support Function.prototype.bind natively, so
// polyfill it whenever this module is required.
Fp.bind = function(context) {
var func = this;
var args = slice.call(arguments, 1);
return args.length > 0 ? function() {
return func.apply(
context || this,
args.concat(slice.call(arguments))
);
} : function() {
return func.apply(context || this, arguments);
};
};
}
if (global.callPhantom) {
// Phantom's onConsoleMessage support is lacking (only one argument