From 5a85c5e53543b4a4c45e59009eaaa8fe14d8d500 Mon Sep 17 00:00:00 2001 From: CommitSyncScript Date: Wed, 26 Jun 2013 11:20:36 -0700 Subject: [PATCH] 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. --- src/core/__tests__/ReactCompositeComponent-test.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/core/__tests__/ReactCompositeComponent-test.js b/src/core/__tests__/ReactCompositeComponent-test.js index c9aad6498a..abbd7cf17f 100644 --- a/src/core/__tests__/ReactCompositeComponent-test.js +++ b/src/core/__tests__/ReactCompositeComponent-test.js @@ -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);