diff --git a/modules/angular2/src/change_detection/proto_change_detector.js b/modules/angular2/src/change_detection/proto_change_detector.js index 0028f5d278..4ea70c616f 100644 --- a/modules/angular2/src/change_detection/proto_change_detector.js +++ b/modules/angular2/src/change_detection/proto_change_detector.js @@ -169,7 +169,9 @@ class _ConvertAstIntoProtoRecords { visitAccessMember(ast:AccessMember) { var receiver = ast.receiver.visit(this); - if (isPresent(this.variableBindings) && ListWrapper.contains(this.variableBindings, ast.name)) { + if (isPresent(this.variableBindings) && + ListWrapper.contains(this.variableBindings, ast.name) && + ast.receiver instanceof ImplicitReceiver) { return this._addRecord(RECORD_TYPE_LOCAL, ast.name, ast.name, [], null, receiver); } else { return this._addRecord(RECORD_TYPE_PROPERTY, ast.name, ast.getter, [], null, receiver); @@ -351,4 +353,4 @@ function _interpolationFn(strings:List) { case 9: return (a1, a2, a3, a4, a5, a6, a7, a8, a9) => c0 + s(a1) + c1 + s(a2) + c2 + s(a3) + c3 + s(a4) + c4 + s(a5) + c5 + s(a6) + c6 + s(a7) + c7 + s(a8) + c8 + s(a9) + c9; default: throw new BaseException(`Does not support more than 9 expressions`); } -} \ No newline at end of file +} diff --git a/modules/angular2/test/change_detection/change_detection_spec.js b/modules/angular2/test/change_detection/change_detection_spec.js index 29f393d4f2..0bebe2c547 100644 --- a/modules/angular2/test/change_detection/change_detection_spec.js +++ b/modules/angular2/test/change_detection/change_detection_spec.js @@ -469,6 +469,18 @@ export function main() { expect(executeWatch('name', 'name', new Person("Jim"), locals)) .toEqual(['name=Jim']); }); + + it('should correctly handle nested properties', () => { + var address = new Address('Grenoble'); + var person = new Person('Victor', address); + var locals = new Locals(null, + MapWrapper.createFromPairs([['city', 'MTV']])); + expect(executeWatch('address.city', 'address.city', person, locals)) + .toEqual(['address.city=Grenoble']); + expect(executeWatch('city', 'city', person, locals)) + .toEqual(['city=MTV']); + }); + }); describe("handle children", () => { @@ -953,4 +965,4 @@ class TestDispatcher extends ChangeDispatcher { _asString(value) { return (isBlank(value) ? 'null' : value.toString()); } -} \ No newline at end of file +}