diff --git a/js/app.js b/js/app.js index c39c6bf9..80bf9828 100644 --- a/js/app.js +++ b/js/app.js @@ -1313,9 +1313,25 @@ class Application { const existingVideoElement = getVideoElement(); if (existingRoot && existingRoot.isConnected) { - if (ensureVideoElement && !existingVideoElement) { - throw new Error("Video modal video element is not ready."); + if (!existingVideoElement && ensureVideoElement) { + if (typeof this.videoModal.load === "function") { + await this.videoModal.load(); + } + + const rehydratedRoot = getRoot(); + const rehydratedVideoElement = getVideoElement(); + + if (!rehydratedVideoElement) { + throw new Error("Video modal video element is not ready."); + } + + this.modalVideo = rehydratedVideoElement; + return { + root: rehydratedRoot || existingRoot, + videoElement: rehydratedVideoElement, + }; } + if (existingVideoElement) { this.modalVideo = existingVideoElement; }