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

Commit 7d2c6ee

Browse files
committed
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 Closes #12708
1 parent 6d8c195 commit 7d2c6ee

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/ng/parse.js

+1
Original file line numberDiff line numberDiff line change
@@ -774,6 +774,7 @@ ASTCompiler.prototype = {
774774
this.state.computing = 'assign';
775775
var result = this.nextId();
776776
this.recurse(assignable, result);
777+
this.return_(result);
777778
extra = 'fn.assign=' + this.generateFunction('assign', 's,v,l');
778779
}
779780
var toWatch = getInputs(ast.body);

test/ng/parseSpec.js

+8
Original file line numberDiff line numberDiff line change
@@ -2797,6 +2797,14 @@ describe('parser', function() {
27972797
expect(scope).toEqual({a:123});
27982798
}));
27992799

2800+
it('should return the assigned value', inject(function($parse) {
2801+
var fn = $parse('a');
2802+
var scope = {};
2803+
expect(fn.assign(scope, 123)).toBe(123);
2804+
var someObject = {};
2805+
expect(fn.assign(scope, someObject)).toBe(someObject);
2806+
}));
2807+
28002808
it('should expose working assignment function for expressions ending with brackets', inject(function($parse) {
28012809
var fn = $parse('a.b["c"]');
28022810
expect(fn.assign).toBeTruthy();

0 commit comments

Comments
 (0)