Skip to content

Commit

Permalink
Fix this/strict mode detection in old browsers.
Browse files Browse the repository at this point in the history
`global` is undefined in the browser, and this is a better strategy anyway.

The bad fix was introduced in kriskowal#193.
  • Loading branch information
domenic committed Feb 16, 2013
1 parent 3031736 commit 450df46
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions spec/q-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ if (typeof Q === "undefined" && typeof require !== "undefined") {

var REASON = "this is not an error, but it might show up in the console";

var STRICT_MODE_CAPABLE = (function(){
return !this;
})();
// In browsers that support strict mode, it'll be `undefined`; otherwise, the global.
var calledAsFunctionThis = (function () { return this; }());

afterEach(function () {
Q.onerror = null;
Expand Down Expand Up @@ -405,7 +404,7 @@ describe("progress", function () {
deferred.promise,
function () {
expect(progressed).toBe(true);
expect(progressContext).toBe(STRICT_MODE_CAPABLE ? undefined : global);
expect(progressContext).toBe(calledAsFunctionThis);
},
function () {
expect(true).toBe(false);
Expand Down

0 comments on commit 450df46

Please sign in to comment.