mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Polyfill Function.prototype.bind during tests.
This commit is contained in:
@@ -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");
|
||||
|
||||
Vendored
-20
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user