Skip to content

Commit ad5e086

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()` to `undefined`. Closes angular#12099
1 parent 91b6022 commit ad5e086

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

src/ng/parse.js

+2
Original file line numberDiff line numberDiff line change
@@ -1024,6 +1024,8 @@ ASTCompiler.prototype = {
10241024
expression = self.ensureSafeObject(expression);
10251025
self.assign(intoId, expression);
10261026
recursionFn(intoId);
1027+
}, function() {
1028+
self.assign(intoId, 'undefined');
10271029
});
10281030
});
10291031
}

test/ng/parseSpec.js

+2
Original file line numberDiff line numberDiff line change
@@ -1746,8 +1746,10 @@ describe('parser', function() {
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);
17491750
expect(scope.$eval("true&&a.b")).toEqual(true && undefined);
17501751
expect(scope.$eval("false||a")).toEqual(false || undefined);
1752+
expect(scope.$eval("false||a()")).toEqual(false || undefined);
17511753
expect(scope.$eval("false||a.b")).toEqual(false || undefined);
17521754
});
17531755

0 commit comments

Comments
 (0)