Skip to content

Commit b7639ad

Browse files
authored
fix: removeChild may throw when render to document.body (#52)
1 parent 29b2b9d commit b7639ad

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

client/overlay/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,12 @@ function render() {
240240
*/
241241
function cleanup() {
242242
// Clean up and reset all internal state.
243-
document.body.removeChild(iframeRoot);
243+
try {
244+
document.body.removeChild(iframeRoot);
245+
} catch (e) {
246+
// In case user render react app directly to body, will trigger `NotFoundError` when recovery from an Error
247+
// https://developer.mozilla.org/en-US/docs/Web/API/Node/removeChild#exceptions
248+
}
244249
scheduledRenderFn = null;
245250
root = null;
246251
iframeRoot = null;

0 commit comments

Comments
 (0)