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

refactor($parse): clean up evaled function #5299

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions src/ng/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -1006,11 +1006,10 @@ function getterFn(path, options, fullExp) {
};
}
} else {
var code = 'var l, fn, p;\n';
var code = options.unwrapPromises ? 'var p;\n' : '';
forEach(pathKeys, function(key, index) {
ensureSafeMemberName(key, fullExp);
code += 'if(s === null || s === undefined) return s;\n' +
'l=s;\n' +
code += 'if(s == null) return s;\n' +
's='+ (index
// we simply dereference 's' on any .dot notation
? 's'
Expand All @@ -1034,9 +1033,9 @@ function getterFn(path, options, fullExp) {
var evaledFnGetter = new Function('s', 'k', 'pw', code); // s=scope, k=locals, pw=promiseWarning
/* jshint +W054 */
evaledFnGetter.toString = function() { return code; };
fn = function(scope, locals) {
fn = options.unwrapPromises ? function(scope, locals) {
return evaledFnGetter(scope, locals, promiseWarning);
};
} : evaledFnGetter;
}

// Only cache the value if it's not going to mess up the cache object
Expand Down