* Same as native getBoundingClientRect, except it takes into account parent offsets * if the element lies within a nested document ( or -like). * @param node
(node)
| 155 | * @param node |
| 156 | */ |
| 157 | function _getActualBoundingClientRect(node) { |
| 158 | let boundingRect = node.getBoundingClientRect(); |
| 159 | |
| 160 | // The original object returned by getBoundingClientRect is immutable, so we clone it |
| 161 | // We can't use extend because the properties are not considered part of the object by hasOwnProperty in IE9 |
| 162 | let rect = {}; |
| 163 | for (let k in boundingRect) { |
| 164 | rect[k] = boundingRect[k]; |
| 165 | } |
| 166 | |
| 167 | try { |
| 168 | if (node.ownerDocument !== document) { |
| 169 | let { frameElement } = node.ownerDocument.defaultView; |
| 170 | if (frameElement) { |
| 171 | let frameRect = _getActualBoundingClientRect(frameElement); |
| 172 | rect.top += frameRect.top; |
| 173 | rect.bottom += frameRect.top; |
| 174 | rect.left += frameRect.left; |
| 175 | rect.right += frameRect.left; |
| 176 | } |
| 177 | } |
| 178 | } catch (err) { |
| 179 | // Ignore "Access is denied" in IE11/Edge |
| 180 | } |
| 181 | |
| 182 | return rect; |
| 183 | } |
| 184 | |
| 185 | function _getOrigin(body) { |
| 186 | // getBoundingClientRect is unfortunately too accurate. It introduces a pixel or two of |
no outgoing calls
no test coverage detected
searching dependent graphs…