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,10 +1,8 @@
|
||||
#![cfg(not(miri))]
|
||||
|
||||
use dioxus::prelude::*;
|
||||
use dioxus_core::{AttributeValue, DynamicNode, NoOpMutations, VComponent, VNode, *};
|
||||
use std::{
|
||||
cfg, collections::HashSet, default::Default, sync::atomic::AtomicUsize, sync::atomic::Ordering,
|
||||
};
|
||||
use dioxus_core::{AttributeValue, DynamicNode, NoOpMutations, Template, VComponent, VNode, *};
|
||||
use std::{cfg, collections::HashSet, default::Default};
|
||||
|
||||
fn random_ns() -> Option<&'static str> {
|
||||
let namespace = rand::random::<u8>() % 2;
|
||||
@@ -129,7 +127,7 @@ enum DynamicNodeType {
|
||||
Other,
|
||||
}
|
||||
|
||||
fn create_random_template(name: &'static str) -> (Template, Vec<DynamicNodeType>) {
|
||||
fn create_random_template() -> (Template, Vec<DynamicNodeType>) {
|
||||
let mut dynamic_node_type = Vec::new();
|
||||
let mut template_idx = 0;
|
||||
let mut attr_idx = 0;
|
||||
@@ -160,7 +158,7 @@ fn create_random_template(name: &'static str) -> (Template, Vec<DynamicNodeType>
|
||||
.into_boxed_slice(),
|
||||
);
|
||||
(
|
||||
Template { name, roots, node_paths, attr_paths },
|
||||
Template { roots, node_paths, attr_paths },
|
||||
dynamic_node_type,
|
||||
)
|
||||
}
|
||||
@@ -174,7 +172,6 @@ fn create_random_dynamic_node(depth: usize) -> DynamicNode {
|
||||
VNode::new(
|
||||
None,
|
||||
Template {
|
||||
name: create_template_location(),
|
||||
roots: &[TemplateNode::Dynamic { id: 0 }],
|
||||
node_paths: &[&[0]],
|
||||
attr_paths: &[],
|
||||
@@ -219,19 +216,6 @@ fn create_random_dynamic_attr() -> Attribute {
|
||||
)
|
||||
}
|
||||
|
||||
static TEMPLATE_COUNT: AtomicUsize = AtomicUsize::new(0);
|
||||
|
||||
fn create_template_location() -> &'static str {
|
||||
Box::leak(
|
||||
format!(
|
||||
"{}{}",
|
||||
concat!(file!(), ":", line!(), ":", column!(), ":"),
|
||||
TEMPLATE_COUNT.fetch_add(1, Ordering::Relaxed)
|
||||
)
|
||||
.into_boxed_str(),
|
||||
)
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Props, Clone)]
|
||||
struct DepthProps {
|
||||
depth: usize,
|
||||
@@ -245,7 +229,7 @@ fn create_random_element(cx: DepthProps) -> Element {
|
||||
let range = if cx.root { 2 } else { 3 };
|
||||
let node = match rand::random::<usize>() % range {
|
||||
0 | 1 => {
|
||||
let (template, dynamic_node_types) = create_random_template(create_template_location());
|
||||
let (template, dynamic_node_types) = create_random_template();
|
||||
let node = VNode::new(
|
||||
None,
|
||||
template,
|
||||
@@ -314,8 +298,6 @@ fn diff() {
|
||||
struct InsertEventListenerMutationHandler<'a>(&'a mut HashSet<ElementId>);
|
||||
|
||||
impl WriteMutations for InsertEventListenerMutationHandler<'_> {
|
||||
fn register_template(&mut self, _: Template) {}
|
||||
|
||||
fn append_children(&mut self, _: ElementId, _: usize) {}
|
||||
|
||||
fn assign_node_id(&mut self, _: &'static [u8], _: ElementId) {}
|
||||
@@ -324,9 +306,7 @@ impl WriteMutations for InsertEventListenerMutationHandler<'_> {
|
||||
|
||||
fn create_text_node(&mut self, _: &str, _: ElementId) {}
|
||||
|
||||
fn hydrate_text_node(&mut self, _: &'static [u8], _: &str, _: ElementId) {}
|
||||
|
||||
fn load_template(&mut self, _: &'static str, _: usize, _: ElementId) {}
|
||||
fn load_template(&mut self, _: Template, _: usize, _: ElementId) {}
|
||||
|
||||
fn replace_node_with(&mut self, _: ElementId, _: usize) {}
|
||||
|
||||
|
||||
Reference in new issue
Block a user