fix(form-registrar-mixin): ensure becomesReady called only once

This commit is contained in:
JaySunSyn 2019-10-10 17:22:56 +02:00
parent 75b3e2c92f
commit 991af25d87

View file

@ -25,6 +25,7 @@ export const FormRegistrarMixin = dedupeMixin(
super(); super();
this.formElements = []; this.formElements = [];
this.__readyForRegistration = false; this.__readyForRegistration = false;
this.__hasBeenRenedered = false;
this.registrationReady = new Promise(resolve => { this.registrationReady = new Promise(resolve => {
this.__resolveRegistrationReady = resolve; this.__resolveRegistrationReady = resolve;
}); });
@ -38,8 +39,10 @@ export const FormRegistrarMixin = dedupeMixin(
super.connectedCallback(); super.connectedCallback();
} }
formRegistrarManager.add(this); formRegistrarManager.add(this);
if (this.__hasBeenRenedered) {
formRegistrarManager.becomesReady(this); formRegistrarManager.becomesReady(this);
} }
}
disconnectedCallback() { disconnectedCallback() {
if (super.disconnectedCallback) { if (super.disconnectedCallback) {
@ -57,6 +60,7 @@ export const FormRegistrarMixin = dedupeMixin(
this.__resolveRegistrationReady(); this.__resolveRegistrationReady();
this.__readyForRegistration = true; this.__readyForRegistration = true;
formRegistrarManager.becomesReady(this); formRegistrarManager.becomesReady(this);
this.__hasBeenRenedered = true;
} }
addFormElement(child) { addFormElement(child) {