Skip to content

Commit 6638390

Browse files
gkalpakvicb
authored andcommitted
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
1 parent 1eb5413 commit 6638390

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

packages/upgrade/src/dynamic/upgrade_ng1_adapter.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,10 @@ class UpgradeNg1ComponentAdapter implements OnInit, OnChanges, DoCheck {
174174
}
175175
for (let j = 0; j < outputs.length; j++) {
176176
const emitter = (this as any)[outputs[j]] = new EventEmitter<any>();
177-
this.setComponentProperty(
178-
outputs[j], (emitter => (value: any) => emitter.emit(value))(emitter));
177+
if (this.propOuts.indexOf(outputs[j]) === -1) {
178+
this.setComponentProperty(
179+
outputs[j], (emitter => (value: any) => emitter.emit(value))(emitter));
180+
}
179181
}
180182
for (let k = 0; k < propOuts.length; k++) {
181183
this.checkLastValues.push(INITIAL_VALUE);

0 commit comments

Comments
 (0)