diff --git a/CHANGELOG.md b/CHANGELOG.md index a3586a7a3..fdb34aa0f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,8 @@ [unreleased] -- (placeholder) +- Added method `El::is_custom(&self)`. +- Fixed custom elements patching (#325). ## v0.5.1 - [BREAKING] `MessageMapper::map_message` changed to `MessageMapper::map_msg`. diff --git a/examples/server_integration/Cargo.lock b/examples/server_integration/Cargo.lock index bc5d4b361..60535d145 100644 --- a/examples/server_integration/Cargo.lock +++ b/examples/server_integration/Cargo.lock @@ -471,7 +471,7 @@ dependencies = [ name = "client" version = "0.1.0" dependencies = [ - "seed 0.5.0", + "seed 0.5.1", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "shared 0.1.0", "wasm-bindgen 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1490,7 +1490,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "seed" -version = "0.5.0" +version = "0.5.1" dependencies = [ "console_error_panic_hook 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "cookie 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/src/virtual_dom/node/el.rs b/src/virtual_dom/node/el.rs index 67df82d6a..e27da2769 100644 --- a/src/virtual_dom/node/el.rs +++ b/src/virtual_dom/node/el.rs @@ -201,6 +201,16 @@ impl El { child.strip_ws_nodes_from_self_and_children(); } } + + /// Is it a custom element? + pub fn is_custom(&self) -> bool { + // @TODO: replace with `matches!` macro once stable + if let Tag::Custom(_) = self.tag { + true + } else { + false + } + } } /// Allow the user to clone their Els. Note that there's no easy way to clone the diff --git a/src/virtual_dom/patch.rs b/src/virtual_dom/patch.rs index 72a60daae..1852cbd46 100644 --- a/src/virtual_dom/patch.rs +++ b/src/virtual_dom/patch.rs @@ -127,8 +127,9 @@ fn patch_el<'a, Ms, Mdl, ElC: View, GMs>( // old el vdom's elements are still attached. // Namespaces can't be patched, since they involve create_element_ns instead of create_element. + // Custom elements can't be patched, because we need to reinit them (Issue #325). (@TODO is there a better way?) // Something about this element itself is different: patch it. - if old.tag != new.tag || old.namespace != new.namespace { + if old.tag != new.tag || old.namespace != new.namespace || old.is_custom() { let old_el_ws = old.node_ws.as_ref().expect("Missing websys el"); // We don't use assign_nodes directly here, since we only have access to