Skip to content

Commit

Permalink
Fix ready state race condition for virtualdom
Browse files Browse the repository at this point in the history
  • Loading branch information
WietseWind committed Dec 20, 2022
1 parent 8ddce8b commit ecf8ab7
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,14 +320,18 @@ export class XummPkceThread extends EventEmitter {
this.mobileRedirectFlow = true;
this.urlParams = params;

document.addEventListener("readystatechange", async (event) => {
const onDocumentReady = async (event?: Event) => {
if (document.readyState === "complete") {
console.log("(readystatechange: [ " + document.readyState + " ])");
this.handleMobileGrant();
await this.authorize();
this.emit("retrieved");
}
});
};

if (!onDocumentReady()) {
document.addEventListener("readystatechange", onDocumentReady);
}
}
}

Expand Down

0 comments on commit ecf8ab7

Please sign in to comment.