aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMisko Hevery2010-07-02 14:43:17 -0700
committerMisko Hevery2010-07-02 14:43:17 -0700
commit105e9443c4170870dd34f69073a6eafaabeaf567 (patch)
treee7d591f255ec945c5b21813e186fda9e3c00c52c
parentfdc0bb232a259faf791b901f583e09bba3213ba5 (diff)
downloadangular.js-105e9443c4170870dd34f69073a6eafaabeaf567.tar.bz2
fixed special keywords in chrome such as x.throw must be x["throw"].
-rw-r--r--scenario/perf.html2
-rw-r--r--src/Scope.js3
2 files changed, 3 insertions, 2 deletions
diff --git a/scenario/perf.html b/scenario/perf.html
index cd676918..50a8d28f 100644
--- a/scenario/perf.html
+++ b/scenario/perf.html
@@ -8,7 +8,7 @@
PerfCntl.prototype = {
createItems: function(){
var items = [];
- for ( var i = 0; i < 1000; i++) {
+ for ( var i = 0; i < 100; i++) {
var item = {
name: "" + Math.random(),
parts: [Math.random(), Math.random()]
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';