fix(ChangeDetection): chain expressions evaluate to the last expression (codegen)

fixes #4782
Closes #5892
This commit is contained in:
Victor Berchet 2015-12-14 20:02:40 -08:00
parent 8c37b7e8f2
commit 933a9112da
3 changed files with 6 additions and 1 deletions

View File

@ -103,7 +103,7 @@ export class CodegenLogicUtil {
break;
case RecordType.Chain:
rhs = 'null';
rhs = `${getLocalName(protoRec.args[protoRec.args.length - 1])}`;
break;
default:

View File

@ -438,6 +438,7 @@ var _availableEventDefinitions = [
'(event)="a[0]=\$event"',
// '(event)="\$event=1"',
'(event)="a=a+1; a=a+1;"',
'(event)="true; false"',
'(event)="false"',
'(event)="true"',
'(event)="true ? a = a + 1 : a = a + 1"',

View File

@ -1358,6 +1358,10 @@ export function main() {
val = _createChangeDetector('(event)="true"', d, null);
res = val.changeDetector.handleEvent("event", 0, event);
expect(res).toBe(true);
val = _createChangeDetector('(event)="true; false"', d, null);
res = val.changeDetector.handleEvent("event", 0, event);
expect(res).toBe(false);
});
it('should support short-circuiting', () => {