@@ -95,24 +95,24 @@ if(urlParts.hostname === "0.0.0.0") {
95
95
// why do we need this check?
96
96
// hostname n/a for file protocol (example, when using electron, ionic)
97
97
// see: https://github.com/webpack/webpack-dev-server/pull/384
98
- if ( window . location . hostname && ! ! ~ window . location . protocol . indexOf ( "http" ) ) {
99
- hostname = window . location . hostname ;
98
+ if ( self . location . hostname && ! ! ~ self . location . protocol . indexOf ( "http" ) ) {
99
+ hostname = self . location . hostname ;
100
100
}
101
101
}
102
102
103
103
// `hostname` can be empty when the script path is relative. In that case, specifying
104
104
// a protocol would result in an invalid URL.
105
105
// When https is used in the app, secure websockets are always necessary
106
106
// because the browser doesn't accept non-secure websockets.
107
- if ( hostname && ( window . location . protocol === "https:" || urlParts . hostname === "0.0.0.0" ) ) {
108
- protocol = window . location . protocol ;
107
+ if ( hostname && ( self . location . protocol === "https:" || urlParts . hostname === "0.0.0.0" ) ) {
108
+ protocol = self . location . protocol ;
109
109
}
110
110
111
111
var socketUrl = url . format ( {
112
112
protocol : protocol ,
113
113
auth : urlParts . auth ,
114
114
hostname : hostname ,
115
- port : ( urlParts . port === "0" ) ? window . location . port : urlParts . port ,
115
+ port : ( urlParts . port === "0" ) ? self . location . port : urlParts . port ,
116
116
pathname : urlParts . path == null || urlParts . path === "/" ? "/sockjs-node" : urlParts . path
117
117
} ) ;
118
118
@@ -123,12 +123,12 @@ function reloadApp() {
123
123
log ( "info" , "[WDS] App hot update..." ) ;
124
124
var hotEmitter = require ( "webpack/hot/emitter" ) ;
125
125
hotEmitter . emit ( "webpackHotUpdate" , currentHash ) ;
126
- if ( typeof window !== "undefined" ) {
126
+ if ( typeof self !== "undefined" ) {
127
127
// broadcast update to window
128
- window . postMessage ( "webpackHotUpdate" + currentHash , "*" ) ;
128
+ self . postMessage ( "webpackHotUpdate" + currentHash , "*" ) ;
129
129
}
130
130
} else {
131
131
log ( "info" , "[WDS] App updated. Reloading..." ) ;
132
- window . location . reload ( ) ;
132
+ self . location . reload ( ) ;
133
133
}
134
134
}
0 commit comments