Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 8b32900

Browse files
committed
fix($parse): simplify getterFn
1 parent 18a1e86 commit 8b32900

File tree

1 file changed

+2
-13
lines changed

1 file changed

+2
-13
lines changed

src/service/parse.js

+2-13
Original file line numberDiff line numberDiff line change
@@ -693,28 +693,17 @@ function getter(obj, path, bindFnToScope) {
693693
return obj;
694694
}
695695

696-
var getterFnCache = {},
697-
JS_KEYWORDS = {};
698-
699-
forEach(
700-
("abstract,boolean,break,byte,case,catch,char,class,const,continue,debugger,default," +
701-
"delete,do,double,else,enum,export,extends,false,final,finally,float,for,function,goto," +
702-
"if,implements,import,in,instanceof,int,interface,long,native,new,null,package,private," +
703-
"protected,public,return,short,static,super,switch,synchronized,this,throw,throws," +
704-
"transient,true,try,typeof,var,volatile,void,undefined,while,with").split(/,/),
705-
function(key){ JS_KEYWORDS[key] = true;}
706-
);
696+
var getterFnCache = {};
707697

708698
function getterFn(path) {
709699
var fn = getterFnCache[path];
710700
if (fn) return fn;
711701

712702
var code = 'var l, fn, p;\n';
713703
forEach(path.split('.'), function(key) {
714-
key = (JS_KEYWORDS[key]) ? '["' + key + '"]' : '.' + key;
715704
code += 'if(!s) return s;\n' +
716705
'l=s;\n' +
717-
's=s' + key + ';\n' +
706+
's=s' + '["' + key + '"]' + ';\n' +
718707
'if (s && s.then) {\n' +
719708
' if (!("$$v" in s)) {\n' +
720709
' p=s;\n' +

0 commit comments

Comments
 (0)