summaryrefslogtreecommitdiff
path: root/src/core/window.js
blob: 6fc531068f9a691433f4f304f5bca351acd74664 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
function makeWindow() {
  var win = {
    location: {},
    history: {},
    open: () => {},
    close: () => {},
    File: function() {},
    FormData: function() {},
  }

  if(typeof window === "undefined") {
    return win
  }

  try {
    win = window
    var props = ["File", "Blob", "FormData"]
    for (var prop of props) {
      if (prop in window) {
        win[prop] = window[prop]
      }
    }
  } catch( e ) {
    console.error(e)
  }

  return win
}

export default makeWindow()