Welcome to mirror list, hosted at ThFree Co, Russian Federation.

getWindow.js.flow « dom-utils « lib « package « popperjs - github.com/gohugoio/hugo-mod-jslibs-dist.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ff38250ad279f5000f85cc6f9e8f2c89471dff00 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// @flow
import type { Window } from '../types';
declare function getWindow(node: Node | Window): Window;

export default function getWindow(node) {
  if (node == null) {
    return window;
  }

  if (node.toString() !== '[object Window]') {
    const ownerDocument = node.ownerDocument;
    return ownerDocument ? ownerDocument.defaultView || window : window;
  }

  return node;
}