Skip to content

Commit

Permalink
Ensure JSON var isn't shadowed in JSC and Spidermonkey
Browse files Browse the repository at this point in the history
  • Loading branch information
josh committed May 12, 2011
1 parent a1277a6 commit f47c02c
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions lib/execjs/support/json2.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,13 @@
// Create a JSON object only if one does not already exist. We create the
// methods in a closure to avoid creating global variables.

var JSON;
if (!JSON) {
JSON = {};
}
(function (global) {
if (!global.JSON) {
global.JSON = {};
}

var JSON = global.JSON;

(function () {
"use strict";

function f(n) {
Expand Down Expand Up @@ -477,4 +478,4 @@ if (!JSON) {
throw new SyntaxError('JSON.parse');
};
}
}());
}(this));

0 comments on commit f47c02c

Please sign in to comment.