Skip to content

Commit 933a911

Browse files
committed
fix(ChangeDetection): chain expressions evaluate to the last expression (codegen)
fixes angular#4782 Closes angular#5892
1 parent 8c37b7e commit 933a911

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

modules/angular2/src/core/change_detection/codegen_logic_util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export class CodegenLogicUtil {
103103
break;
104104

105105
case RecordType.Chain:
106-
rhs = 'null';
106+
rhs = `${getLocalName(protoRec.args[protoRec.args.length - 1])}`;
107107
break;
108108

109109
default:

modules/angular2/test/core/change_detection/change_detector_config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,7 @@ var _availableEventDefinitions = [
438438
'(event)="a[0]=\$event"',
439439
// '(event)="\$event=1"',
440440
'(event)="a=a+1; a=a+1;"',
441+
'(event)="true; false"',
441442
'(event)="false"',
442443
'(event)="true"',
443444
'(event)="true ? a = a + 1 : a = a + 1"',

modules/angular2/test/core/change_detection/change_detector_spec.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1358,6 +1358,10 @@ export function main() {
13581358
val = _createChangeDetector('(event)="true"', d, null);
13591359
res = val.changeDetector.handleEvent("event", 0, event);
13601360
expect(res).toBe(true);
1361+
1362+
val = _createChangeDetector('(event)="true; false"', d, null);
1363+
res = val.changeDetector.handleEvent("event", 0, event);
1364+
expect(res).toBe(false);
13611365
});
13621366

13631367
it('should support short-circuiting', () => {

0 commit comments

Comments
 (0)