| 13 | |
| 14 | const overlaps = (a: ScreenRect, b: ScreenRect) => !(a.right <= b.left || b.right <= a.left || a.bottom <= b.top || b.bottom <= a.top); |
| 15 | function element(host: HTMLElement, html: string, rect: ScreenRect): HTMLElement { |
| 16 | host.insertAdjacentHTML('beforeend', html); |
| 17 | const added = host.lastElementChild as HTMLElement; |
| 18 | const target = added.querySelector('b') ?? added; |
| 19 | target.getBoundingClientRect = () => ({ ...rect, x: rect.left, y: rect.top, width: rect.right - rect.left, height: rect.bottom - rect.top, toJSON: () => ({}) }); |
| 20 | return target; |
| 21 | } |
| 22 | |
| 23 | afterEach(() => { document.body.innerHTML = ''; }); |
| 24 | |