diff --git a/src/js/libpannellum.js b/src/js/libpannellum.js index 782e9d6..f07f469 100644 --- a/src/js/libpannellum.js +++ b/src/js/libpannellum.js @@ -422,10 +422,10 @@ function Renderer(container) { */ this.destroy = function() { if (container !== undefined) { - if (canvas !== undefined) { + if (canvas !== undefined && container.contains(canvas)) { container.removeChild(canvas); } - if (world !== undefined) { + if (world !== undefined && container.contains(world)) { container.removeChild(world); } }