Skip to content

Commit 0fe9408

Browse files
committed
refactor($parse): Create idents lazily
Create the ident functions lazily as these are not used for filters not object literal properties Closes angular#9131
1 parent d8c8b2e commit 0fe9408

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/ng/parse.js

+12-2
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,11 @@ Lexer.prototype = {
318318
this.tokens.push({
319319
index: start,
320320
text: ident,
321-
fn: CONSTANTS[ident] || getterFn(ident, this.options, expression)
321+
// An indent may reference a primary, a filter or an object literal property
322+
// If the indent is not a constant then we create a lazy getter, this can be turned
323+
// into a real getter if it turns out to be a primary
324+
fn: CONSTANTS[ident],
325+
lazyFn: CONSTANTS[ident] ? undefined : lazyGetterFn(ident, this.options, expression)
322326
});
323327

324328
if (methodName) {
@@ -426,7 +430,7 @@ Parser.prototype = {
426430
primary = this.object();
427431
} else {
428432
var token = this.expect();
429-
primary = token.fn;
433+
primary = token.fn || token.lazyFn && token.lazyFn();
430434
if (!primary) {
431435
this.throwError('not a primary expression', token);
432436
}
@@ -945,6 +949,12 @@ function getterFn(path, options, fullExp) {
945949
return fn;
946950
}
947951

952+
function lazyGetterFn(ident, options, expression) {
953+
return function() {
954+
return getterFn(ident, options, expression);
955+
};
956+
}
957+
948958
///////////////////////////////////
949959

950960
/**

0 commit comments

Comments
 (0)