From 9c5657b86c867287b7958baf714e8190b1c647b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Tue, 25 Jun 2019 18:19:22 +0200 Subject: [PATCH] Remove `Canvas` when dropped --- src/platform_impl/web/web_sys/canvas.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/platform_impl/web/web_sys/canvas.rs b/src/platform_impl/web/web_sys/canvas.rs index 27481349..845c3ee3 100644 --- a/src/platform_impl/web/web_sys/canvas.rs +++ b/src/platform_impl/web/web_sys/canvas.rs @@ -17,6 +17,12 @@ pub struct Canvas { on_mouse_scroll: Option>, } +impl Drop for Canvas { + fn drop(&mut self) { + self.raw.remove(); + } +} + impl Canvas { pub fn create() -> Result { let window = web_sys::window().expect("Failed to obtain window");