diff options
| author | Lucas Galfasó | 2013-04-25 12:54:28 -0300 | 
|---|---|---|
| committer | Pete Bacon Darwin | 2013-04-29 19:16:21 +0100 | 
| commit | 7812ae75d578314c1a285e9644fc75812940eb1d (patch) | |
| tree | b9d24fe96d4e606f386133738b3bb626bb805461 /src/ng/parse.js | |
| parent | da8c320bdedff51db87c632e16c7d0b56fd6cd8b (diff) | |
| download | angular.js-7812ae75d578314c1a285e9644fc75812940eb1d.tar.bz2 | |
fix(parse): Fix context access and double function call
Fix a context duplication and invocation to a previous context when
doing an access modifier function on the result of a function
Currently, when doing `foo().bar()`, `foo` is called twice, the first
time to get the context and the second one for `bar` to get the
underlying object. Then the call to `bar` is called using the second
instance as self
This is equivalent to doing:
```
var instance1 = foo();
var instance2 = foo();
instance2.bar.apply(instance1);
```
Closes #2496
Diffstat (limited to 'src/ng/parse.js')
| -rw-r--r-- | src/ng/parse.js | 20 | 
1 files changed, 10 insertions, 10 deletions
| diff --git a/src/ng/parse.js b/src/ng/parse.js index f931f613..b5127d9f 100644 --- a/src/ng/parse.js +++ b/src/ng/parse.js @@ -438,8 +438,8 @@ function parser(text, json, $filter, csp){            text.substring(0, token.index) + "] can not be assigned to", token);        }        right = logicalOR(); -      return function(self, locals){ -        return left.assign(self, right(self, locals), locals); +      return function(scope, locals){ +        return left.assign(scope, right(scope, locals), locals);        };      } else {        return left; @@ -559,12 +559,12 @@ function parser(text, json, $filter, csp){      var field = expect().text;      var getter = getterFn(field, csp);      return extend( -        function(self, locals) { -          return getter(object(self, locals), locals); +        function(scope, locals, self) { +          return getter(self || object(scope, locals), locals);          },          { -          assign:function(self, value, locals) { -            return setter(object(self, locals), field, value); +          assign:function(scope, value, locals) { +            return setter(object(scope, locals), field, value);            }          }      ); @@ -605,14 +605,14 @@ function parser(text, json, $filter, csp){        } while (expect(','));      }      consume(')'); -    return function(self, locals){ +    return function(scope, locals){        var args = [], -          context = contextGetter ? contextGetter(self, locals) : self; +          context = contextGetter ? contextGetter(scope, locals) : scope;        for ( var i = 0; i < argsFn.length; i++) { -        args.push(argsFn[i](self, locals)); +        args.push(argsFn[i](scope, locals));        } -      var fnPtr = fn(self, locals) || noop; +      var fnPtr = fn(scope, locals, context) || noop;        // IE stupidity!        return fnPtr.apply            ? fnPtr.apply(context, args) | 
