Merge pull request #295 from JaySunSyn/fix/cached-form

fix(form-registrar-mixin): invoke becomesReady on connectedCallback
This commit is contained in:
gerjanvangeest 2019-10-14 08:16:54 +02:00 committed by GitHub
commit 8b1fabbf19
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

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