aboutsummaryrefslogtreecommitdiffstats
path: root/src/Parser.js
diff options
context:
space:
mode:
authorMisko Hevery2010-02-12 14:16:33 -0800
committerMisko Hevery2010-02-12 14:17:44 -0800
commit6cc946413622f1cef97997849e73a06a00f876fd (patch)
treeb0e4e10405fc8cd91e6d55507b3a6a02528928a9 /src/Parser.js
parentb2a8a089b6c31c8ff176c2483f659caae4f71afb (diff)
downloadangular.js-6cc946413622f1cef97997849e73a06a00f876fd.tar.bz2
Fixed negation grouping bug
Make 'this' of validation be scope
Diffstat (limited to 'src/Parser.js')
-rw-r--r--src/Parser.js53
1 files changed, 23 insertions, 30 deletions
diff --git a/src/Parser.js b/src/Parser.js
index fe9671af..3aa644ac 100644
--- a/src/Parser.js
+++ b/src/Parser.js
@@ -369,7 +369,16 @@ Parser.prototype = {
for ( var i = 0; i < argsFn.length; i++) {
args.push(argsFn[i](self));
}
- return fn.apply(self, args);
+ var pipeThis = function(){
+ var _this = this;
+ foreach(self, function(v, k) {
+ if (k.charAt(0) == '$') {
+ _this[k] = v;
+ }
+ });
+ };
+ pipeThis.prototype = self.self;
+ return fn.apply(new pipeThis(), args);
};
return function(){
return fnInvoke;
@@ -422,48 +431,30 @@ Parser.prototype = {
},
logicalAND: function(){
- var left = this.negated();
+ var left = this.equality();
var token;
- while(true) {
- if ((token = this.expect('&&'))) {
- left = this._binary(left, token.fn, this.negated());
- } else {
- return left;
- }
- }
- },
-
- negated: function(){
- var token;
- if (token = this.expect('!')) {
- return this._unary(token.fn, this.assignment());
- } else {
- return this.equality();
+ if ((token = this.expect('&&'))) {
+ left = this._binary(left, token.fn, this.logicalAND());
}
+ return left;
},
equality: function(){
var left = this.relational();
var token;
- while(true) {
- if ((token = this.expect('==','!='))) {
- left = this._binary(left, token.fn, this.relational());
- } else {
- return left;
- }
+ if ((token = this.expect('==','!='))) {
+ left = this._binary(left, token.fn, this.equality());
}
+ return left;
},
relational: function(){
var left = this.additive();
var token;
- while(true) {
- if ((token = this.expect('<', '>', '<=', '>='))) {
- left = this._binary(left, token.fn, this.additive());
- } else {
- return left;
- }
+ if (token = this.expect('<', '>', '<=', '>=')) {
+ left = this._binary(left, token.fn, this.relational());
}
+ return left;
},
additive: function(){
@@ -489,7 +480,9 @@ Parser.prototype = {
if (this.expect('+')) {
return this.primary();
} else if (token = this.expect('-')) {
- return this._binary(Parser.ZERO, token.fn, this.multiplicative());
+ return this._binary(Parser.ZERO, token.fn, this.unary());
+ } else if (token = this.expect('!')) {
+ return this._unary(token.fn, this.unary());
} else {
return this.primary();
}