fix(field): teardown registrarmanager listener on field after register
Co-authored-by: Anton Kot <anton.kot@ing.nl>
This commit is contained in:
parent
8237b64a3b
commit
88e75a271f
1 changed files with 13 additions and 3 deletions
|
|
@ -13,6 +13,11 @@ export const FormRegisteringMixin = dedupeMixin(
|
|||
superclass =>
|
||||
// eslint-disable-next-line no-shadow, no-unused-vars
|
||||
class FormRegisteringMixin extends superclass {
|
||||
constructor() {
|
||||
super();
|
||||
this.__boundDispatchRegistration = this._dispatchRegistration.bind(this);
|
||||
}
|
||||
|
||||
connectedCallback() {
|
||||
if (super.connectedCallback) {
|
||||
super.connectedCallback();
|
||||
|
|
@ -31,9 +36,10 @@ export const FormRegisteringMixin = dedupeMixin(
|
|||
if (formRegistrarManager.ready) {
|
||||
this._dispatchRegistration();
|
||||
} else {
|
||||
formRegistrarManager.addEventListener('all-forms-open-for-registration', () => {
|
||||
this._dispatchRegistration();
|
||||
});
|
||||
formRegistrarManager.addEventListener(
|
||||
'all-forms-open-for-registration',
|
||||
this.__boundDispatchRegistration,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -44,6 +50,10 @@ export const FormRegisteringMixin = dedupeMixin(
|
|||
bubbles: true,
|
||||
}),
|
||||
);
|
||||
formRegistrarManager.removeEventListener(
|
||||
'all-forms-open-for-registration',
|
||||
this.__boundDispatchRegistration,
|
||||
);
|
||||
}
|
||||
|
||||
_unregisterFormElement() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue