webpack-dev-server 2.9.0 → 2.9.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/client/index.js CHANGED
@@ -218,7 +218,25 @@ function reloadApp() {
218
218
  self.postMessage('webpackHotUpdate' + currentHash, '*');
219
219
  }
220
220
  } else {
221
+ let rootWindow = self;
222
+ // use parent window for reload (in case we're in an iframe with no valid src)
223
+ const intervalId = self.setInterval(function findRootWindow() {
224
+ if (rootWindow.location.protocol !== 'about:') {
225
+ // reload immediately if protocol is valid
226
+ applyReload(rootWindow, intervalId);
227
+ } else {
228
+ rootWindow = rootWindow.parent;
229
+ if (rootWindow.parent === rootWindow) {
230
+ // if parent equals current window we've reached the root which would continue forever, so trigger a reload anyways
231
+ applyReload(rootWindow, intervalId);
232
+ }
233
+ }
234
+ });
235
+ }
236
+
237
+ function applyReload(rootWindow, intervalId) {
238
+ clearInterval(intervalId);
221
239
  log.info('[WDS] App updated. Reloading...');
222
- self.location.reload();
240
+ rootWindow.location.reload();
223
241
  }
224
242
  }