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

Commit d19504a

Browse files
committed
fix($parse): set null reference properties to undefined
When there is an expression of the form `true && a.b` and where `a == null`, then set the value of `true && a.b` to `undefined`. Closes #11959
1 parent e5e871f commit d19504a

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)