Skip to content

Commit f47c02c

Browse files
committed
Ensure JSON var isn't shadowed in JSC and Spidermonkey
1 parent a1277a6 commit f47c02c

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

lib/execjs/support/json2.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,13 @@
159159
// Create a JSON object only if one does not already exist. We create the
160160
// methods in a closure to avoid creating global variables.
161161

162-
var JSON;
163-
if (!JSON) {
164-
JSON = {};
165-
}
162+
(function (global) {
163+
if (!global.JSON) {
164+
global.JSON = {};
165+
}
166+
167+
var JSON = global.JSON;
166168

167-
(function () {
168169
"use strict";
169170

170171
function f(n) {
@@ -477,4 +478,4 @@ if (!JSON) {
477478
throw new SyntaxError('JSON.parse');
478479
};
479480
}
480-
}());
481+
}(this));

0 commit comments

Comments
 (0)