diff --git a/examples/window.rs b/examples/window.rs index 797dbf41..b1adb682 100644 --- a/examples/window.rs +++ b/examples/window.rs @@ -3,7 +3,6 @@ extern crate winit; #[macro_use] extern crate stdweb; #[cfg(feature = "wasm-bindgen")] -#[macro_use] extern crate wasm_bindgen; #[cfg(feature = "wasm-bindgen")] extern crate web_sys; diff --git a/src/platform_impl/web_sys/event_loop.rs b/src/platform_impl/web_sys/event_loop.rs index d7c5779e..d9f43c88 100644 --- a/src/platform_impl/web_sys/event_loop.rs +++ b/src/platform_impl/web_sys/event_loop.rs @@ -265,7 +265,7 @@ fn add_event( event_ref.cancel_bubble(); handler(&elrs, event); - }) as Box); + }) as Box); target.add_event_listener_with_callback(event, &closure.as_ref().unchecked_ref()); closure.forget(); // TODO: don't leak this. diff --git a/src/platform_impl/web_sys/window.rs b/src/platform_impl/web_sys/window.rs index 684c580c..c5c0f88e 100644 --- a/src/platform_impl/web_sys/window.rs +++ b/src/platform_impl/web_sys/window.rs @@ -62,7 +62,7 @@ impl Window { let canvas: HtmlCanvasElement = element.unchecked_into(); document().body() .ok_or_else(|| os_error!(OsError("Failed to find body node".to_owned())))? - .append_child(&canvas); + .append_child(&canvas).map_err(|_| os_error!(OsError("Failed to append canvas".to_owned())))?; register(&target.runner, &canvas);