MCPcopy Index your code
hub / github.com/shipshapecode/tether / _getActualBoundingClientRect

Function _getActualBoundingClientRect

src/js/utils/bounds.js:157–183  ·  view source on GitHub ↗

* Same as native getBoundingClientRect, except it takes into account parent offsets * if the element lies within a nested document ( or -like). * @param node

(node)

Source from the content-addressed store, hash-verified

155 * @param node
156 */
157function _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
185function _getOrigin(body) {
186 // getBoundingClientRect is unfortunately too accurate. It introduces a pixel or two of

Callers 2

getBoundsFunction · 0.85
_getOriginFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…