Allow to replace an element instead of append to body
This commit is contained in:
parent
d222b5c8b0
commit
ab2872fe2b
1 changed files with 8 additions and 3 deletions
|
|
@ -159,9 +159,14 @@ where
|
||||||
let document = window.document().unwrap();
|
let document = window.document().unwrap();
|
||||||
let body = document.body().unwrap();
|
let body = document.body().unwrap();
|
||||||
|
|
||||||
let _ = body
|
let _ = match body.query_selector("#iced_root").unwrap() {
|
||||||
.append_child(&canvas)
|
Some(e) => body
|
||||||
.expect("Append canvas to HTML 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))?;
|
let (compositor, renderer) = C::new(compositor_settings, Some(&window))?;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue