diff --git a/crates/bevy_winit/src/winit_windows.rs b/crates/bevy_winit/src/winit_windows.rs index da4024aef8f0d..865eb7a02eedf 100644 --- a/crates/bevy_winit/src/winit_windows.rs +++ b/crates/bevy_winit/src/winit_windows.rs @@ -140,7 +140,8 @@ impl WinitWindows { } winit_window_builder = - winit_window_builder.with_prevent_default(window.prevent_default_event_handling) + winit_window_builder.with_prevent_default(window.prevent_default_event_handling); + winit_window_builder = winit_window_builder.with_append(true); } let winit_window = winit_window_builder.build(event_loop).unwrap(); @@ -189,22 +190,6 @@ impl WinitWindows { self.entity_to_winit.insert(entity, winit_window.id()); self.winit_to_entity.insert(winit_window.id(), entity); - #[cfg(target_arch = "wasm32")] - { - use winit::platform::web::WindowExtWebSys; - - if window.canvas.is_none() { - let canvas = winit_window.canvas().expect("Failed to retrieve canvas."); - - let window = web_sys::window().unwrap(); - let document = window.document().unwrap(); - let body = document.body().unwrap(); - - body.append_child(&canvas) - .expect("Append canvas to HTML body."); - } - } - self.windows .entry(winit_window.id()) .insert(winit_window)