Clean partial editor mounts and failed refreshes
Quality / quality (ubuntu-latest) (push) Failing after 10m2s
Quality / quality (windows-latest) (push) Canceled after 0s

This commit is contained in:
Clintchiz committed 2026-09-05 18:07:35 +05:30
1 parent 3da88510df
commit d41eda7050
3 files changed
+39 -10

No files matched your search

+16 -9
View File
@@ -31,8 +31,20 @@ export function mountBlockEditor(root: HTMLElement, options: MountEditorOptions)
live.style.cssText =
"position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0";
root.append(live);
const destroy = () => {
if (destroyed) return;
destroyed = true;
generation++;
try {
cleanups.forEach((cleanup) => cleanup());
} finally {
cleanups = [];
try { manager?.destroy(); } finally { live.remove(); }
}
};
const refresh = () => {
if (destroyed) return;
try {
const currentGeneration = ++generation;
cleanups.forEach((cleanup) => cleanup());
cleanups = [];
@@ -145,18 +157,13 @@ export function mountBlockEditor(root: HTMLElement, options: MountEditorOptions)
}),
);
}
} catch (error) {
try { destroy(); } finally { throw error; }
}
};
refresh();
return {
refresh,
destroy() {
if (destroyed) return;
destroyed = true;
generation++;
cleanups.forEach((cleanup) => cleanup());
cleanups = [];
manager?.destroy();
live.remove();
},
destroy,
};
}