Skip to content

Commit 2eb570e

Browse files
committed
fix($parse): set null reference properties to undefined
When there is an expression of the form * true && a.b.c * true && a() * true && a()() * false || a.b.c * false || a() * false || a()() where `a == null` Closes angular#12099
1 parent 91b6022 commit 2eb570e

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/ng/parse.js

+4
Original file line numberDiff line numberDiff line change
@@ -985,6 +985,7 @@ ASTCompiler.prototype = {
985985
recursionFn(intoId);
986986
}, function() {
987987
self.assign(intoId, 'undefined');
988+
recursionFn(intoId);
988989
});
989990
}, !!create);
990991
break;
@@ -1024,6 +1025,9 @@ ASTCompiler.prototype = {
10241025
expression = self.ensureSafeObject(expression);
10251026
self.assign(intoId, expression);
10261027
recursionFn(intoId);
1028+
}, function() {
1029+
self.assign(intoId, 'undefined');
1030+
recursionFn(intoId);
10271031
});
10281032
});
10291033
}

test/ng/parseSpec.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -1741,14 +1741,20 @@ describe('parser', function() {
17411741
expect(scope.$eval("3 >= 3 > 2")).toEqual(3 >= 3 > 2);
17421742
});
17431743

1744-
it('should parse logical', function() {
1744+
iit('should parse logical', 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);
17481748
expect(scope.$eval("true&&a")).toEqual(true && undefined);
1749+
expect(scope.$eval("true&&a()")).toEqual(true && undefined);
1750+
expect(scope.$eval("true&&a()()")).toEqual(true && undefined);
17491751
expect(scope.$eval("true&&a.b")).toEqual(true && undefined);
1752+
expect(scope.$eval("true&&a.b.c")).toEqual(true && undefined);
17501753
expect(scope.$eval("false||a")).toEqual(false || undefined);
1754+
expect(scope.$eval("false||a()")).toEqual(false || undefined);
1755+
expect(scope.$eval("false||a()()")).toEqual(false || undefined);
17511756
expect(scope.$eval("false||a.b")).toEqual(false || undefined);
1757+
expect(scope.$eval("false||a.b.c")).toEqual(false || undefined);
17521758
});
17531759

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

0 commit comments

Comments
 (0)