fix(change_detector): ensure that locals are only used when implicit receiver
closes #1542
This commit is contained in:
parent
5b104936ae
commit
d4925b61ff
|
@ -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`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue