From f089bf5333d78f4bc354c4154e58d49fc45f363f Mon Sep 17 00:00:00 2001 From: George Kalpakas Date: Thu, 15 Feb 2018 19:26:28 +0200 Subject: [PATCH] fix(upgrade): correctly handle `=` bindings in `@angular/upgrade` (#22167) Previously, having a `=` binding on an upgraded components would result in setting the corresponding property to an EventEmitter function. This should only happen for `&` bindings. This commit rstrores the correct behavior. Note: The issue was only present in the dynamic version of `ngUpgrade`. The static version worked as expected. The error did not show up in tests, because in AngularJS v1.5.x a function would be serialized to an empty string in interpolations, thus making them indistinguishable from uninitialized properties (in the view). The serialization behavior changed in AngularJS v1.6.x, making the errors visible. PR Close #22167 --- packages/upgrade/src/dynamic/upgrade_ng1_adapter.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/upgrade/src/dynamic/upgrade_ng1_adapter.ts b/packages/upgrade/src/dynamic/upgrade_ng1_adapter.ts index 3aedd1c3d1..06d9ed44dc 100644 --- a/packages/upgrade/src/dynamic/upgrade_ng1_adapter.ts +++ b/packages/upgrade/src/dynamic/upgrade_ng1_adapter.ts @@ -174,8 +174,10 @@ class UpgradeNg1ComponentAdapter implements OnInit, OnChanges, DoCheck { } for (let j = 0; j < outputs.length; j++) { const emitter = (this as any)[outputs[j]] = new EventEmitter(); - this.setComponentProperty( - outputs[j], (emitter => (value: any) => emitter.emit(value))(emitter)); + if (this.propOuts.indexOf(outputs[j]) === -1) { + this.setComponentProperty( + outputs[j], (emitter => (value: any) => emitter.emit(value))(emitter)); + } } for (let k = 0; k < propOuts.length; k++) { this.checkLastValues.push(INITIAL_VALUE);