Skip to content

Commit 6fb121e

Browse files
lgalfasorodyhaddad
authored andcommitted
refactor(parse): simplify the Parser's filter function
1 parent f7a0a38 commit 6fb121e

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

src/ng/parse.js

+10-14
Original file line numberDiff line numberDiff line change
@@ -542,21 +542,17 @@ Parser.prototype = {
542542
var token = this.expect();
543543
var fn = this.$filter(token.text);
544544
var argsFn = [];
545-
while (true) {
546-
if ((token = this.expect(':'))) {
547-
argsFn.push(this.expression());
548-
} else {
549-
var fnInvoke = function(self, locals, input) {
550-
var args = [input];
551-
for (var i = 0; i < argsFn.length; i++) {
552-
args.push(argsFn[i](self, locals));
553-
}
554-
return fn.apply(self, args);
555-
};
556-
return function() {
557-
return fnInvoke;
558-
};
545+
while(this.expect(':')) {
546+
argsFn.push(this.expression());
547+
}
548+
return valueFn(fnInvoke);
549+
550+
function fnInvoke(self, locals, input) {
551+
var args = [input];
552+
for (var i = 0; i < argsFn.length; i++) {
553+
args.push(argsFn[i](self, locals));
559554
}
555+
return fn.apply(self, args);
560556
}
561557
},
562558

0 commit comments

Comments
 (0)