diff options
author | 2022-09-19 16:19:15 +0200 | |
---|---|---|
committer | 2022-11-05 01:28:16 +0100 | |
commit | ab2872fe2be5b694f65125b86e5c03b1f3506ac3 (patch) | |
tree | 48615bfa51bebde2b522b29c45a3d2976ee127fe /winit/src/application.rs | |
parent | d222b5c8b0befab665c20ba0112b28199df0ae44 (diff) | |
download | iced-ab2872fe2be5b694f65125b86e5c03b1f3506ac3.tar.gz iced-ab2872fe2be5b694f65125b86e5c03b1f3506ac3.tar.bz2 iced-ab2872fe2be5b694f65125b86e5c03b1f3506ac3.zip |
Allow to replace an element instead of append to body
Diffstat (limited to 'winit/src/application.rs')
-rw-r--r-- | winit/src/application.rs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/winit/src/application.rs b/winit/src/application.rs index 939a50c9..db0ab938 100644 --- a/winit/src/application.rs +++ b/winit/src/application.rs @@ -159,9 +159,14 @@ where let document = window.document().unwrap(); let body = document.body().unwrap(); - let _ = body - .append_child(&canvas) - .expect("Append canvas to HTML body"); + let _ = match body.query_selector("#iced_root").unwrap() { + Some(e) => body + .replace_child(&canvas, &e) + .expect("Could not replace iced_root"), + None => body + .append_child(&canvas) + .expect("Append canvas to HTML body"), + }; } let (compositor, renderer) = C::new(compositor_settings, Some(&window))?; |