@samitouri / QOS-React-2 / commits / 5a85c5e535
Fork 0

The library for web and native user interfaces.

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.

CommitSyncScript committed Jun 26, 2013 at 11:20 UTC 5a85c5e53543b4a4c45e59009eaaa8fe14d8d500
1 file changed +4 -3
src/core/__tests__/ReactCompositeComponent-test.js
+4 -3
@@ -207,9 +207,10 @@ describe('ReactCompositeComponent', function() {
207 var autoBound = instance.methodAutoBound;
208 var explicitlyNotBound = instance.methodExplicitlyNotBound;
209
210 - expect(explicitlyBound.call(null)).toBe(instance);
211 - expect(autoBound.call(null)).toBe(instance);
212 - expect(explicitlyNotBound.call(null)).toBe(null);
210 + var context = {};
211 + expect(explicitlyBound.call(context)).toBe(instance);
212 + expect(autoBound.call(context)).toBe(instance);
213 + expect(explicitlyNotBound.call(context)).toBe(context);
214
215 expect(explicitlyBound.call(instance)).toBe(instance);
216 expect(autoBound.call(instance)).toBe(instance);