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

Commit 71fc3f4

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 #12099
1 parent 8caf180 commit 71fc3f4

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/ng/parse.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -982,10 +982,10 @@ ASTCompiler.prototype = {
982982
nameId.name = ast.property.name;
983983
}
984984
}
985-
recursionFn(intoId);
986985
}, function() {
987986
self.assign(intoId, 'undefined');
988987
});
988+
recursionFn(intoId);
989989
}, !!create);
990990
break;
991991
case AST.CallExpression:
@@ -1023,8 +1023,10 @@ ASTCompiler.prototype = {
10231023
}
10241024
expression = self.ensureSafeObject(expression);
10251025
self.assign(intoId, expression);
1026-
recursionFn(intoId);
1026+
}, function() {
1027+
self.assign(intoId, 'undefined');
10271028
});
1029+
recursionFn(intoId);
10281030
});
10291031
}
10301032
break;

test/ng/parseSpec.js

+6
Original file line numberDiff line numberDiff line change
@@ -1746,9 +1746,15 @@ 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);
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)