From 31d2b994856f8e0e15ac7c0a07c675de8f635e9d Mon Sep 17 00:00:00 2001 From: Jarle Friestad Date: Tue, 11 Oct 2016 13:44:58 +0200 Subject: [PATCH] Dispose error overlay when linting errors have been corrected (#856) * Dispose error overlay when linting errors have been corrected * Fixed spelling error * Minor style tweaks --- packages/react-dev-utils/webpackHotDevClient.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/packages/react-dev-utils/webpackHotDevClient.js b/packages/react-dev-utils/webpackHotDevClient.js index eebf6c0a254..f15fd06f291 100644 --- a/packages/react-dev-utils/webpackHotDevClient.js +++ b/packages/react-dev-utils/webpackHotDevClient.js @@ -123,6 +123,19 @@ function showErrorOverlay(message) { }); } +function destroyErrorOverlay() { + if (!overlayDiv) { + // It is not there in the first place. + return; + } + + // Clean up and reset internal state. + document.body.removeChild(overlayIframe); + overlayDiv = null; + overlayIframe = null; + lastOnOverlayDivReady = null; +} + // Connect to WebpackDevServer via a socket. var connection = new SockJS(url.format({ protocol: window.location.protocol, @@ -156,6 +169,7 @@ function clearOutdatedErrors() { // Successful compilation. function handleSuccess() { clearOutdatedErrors(); + destroyErrorOverlay(); var isHotUpdate = !isFirstCompilation; isFirstCompilation = false; @@ -170,6 +184,7 @@ function handleSuccess() { // Compilation with warnings (e.g. ESLint). function handleWarnings(warnings) { clearOutdatedErrors(); + destroyErrorOverlay(); var isHotUpdate = !isFirstCompilation; isFirstCompilation = false;