seed
seed copied to clipboard
Mount takeover behavior concerns.
The code in question is introduced in PR #276.
A new enum MountType was introduced for dealing with how to handle elements that are already attached to the root element (the mount_point). The behavior of MountType::Append is approximately the same as before the change. The behavior of MountType::Takeover is that it will add preexisting nodes to the tree, delete the underlying DOM nodes, then construct new DOM nodes.
The second is a little problematic. It is problematic because there can be nodes that should not be recreated (like script nodes). It also replaces unknown elements with the span element, which may also be problematic if someone has custom tags.
Additionally, the tag checking mechanism is slightly buggy, as the many tags have an upper case letter in their spellings, causing scripts to be removed from the DOM. The tag names are listing in dom_types.rs.
Lastly, this is also a bit inefficient, but it is a one time cost.
These issues might need to be addressed later.
Here's a reproducible example based on counter example from the latest master:
// ... snip
fn before_mount(_: Url) -> BeforeMount {
BeforeMount::new()
.mount_point(seed::body())
.mount_type(MountType::Takeover)
}
#[wasm_bindgen(start)]
pub fn render() {
seed::log!("Started");
App::builder(update, view).before_mount(before_mount).build_and_start();
}
You will see "Started" printed 2 times, while it should be printed only once.
Warning about scripts in the mount point: https://github.com/seed-rs/seed/pull/334/files
Does #478 close this issue?