mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-06-05 20:01:00 +08:00
refactor(parse): simplify the Parser's filter function
This commit is contained in:
committed by
rodyhaddad
parent
f7a0a386ee
commit
6fb121e64c
@@ -542,21 +542,17 @@ Parser.prototype = {
|
||||
var token = this.expect();
|
||||
var fn = this.$filter(token.text);
|
||||
var argsFn = [];
|
||||
while (true) {
|
||||
if ((token = this.expect(':'))) {
|
||||
argsFn.push(this.expression());
|
||||
} else {
|
||||
var fnInvoke = function(self, locals, input) {
|
||||
var args = [input];
|
||||
for (var i = 0; i < argsFn.length; i++) {
|
||||
args.push(argsFn[i](self, locals));
|
||||
}
|
||||
return fn.apply(self, args);
|
||||
};
|
||||
return function() {
|
||||
return fnInvoke;
|
||||
};
|
||||
while(this.expect(':')) {
|
||||
argsFn.push(this.expression());
|
||||
}
|
||||
return valueFn(fnInvoke);
|
||||
|
||||
function fnInvoke(self, locals, input) {
|
||||
var args = [input];
|
||||
for (var i = 0; i < argsFn.length; i++) {
|
||||
args.push(argsFn[i](self, locals));
|
||||
}
|
||||
return fn.apply(self, args);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user