Skip to content

Commit 105e944

Browse files
committed
fixed special keywords in chrome such as x.throw must be x["throw"].
1 parent fdc0bb2 commit 105e944

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

scenario/perf.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
PerfCntl.prototype = {
99
createItems: function(){
1010
var items = [];
11-
for ( var i = 0; i < 1000; i++) {
11+
for ( var i = 0; i < 100; i++) {
1212
var item = {
1313
name: "" + Math.random(),
1414
parts: [Math.random(), Math.random()]

src/Scope.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,15 @@ function setter(instance, path, value){
4646
///////////////////////////////////
4747

4848
var getterFnCache = {};
49+
var JS_KEYWORDS = ["this", "throw", "for", "foreach", "var", "const"];
4950
function getterFn(path){
5051
var fn = getterFnCache[path];
5152
if (fn) return fn;
5253

5354
var code = 'function (self){\n';
5455
code += ' var last, fn, type;\n';
5556
foreach(path.split('.'), function(key) {
56-
key = (key == 'this') ? '["this"]' : '.' + key;
57+
key = (includes(JS_KEYWORDS, key)) ? '["' + key + '"]' : '.' + key;
5758
code += ' if(!self) return self;\n';
5859
code += ' last = self;\n';
5960
code += ' self = self' + key + ';\n';

0 commit comments

Comments
 (0)