fix(viewer): destroy a pending viewer whose element left the stage

rebuild() empties the stage while a view is pending, and the deferred destroy then failed on the viewer's null parent: a page error, and the image kept its src. The destroy now finishes and the src is released.
This commit is contained in:
Vito Sansevero
2026-10-30 18:32:57 -07:00
parent df0a798eea
commit 95478a0aed
2 changed files with 25 additions and 1 deletions
+4 -1
View File
@@ -267,7 +267,10 @@ export function createMediaViewer({api,container,parentScope,inspectionControlle
let fitFrame = 0, fitWidth, fitHeight, viewSettled = false, released = false, fallback = 0;
const release = () => {
if (released) return;
released = true;clearTimeout(fallback);instance.destroy();node.removeAttribute('src');
released = true;clearTimeout(fallback);
// Moving on empties the stage, and destroy() removes the built viewer from its parent.
if (instance.viewer && !instance.viewer.parentNode) document.createElement('div').append(instance.viewer);
instance.destroy();node.removeAttribute('src');
};
const scheduleFit = () => {
if (!current() || fitFrame) return;