From 105e9443c4170870dd34f69073a6eafaabeaf567 Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Fri, 2 Jul 2010 14:43:17 -0700 Subject: fixed special keywords in chrome such as x.throw must be x["throw"]. --- src/Scope.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/Scope.js') diff --git a/src/Scope.js b/src/Scope.js index 637fc25e..e9b61ec4 100644 --- a/src/Scope.js +++ b/src/Scope.js @@ -46,6 +46,7 @@ function setter(instance, path, value){ /////////////////////////////////// var getterFnCache = {}; +var JS_KEYWORDS = ["this", "throw", "for", "foreach", "var", "const"]; function getterFn(path){ var fn = getterFnCache[path]; if (fn) return fn; @@ -53,7 +54,7 @@ function getterFn(path){ var code = 'function (self){\n'; code += ' var last, fn, type;\n'; foreach(path.split('.'), function(key) { - key = (key == 'this') ? '["this"]' : '.' + key; + key = (includes(JS_KEYWORDS, key)) ? '["' + key + '"]' : '.' + key; code += ' if(!self) return self;\n'; code += ' last = self;\n'; code += ' self = self' + key + ';\n'; -- cgit v1.2.3