Skip to content

Commit

Permalink
fix: restored dom loaded waiting
Browse files Browse the repository at this point in the history
  • Loading branch information
kobezzza committed Jan 15, 2024
1 parent eb39f28 commit a569ebc
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/core/init/semaphore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* https://github.com/V4Fire/Client/blob/master/LICENSE
*/

import { createsAsyncSemaphore } from 'core/event';
import { createsAsyncSemaphore, resolveAfterDOMLoaded } from 'core/event';

import remoteState, { set } from 'core/component/state';

Expand Down Expand Up @@ -38,12 +38,17 @@ if (SSR) {
process.on('unhandledRejection', stderr);

} else {
const
targetToMount = document.querySelector<HTMLElement>('[data-root-component]'),
rootComponentName = targetToMount?.getAttribute('data-root-component'),
ready = createSemaphore();
resolveAfterDOMLoaded()
.then(() => {
const
targetToMount = document.querySelector<HTMLElement>('[data-root-component]'),
rootComponentName = targetToMount?.getAttribute('data-root-component'),
ready = createSemaphore();

return initApp(rootComponentName, {targetToMount, ready});
})

initApp(rootComponentName, {targetToMount, ready}).catch(stderr);
.catch(stderr);
}

function createAppInitializer() {
Expand Down

0 comments on commit a569ebc

Please sign in to comment.