Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Commit

Permalink
fix($parse): assign returns the new value
Browse files Browse the repository at this point in the history
The `.assign` function returns the new value.
The version with csp enabled already has this behavior.

Closes #12675
Closes #12708
  • Loading branch information
lgalfaso committed Aug 31, 2015
1 parent 6d8c195 commit 7d2c6ee
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/ng/parse.js
Expand Up @@ -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);
Expand Down
8 changes: 8 additions & 0 deletions test/ng/parseSpec.js
Expand Up @@ -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();
Expand Down

0 comments on commit 7d2c6ee

Please sign in to comment.