fix: resolve registrationComplete via microtask to be sync

This commit is contained in:
Thomas Allmer 2020-07-28 13:58:13 +02:00
parent 4715b6b37d
commit 6b8daef509
2 changed files with 2 additions and 10 deletions

View file

@ -94,10 +94,7 @@ export const ChoiceGroupMixin = dedupeMixin(
connectedCallback() { connectedCallback() {
super.connectedCallback(); super.connectedCallback();
Promise.resolve().then(() => this.__resolveRegistrationComplete());
this.__registrationCompleteTimer = setTimeout(() => {
this.__resolveRegistrationComplete();
});
this.registrationComplete.then(() => { this.registrationComplete.then(() => {
this.__isInitialModelValue = false; this.__isInitialModelValue = false;
@ -110,7 +107,6 @@ export const ChoiceGroupMixin = dedupeMixin(
super.disconnectedCallback(); super.disconnectedCallback();
} }
clearTimeout(this.__registrationCompleteTimer);
if (this.registrationComplete.done === false) { if (this.registrationComplete.done === false) {
this.__rejectRegistrationComplete(); this.__rejectRegistrationComplete();
} }

View file

@ -154,10 +154,7 @@ export const FormGroupMixin = dedupeMixin(
connectedCallback() { connectedCallback() {
super.connectedCallback(); super.connectedCallback();
this.setAttribute('role', 'group'); this.setAttribute('role', 'group');
Promise.resolve().then(() => this.__resolveRegistrationComplete());
this.__registrationCompleteTimer = setTimeout(() => {
this.__resolveRegistrationComplete();
});
this.registrationComplete.then(() => { this.registrationComplete.then(() => {
this.__isInitialModelValue = false; this.__isInitialModelValue = false;
@ -175,7 +172,6 @@ export const FormGroupMixin = dedupeMixin(
document.removeEventListener('click', this._checkForOutsideClick); document.removeEventListener('click', this._checkForOutsideClick);
this.__hasActiveOutsideClickHandling = false; this.__hasActiveOutsideClickHandling = false;
} }
clearTimeout(this.__registrationCompleteTimer);
if (this.registrationComplete.done === false) { if (this.registrationComplete.done === false) {
this.__rejectRegistrationComplete(); this.__rejectRegistrationComplete();
} }