mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-10 14:44:12 +00:00
Fix reclaim element when hot reloading (#2361)
* Fix reclaim element when hot reloading * Just disable headless tests on windows
This commit is contained in:
parent
39cef8fe42
commit
88f3558419
3 changed files with 7 additions and 16 deletions
|
@ -33,7 +33,8 @@ impl VNode {
|
||||||
if template != self.template.get() {
|
if template != self.template.get() {
|
||||||
let mount_id = self.mount.get();
|
let mount_id = self.mount.get();
|
||||||
let parent = dom.mounts[mount_id.0].parent;
|
let parent = dom.mounts[mount_id.0].parent;
|
||||||
return self.replace([new], parent, dom, to);
|
self.replace([new], parent, dom, to);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -200,7 +201,7 @@ impl VNode {
|
||||||
|
|
||||||
// Clean up any attributes that have claimed a static node as dynamic for mount/unmounts
|
// Clean up any attributes that have claimed a static node as dynamic for mount/unmounts
|
||||||
// Will not generate mutations!
|
// Will not generate mutations!
|
||||||
self.reclaim_attributes(mount, dom, to);
|
self.reclaim_attributes(mount, dom);
|
||||||
|
|
||||||
// Remove the nested dynamic nodes
|
// Remove the nested dynamic nodes
|
||||||
// We don't generate mutations for these, as they will be removed by the parent (in the next line)
|
// We don't generate mutations for these, as they will be removed by the parent (in the next line)
|
||||||
|
@ -314,17 +315,8 @@ impl VNode {
|
||||||
!std::ptr::eq(self_node_name, other_node_name)
|
!std::ptr::eq(self_node_name, other_node_name)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn reclaim_attributes(
|
pub(super) fn reclaim_attributes(&self, mount: MountId, dom: &mut VirtualDom) {
|
||||||
&self,
|
|
||||||
mount: MountId,
|
|
||||||
dom: &mut VirtualDom,
|
|
||||||
_to: &mut impl WriteMutations,
|
|
||||||
) {
|
|
||||||
let mut id = None;
|
|
||||||
|
|
||||||
for (idx, path) in self.template.get().attr_paths.iter().enumerate() {
|
for (idx, path) in self.template.get().attr_paths.iter().enumerate() {
|
||||||
let _attr = &self.dynamic_attrs[idx];
|
|
||||||
|
|
||||||
// We clean up the roots in the next step, so don't worry about them here
|
// We clean up the roots in the next step, so don't worry about them here
|
||||||
if path.len() <= 1 {
|
if path.len() <= 1 {
|
||||||
continue;
|
continue;
|
||||||
|
@ -333,10 +325,7 @@ impl VNode {
|
||||||
let next_id = dom.mounts[mount.0].mounted_attributes[idx];
|
let next_id = dom.mounts[mount.0].mounted_attributes[idx];
|
||||||
|
|
||||||
// only reclaim the new element if it's different from the previous one
|
// only reclaim the new element if it's different from the previous one
|
||||||
if id != Some(next_id) {
|
_ = dom.try_reclaim(next_id);
|
||||||
dom.reclaim(next_id);
|
|
||||||
id = Some(next_id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ use dioxus_desktop::DesktopContext;
|
||||||
mod utils;
|
mod utils;
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
|
#[cfg(not(windows))]
|
||||||
utils::check_app_exits(app);
|
utils::check_app_exits(app);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ use dioxus_desktop::DesktopContext;
|
||||||
mod utils;
|
mod utils;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
#[cfg(not(windows))]
|
||||||
utils::check_app_exits(check_html_renders);
|
utils::check_app_exits(check_html_renders);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue