From 6b8daef5099ab7bab40f9bdd8aaa1a0795b56214 Mon Sep 17 00:00:00 2001 From: Thomas Allmer Date: Tue, 28 Jul 2020 13:58:13 +0200 Subject: [PATCH] fix: resolve registrationComplete via microtask to be sync --- packages/form-core/src/choice-group/ChoiceGroupMixin.js | 6 +----- packages/form-core/src/form-group/FormGroupMixin.js | 6 +----- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/packages/form-core/src/choice-group/ChoiceGroupMixin.js b/packages/form-core/src/choice-group/ChoiceGroupMixin.js index 09b900051..d05fa348a 100644 --- a/packages/form-core/src/choice-group/ChoiceGroupMixin.js +++ b/packages/form-core/src/choice-group/ChoiceGroupMixin.js @@ -94,10 +94,7 @@ export const ChoiceGroupMixin = dedupeMixin( connectedCallback() { super.connectedCallback(); - - this.__registrationCompleteTimer = setTimeout(() => { - this.__resolveRegistrationComplete(); - }); + Promise.resolve().then(() => this.__resolveRegistrationComplete()); this.registrationComplete.then(() => { this.__isInitialModelValue = false; @@ -110,7 +107,6 @@ export const ChoiceGroupMixin = dedupeMixin( super.disconnectedCallback(); } - clearTimeout(this.__registrationCompleteTimer); if (this.registrationComplete.done === false) { this.__rejectRegistrationComplete(); } diff --git a/packages/form-core/src/form-group/FormGroupMixin.js b/packages/form-core/src/form-group/FormGroupMixin.js index a50ec76ed..4339fc356 100644 --- a/packages/form-core/src/form-group/FormGroupMixin.js +++ b/packages/form-core/src/form-group/FormGroupMixin.js @@ -154,10 +154,7 @@ export const FormGroupMixin = dedupeMixin( connectedCallback() { super.connectedCallback(); this.setAttribute('role', 'group'); - - this.__registrationCompleteTimer = setTimeout(() => { - this.__resolveRegistrationComplete(); - }); + Promise.resolve().then(() => this.__resolveRegistrationComplete()); this.registrationComplete.then(() => { this.__isInitialModelValue = false; @@ -175,7 +172,6 @@ export const FormGroupMixin = dedupeMixin( document.removeEventListener('click', this._checkForOutsideClick); this.__hasActiveOutsideClickHandling = false; } - clearTimeout(this.__registrationCompleteTimer); if (this.registrationComplete.done === false) { this.__rejectRegistrationComplete(); }