MCPcopy
hub / github.com/souporserious/react-measure / getWindowOf

Function getWindowOf

src/get-window-of.js:4–13  ·  view source on GitHub ↗

* Returns the global window object associated with provided element.

(target)

Source from the content-addressed store, hash-verified

2 * Returns the global window object associated with provided element.
3 */
4function getWindowOf(target) {
5 // Assume that the element is an instance of Node, which means that it
6 // has the "ownerDocument" property from which we can retrieve a
7 // corresponding global object.
8 const ownerGlobal = target && target.ownerDocument && target.ownerDocument.defaultView
9
10 // Return the local window object if it's not possible extract one from
11 // provided element.
12 return ownerGlobal || window
13};
14
15export default getWindowOf

Callers 1

WithContentRectClass · 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…