Loading homepage
Input: const cleanup = createFocusTrap(dialog); // dialog contains two buttons // Press Tab on the last button. Output: Focus moves to the first button and the Tab event is prevented.
Input: cleanup(); cleanup(); Output: The listener is removed and the prior connected element is focused only once.
Implement the exported API in index.js or index.ts. Tests cover the contract and edge cases below.