(this: Element)
| 106 | } |
| 107 | |
| 108 | function getBoundingClientRect(this: Element): DOMRect { |
| 109 | const containerRect = containerRects.get(this); |
| 110 | if (containerRect) { |
| 111 | return new DOMRect( |
| 112 | containerRect.left, |
| 113 | containerRect.top, |
| 114 | containerRect.width, |
| 115 | containerRect.height |
| 116 | ); |
| 117 | } |
| 118 | |
| 119 | const documentElement = document.documentElement; |
| 120 | if (this === documentElement) { |
| 121 | return new DOMRect( |
| 122 | -mutableWindow.scrollX, |
| 123 | -mutableWindow.scrollY, |
| 124 | mutableWindow.innerWidth, |
| 125 | getLayoutHeight(document.body) |
| 126 | ); |
| 127 | } |
| 128 | |
| 129 | const height = getLayoutHeight(this); |
| 130 | const width = parsePixels(getStyle(this)?.width ?? ""); |
| 131 | |
| 132 | const container = getClosestContainer(this); |
| 133 | if (container !== null) { |
| 134 | const rect = containerRects.get(container)!; |
| 135 | return new DOMRect( |
| 136 | rect.left - container.scrollLeft, |
| 137 | rect.top + getLayoutTop(this, container) - container.scrollTop, |
| 138 | width ?? rect.width, |
| 139 | height |
| 140 | ); |
| 141 | } |
| 142 | |
| 143 | return new DOMRect( |
| 144 | -mutableWindow.scrollX, |
| 145 | getLayoutTop(this, documentElement) - mutableWindow.scrollY, |
| 146 | width ?? mutableWindow.innerWidth, |
| 147 | height |
| 148 | ); |
| 149 | } |
| 150 | |
| 151 | /** Installs the layout model (see above); it is restored after each test. */ |
| 152 | export function mockLayout() { |
nothing calls this directly
no test coverage detected