From cc43cb9746c3535a5ab89b0e82061e01bae8939c Mon Sep 17 00:00:00 2001 From: Lucas Galfaso Date: Sun, 31 May 2015 22:26:31 +0200 Subject: [PATCH] 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 #11959 --- src/ng/parse.js | 2 ++ test/ng/parseSpec.js | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/src/ng/parse.js b/src/ng/parse.js index 7084acb1d46a..9a3d82666584 100644 --- a/src/ng/parse.js +++ b/src/ng/parse.js @@ -983,6 +983,8 @@ ASTCompiler.prototype = { } } recursionFn(intoId); + }, function() { + self.assign(intoId, 'undefined'); }); }, !!create); break; diff --git a/test/ng/parseSpec.js b/test/ng/parseSpec.js index 2983c7ea6397..8814f3a7702e 100644 --- a/test/ng/parseSpec.js +++ b/test/ng/parseSpec.js @@ -1745,6 +1745,10 @@ describe('parser', function() { expect(scope.$eval("0&&2")).toEqual(0 && 2); expect(scope.$eval("0||2")).toEqual(0 || 2); expect(scope.$eval("0||1&&2")).toEqual(0 || 1 && 2); + expect(scope.$eval("true&&a")).toEqual(true && undefined); + expect(scope.$eval("true&&a.b")).toEqual(true && undefined); + expect(scope.$eval("false||a")).toEqual(false || undefined); + expect(scope.$eval("false||a.b")).toEqual(false || undefined); }); it('should parse ternary', function() {