From 454aa8433b2bb13b40a443f830be8f9c42ea6af5 Mon Sep 17 00:00:00 2001 From: Michael Ficarra Date: Wed, 25 May 2011 03:43:10 -0400 Subject: [PATCH] fixes #1390: persistence of non-enumerable global properties in the REPL --- lib/coffee-script.js | 6 ++++-- lib/repl.js | 6 ++++-- src/coffee-script.coffee | 2 +- src/repl.coffee | 2 +- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/coffee-script.js b/lib/coffee-script.js index d8b0dd87..abdfd645 100755 --- a/lib/coffee-script.js +++ b/lib/coffee-script.js @@ -60,7 +60,7 @@ } }; exports.eval = function(code, options) { - var g, js, sandbox; + var g, js, sandbox, _i, _len, _ref2; if (options == null) { options = {}; } @@ -72,7 +72,9 @@ exports: {} } }; - for (g in global) { + _ref2 = Object.getOwnPropertyNames(global); + for (_i = 0, _len = _ref2.length; _i < _len; _i++) { + g = _ref2[_i]; sandbox[g] = global[g]; } sandbox.global = sandbox; diff --git a/lib/repl.js b/lib/repl.js index 84dd70e8..5f468bc6 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -16,14 +16,16 @@ }; backlog = ''; run = (function() { - var g, sandbox; + var g, sandbox, _i, _len, _ref; sandbox = { require: require, module: { exports: {} } }; - for (g in global) { + _ref = Object.getOwnPropertyNames(global); + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + g = _ref[_i]; sandbox[g] = global[g]; } sandbox.global = sandbox; diff --git a/src/coffee-script.coffee b/src/coffee-script.coffee index 16b76927..be892880 100755 --- a/src/coffee-script.coffee +++ b/src/coffee-script.coffee @@ -82,7 +82,7 @@ exports.eval = (code, options = {}) -> sandbox = require: require module : { exports: {} } - sandbox[g] = global[g] for g of global + sandbox[g] = global[g] for g in Object.getOwnPropertyNames global sandbox.global = sandbox sandbox.global.global = sandbox.global.root = sandbox.global.GLOBAL = sandbox sandbox.__filename = options.filename || 'eval' diff --git a/src/repl.coffee b/src/repl.coffee index 4ba1d0f3..1e42e037 100644 --- a/src/repl.coffee +++ b/src/repl.coffee @@ -35,7 +35,7 @@ run = do -> sandbox = require: require module : { exports: {} } - sandbox[g] = global[g] for g of global + sandbox[g] = global[g] for g in Object.getOwnPropertyNames global sandbox.global = sandbox sandbox.global.global = sandbox.global.root = sandbox.global.GLOBAL = sandbox (buffer) ->