Skip to content

Commit

Permalink
Fix race condition during initialization (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaumejenkins authored May 20, 2021
1 parent f0159ae commit d331e6d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/text-fragments.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ import * as utils from './text-fragment-utils.js';
}
};
if (document.readyState !== 'complete') {
window.addEventListener('DOMContentLoaded', init);
document.addEventListener('readystatechange', event => {
if (event.target.readyState === 'complete') {
init();
}
});
} else {
init();
}
Expand Down

0 comments on commit d331e6d

Please sign in to comment.