You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

16 lines
383 B

2 months ago
  1. // @flow
  2. import type { Window } from '../types';
  3. declare function getWindow(node: Node | Window): Window;
  4. export default function getWindow(node) {
  5. if (node == null) {
  6. return window;
  7. }
  8. if (node.toString() !== '[object Window]') {
  9. const ownerDocument = node.ownerDocument;
  10. return ownerDocument ? ownerDocument.defaultView || window : window;
  11. }
  12. return node;
  13. }