Skip to content

Commit 596ffad

Browse files
committed
Fix DOMContentLoaded race condition by checking document.readyState
1 parent 0c9ab20 commit 596ffad

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

web_studio/static/app.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
document.addEventListener('DOMContentLoaded', () => {
1+
function initStudioApp() {
22
// Navigation Tabs
33
const navButtons = document.querySelectorAll('.nav-btn');
44
const tabContents = document.querySelectorAll('.tab-content');
@@ -11,8 +11,8 @@ document.addEventListener('DOMContentLoaded', () => {
1111
btn.classList.add('active');
1212
const targetEl = document.getElementById(targetTab);
1313
if (targetEl) targetEl.classList.add('active');
14-
if (targetTab === 'tab-gallery' && typeof loadGallery === 'function') {
15-
loadGallery();
14+
if (targetTab === 'tab-gallery' && typeof window.loadGallery === 'function') {
15+
window.loadGallery();
1616
}
1717
});
1818
});
@@ -1187,4 +1187,10 @@ document.addEventListener('DOMContentLoaded', () => {
11871187
// Start live inline log polling immediately and every 2 seconds
11881188
pollInlineLogs();
11891189
setInterval(pollInlineLogs, 2000);
1190-
});
1190+
}
1191+
1192+
if (document.readyState === 'loading') {
1193+
document.addEventListener('DOMContentLoaded', initStudioApp);
1194+
} else {
1195+
initStudioApp();
1196+
}

0 commit comments

Comments
 (0)