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 =>
|
superclass =>
|
||||||
// eslint-disable-next-line no-shadow, no-unused-vars
|
// eslint-disable-next-line no-shadow, no-unused-vars
|
||||||
class FormRegisteringMixin extends superclass {
|
class FormRegisteringMixin extends superclass {
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
this.__boundDispatchRegistration = this._dispatchRegistration.bind(this);
|
||||||
|
}
|
||||||
|
|
||||||
connectedCallback() {
|
connectedCallback() {
|
||||||
if (super.connectedCallback) {
|
if (super.connectedCallback) {
|
||||||
super.connectedCallback();
|
super.connectedCallback();
|
||||||
|
|
@ -31,9 +36,10 @@ export const FormRegisteringMixin = dedupeMixin(
|
||||||
if (formRegistrarManager.ready) {
|
if (formRegistrarManager.ready) {
|
||||||
this._dispatchRegistration();
|
this._dispatchRegistration();
|
||||||
} else {
|
} else {
|
||||||
formRegistrarManager.addEventListener('all-forms-open-for-registration', () => {
|
formRegistrarManager.addEventListener(
|
||||||
this._dispatchRegistration();
|
'all-forms-open-for-registration',
|
||||||
});
|
this.__boundDispatchRegistration,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -44,6 +50,10 @@ export const FormRegisteringMixin = dedupeMixin(
|
||||||
bubbles: true,
|
bubbles: true,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
formRegistrarManager.removeEventListener(
|
||||||
|
'all-forms-open-for-registration',
|
||||||
|
this.__boundDispatchRegistration,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
_unregisterFormElement() {
|
_unregisterFormElement() {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue