mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Don't pass a null context to Function.prototype.call.
This prevents PhantomJS tests from hanging in the open-source React repo. Until the advent of `"use strict"`, passing `null` as the context object to `.call` or `.apply` resulted in `this` taking on the value of the global object inside the invoked function. Technically the `"use strict"` directive is supposed to make it possible that `this === null`, but strict mode is not respected by all browsers, including (unfortunately) PhantomJS. Since these `expect`-ations are just testing binding behavior, let's not make them also test strict mode `this` handling.
This commit is contained in:
committed by
Paul O’Shannessy
parent
cf926338bf
commit
5a85c5e535
@@ -207,9 +207,10 @@ describe('ReactCompositeComponent', function() {
|
||||
var autoBound = instance.methodAutoBound;
|
||||
var explicitlyNotBound = instance.methodExplicitlyNotBound;
|
||||
|
||||
expect(explicitlyBound.call(null)).toBe(instance);
|
||||
expect(autoBound.call(null)).toBe(instance);
|
||||
expect(explicitlyNotBound.call(null)).toBe(null);
|
||||
var context = {};
|
||||
expect(explicitlyBound.call(context)).toBe(instance);
|
||||
expect(autoBound.call(context)).toBe(instance);
|
||||
expect(explicitlyNotBound.call(context)).toBe(context);
|
||||
|
||||
expect(explicitlyBound.call(instance)).toBe(instance);
|
||||
expect(autoBound.call(instance)).toBe(instance);
|
||||
|
||||
Reference in New Issue
Block a user