From 2e6bbaea90ea10d3e949d997c39486237f3bc327 Mon Sep 17 00:00:00 2001 From: Lucas Galfaso Date: Sun, 30 Aug 2015 19:21:15 +0200 Subject: [PATCH] fix($parse): `assign` returns the new value The `.assign` function returns the new value. The version with csp enabled already has this behavior. Closes #12675 --- src/ng/parse.js | 1 + test/ng/parseSpec.js | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/src/ng/parse.js b/src/ng/parse.js index b3e5c5642962..af07fce51630 100644 --- a/src/ng/parse.js +++ b/src/ng/parse.js @@ -774,6 +774,7 @@ ASTCompiler.prototype = { this.state.computing = 'assign'; var result = this.nextId(); this.recurse(assignable, result); + this.return_(result); extra = 'fn.assign=' + this.generateFunction('assign', 's,v,l'); } var toWatch = getInputs(ast.body); diff --git a/test/ng/parseSpec.js b/test/ng/parseSpec.js index ae500a676189..5fef35eec346 100644 --- a/test/ng/parseSpec.js +++ b/test/ng/parseSpec.js @@ -2797,6 +2797,14 @@ describe('parser', function() { expect(scope).toEqual({a:123}); })); + it('should return the assigned value', inject(function($parse) { + var fn = $parse('a'); + var scope = {}; + expect(fn.assign(scope, 123)).toBe(123); + var someObject = {}; + expect(fn.assign(scope, someObject)).toBe(someObject); + })); + it('should expose working assignment function for expressions ending with brackets', inject(function($parse) { var fn = $parse('a.b["c"]'); expect(fn.assign).toBeTruthy();