fix(Citations): Handle race condition with formatReferences
formatReferences wasn't getting called consistently, causing the citation styles to not work.
@@ -51,13 +51,13 @@ export const formatReferences = (): void => {
const onReadyHandler = (): void => {
codeHighlight()
- formatReferences()
+ window.setTimeout(formatReferences, 0)
}
export const load = (): void => {
- if (document.readyState !== 'loading') {
+ if (document.readyState === 'loading') {
+ document.addEventListener('DOMContentLoaded', onReadyHandler)
+ } else {
onReadyHandler()
}
-
- document.addEventListener('DOMContentLoaded', onReadyHandler)
}
