* Returns the global window object associated with provided element.
(target)
| 2 | * Returns the global window object associated with provided element. |
| 3 | */ |
| 4 | function 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 | |
| 15 | export default getWindowOf |
no outgoing calls
no test coverage detected
searching dependent graphs…