Skip to content

Commit cc43cb9

Browse files
committed
fix($parse): default expressions of the form a.b to undefined
When there is an expression of the form `a.b` and there is a recursion that specifies where the value should be placed, then when `a == null` then set the value of the returned identifier to `undefined` Closes angular#11959
1 parent 291d7c4 commit cc43cb9

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/ng/parse.js

+2
Original file line numberDiff line numberDiff line change
@@ -983,6 +983,8 @@ ASTCompiler.prototype = {
983983
}
984984
}
985985
recursionFn(intoId);
986+
}, function() {
987+
self.assign(intoId, 'undefined');
986988
});
987989
}, !!create);
988990
break;

test/ng/parseSpec.js

+4
Original file line numberDiff line numberDiff line change
@@ -1745,6 +1745,10 @@ describe('parser', function() {
17451745
expect(scope.$eval("0&&2")).toEqual(0 && 2);
17461746
expect(scope.$eval("0||2")).toEqual(0 || 2);
17471747
expect(scope.$eval("0||1&&2")).toEqual(0 || 1 && 2);
1748+
expect(scope.$eval("true&&a")).toEqual(true && undefined);
1749+
expect(scope.$eval("true&&a.b")).toEqual(true && undefined);
1750+
expect(scope.$eval("false||a")).toEqual(false || undefined);
1751+
expect(scope.$eval("false||a.b")).toEqual(false || undefined);
17481752
});
17491753

17501754
it('should parse ternary', function() {

0 commit comments

Comments
 (0)