Check if window object exists (#100)

* Check if window object exists

* brackets for readability

* change check to isUndefined()

* isUndefined() -> !isUndefined()
This commit is contained in:
Stefanie Doll
2019-03-21 11:11:14 +01:00
committed by Jaco Greeff
parent 5a5200729f
commit 71a649c428
2 changed files with 5 additions and 2 deletions
+1
View File
@@ -10,6 +10,7 @@
"license": "Apache-2.0",
"dependencies": {
"@babel/runtime": "^7.3.4",
"@polkadot/util": "^0.39.1",
"@types/store": "^2.0.1",
"store": "^2.0.12"
}
+4 -2
View File
@@ -2,10 +2,12 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { isUndefined } from '@polkadot/util';
import { Options } from './types';
// matches https://polkadot.js.org & https://poc-3.polkadot.io
const isPolkadot = window.location.host.indexOf('polkadot') !== -1;
const isPolkadot = !isUndefined(window) && window.location.host.indexOf('polkadot') !== -1;
const WSS_POLKADOT = 'wss://poc3-rpc.polkadot.io/';
const WSS_SUBSTRATE = 'wss://substrate-rpc.parity.io/';
@@ -44,7 +46,7 @@ const UITHEME_DEFAULT = isPolkadot
? 'polkadot'
: 'substrate';
const UIMODE_DEFAULT = !isPolkadot && window.location.host.indexOf('ui-light') !== -1
const UIMODE_DEFAULT = !isPolkadot && !isUndefined(window) && window.location.host.indexOf('ui-light') !== -1
? 'light'
: 'full';