test(images): set the bar's observer stub outside the fake document (#531)

This commit is contained in:
Vito Sansevero
2026-10-30 13:50:42 -07:00
parent 99e392436e
commit 239423e0c8
+4 -5
View File
@@ -69,16 +69,15 @@ function fakeDOM() {
createElement: tag => new Element(tag),
createTextNode: text => Object.assign(new Element('#text'), { _text: String(text) }),
getElementById: id => (id === 'workspace-toast' ? toast : null),
documentElement: { style: { setProperty() {}, removeProperty() {} } },
};
// The bar publishes its height for the sticky chrome (D186); nothing in this DOM ever resizes.
const previousObserver = globalThis.ResizeObserver;
globalThis.ResizeObserver = class { observe() {} disconnect() {} };
return { Element, body, toast, restore() { globalThis.document = previous; globalThis.ResizeObserver = previousObserver; } };
return { Element, body, toast, restore() { globalThis.document = previous; } };
}
/** The bar over `items` with `checked` keys; `options` adds the collection props. */
function mountBar(dom, items, checkedKeys, options = {}) {
// The bar publishes its height for the sticky chrome (D186); nothing in this DOM ever resizes.
globalThis.ResizeObserver ??= class { observe() {} disconnect() {} };
document.documentElement ??= { style: { setProperty() {}, removeProperty() {} } };
const scope = createScope();
const grid = new dom.Element('div');
const focusFallback = new dom.Element('h1');