Fix nested rsx expansion by not using template titles (#2799)
* Fix nested rsx expansion by not using template titles * fix writers with nameless templates * fix clippy * dont commit vscode fix * fix release mode, pull out __template_name * fix axum_desktop * Fix core tests * Make most fields of HotReloadedTemplate public for testing * wip: formatting, compare all diff cases * slightly smarter diffing for dynamic nodes * add a comment about generic node diffing * clean up mutations a bit * fix load template * simplify maybe_rebuild * Restore write mutations flag in web * write_mutations -> skip_mutations --------- Co-authored-by: Evan Almloff <evanalmloff@gmail.com>
This commit is contained in:
1 parent
a2180b92e9
commit
0de3bf7aeb
40 files changed
+597
-1038
No files matched your search
@@ -1,5 +1,6 @@
|
||||
use dioxus::dioxus_core::{ElementId, Mutation::*};
|
||||
use dioxus::prelude::*;
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
/// When returning sets of components, we do a light diff of the contents to preserve some react-like functionality
|
||||
///
|
||||
@@ -7,6 +8,15 @@ use dioxus::prelude::*;
|
||||
/// different pointers
|
||||
#[test]
|
||||
fn component_swap() {
|
||||
// Check that templates with the same structure are deduplicated at compile time
|
||||
// If they are not, this test will fail because it is being run in debug mode where templates are not deduped
|
||||
let dynamic = 0;
|
||||
let template_1 = rsx! { "{dynamic}" };
|
||||
let template_2 = rsx! { "{dynamic}" };
|
||||
if template_1.unwrap().template != template_2.unwrap().template {
|
||||
return;
|
||||
}
|
||||
|
||||
fn app() -> Element {
|
||||
let mut render_phase = use_signal(|| 0);
|
||||
|
||||
@@ -62,16 +72,16 @@ fn component_swap() {
|
||||
|
||||
let mut dom = VirtualDom::new(app);
|
||||
{
|
||||
let edits = dom.rebuild_to_vec().sanitize();
|
||||
let edits = dom.rebuild_to_vec();
|
||||
assert_eq!(
|
||||
edits.edits,
|
||||
[
|
||||
LoadTemplate { name: "template", index: 0, id: ElementId(1) },
|
||||
LoadTemplate { name: "template", index: 0, id: ElementId(2) },
|
||||
LoadTemplate { name: "template", index: 0, id: ElementId(3) },
|
||||
LoadTemplate { name: "template", index: 0, id: ElementId(4) },
|
||||
LoadTemplate { index: 0, id: ElementId(1) },
|
||||
LoadTemplate { index: 0, id: ElementId(2) },
|
||||
LoadTemplate { index: 0, id: ElementId(3) },
|
||||
LoadTemplate { index: 0, id: ElementId(4) },
|
||||
ReplacePlaceholder { path: &[1], m: 3 },
|
||||
LoadTemplate { name: "template", index: 0, id: ElementId(5) },
|
||||
LoadTemplate { index: 0, id: ElementId(5) },
|
||||
AppendChildren { m: 2, id: ElementId(0) }
|
||||
]
|
||||
);
|
||||
@@ -79,27 +89,27 @@ fn component_swap() {
|
||||
|
||||
dom.mark_dirty(ScopeId::APP);
|
||||
assert_eq!(
|
||||
dom.render_immediate_to_vec().sanitize().edits,
|
||||
dom.render_immediate_to_vec().edits,
|
||||
[
|
||||
LoadTemplate { name: "template", index: 0, id: ElementId(6) },
|
||||
LoadTemplate { index: 0, id: ElementId(6) },
|
||||
ReplaceWith { id: ElementId(5), m: 1 }
|
||||
]
|
||||
);
|
||||
|
||||
dom.mark_dirty(ScopeId::APP);
|
||||
assert_eq!(
|
||||
dom.render_immediate_to_vec().sanitize().edits,
|
||||
dom.render_immediate_to_vec().edits,
|
||||
[
|
||||
LoadTemplate { name: "template", index: 0, id: ElementId(5) },
|
||||
LoadTemplate { index: 0, id: ElementId(5) },
|
||||
ReplaceWith { id: ElementId(6), m: 1 }
|
||||
]
|
||||
);
|
||||
|
||||
dom.mark_dirty(ScopeId::APP);
|
||||
assert_eq!(
|
||||
dom.render_immediate_to_vec().sanitize().edits,
|
||||
dom.render_immediate_to_vec().edits,
|
||||
[
|
||||
LoadTemplate { name: "template", index: 0, id: ElementId(6) },
|
||||
LoadTemplate { index: 0, id: ElementId(6) },
|
||||
ReplaceWith { id: ElementId(5), m: 1 }
|
||||
]
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user