aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Scope.js11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/Scope.js b/src/Scope.js
index b45efbce..35da77fe 100644
--- a/src/Scope.js
+++ b/src/Scope.js
@@ -46,7 +46,14 @@ function setter(instance, path, value){
///////////////////////////////////
var getterFnCache = {};
-var JS_KEYWORDS = ["this", "throw", "for", "foreach", "var", "const"];
+var JS_KEYWORDS = {};
+foreach(
+ ["break", "const", "continue", "class", "delete",
+ "do", "while", "for", "function", "if",
+ "instanceof", "new", "return", "switch",
+ "this", "throw", "try", "catch", "with"],
+ function(key){ JS_KEYWORDS[key] = true;}
+);
function getterFn(path){
var fn = getterFnCache[path];
if (fn) return fn;
@@ -54,7 +61,7 @@ function getterFn(path){
var code = 'function (self){\n';
code += ' var last, fn, type;\n';
foreach(path.split('.'), function(key) {
- key = (includes(JS_KEYWORDS, key)) ? '["' + key + '"]' : '.' + key;
+ key = (JS_KEYWORDS[key]) ? '["' + key + '"]' : '.' + key;
code += ' if(!self) return self;\n';
code += ' last = self;\n';
code += ' self = self' + key + ';\n';