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
This commit is contained in:
parent
8e1e040f72
commit
f089bf5333
|
@ -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<any>();
|
||||
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);
|
||||
|
|
Loading…
Reference in New Issue