diff --git a/packages/core/compile_tests/props_safety.rs b/packages/core/compile_tests/props_safety.rs index 00a110a43..312952225 100644 --- a/packages/core/compile_tests/props_safety.rs +++ b/packages/core/compile_tests/props_safety.rs @@ -5,11 +5,7 @@ fn main() {} fn app() -> Element { let count: &RefCell> = cx.use_hook(|| RefCell::new(Vec::new())); - render! { - unsafe_child_component { - borrowed: count - } - } + render! { unsafe_child_component { borrowed: count } } } #[derive(Props)] @@ -26,7 +22,5 @@ fn unsafe_child_component<'a>(cx: Testing) -> Element { .borrow_mut() .push(render! {"{borrowed_temporary_data}"}); - cx.render(rsx! { - div { "Hello, world!" } - }) + render! { div { "Hello, world!" } } } diff --git a/packages/core/compile_tests/props_safety_temporary_values.rs b/packages/core/compile_tests/props_safety_temporary_values.rs index e7f8b7a87..103e333cf 100644 --- a/packages/core/compile_tests/props_safety_temporary_values.rs +++ b/packages/core/compile_tests/props_safety_temporary_values.rs @@ -5,11 +5,7 @@ fn main() {} fn app() -> Element { let count = vec![1, 2, 3]; - render! { - unsafe_child_component { - borrowed: &count - } - } + render! { unsafe_child_component { borrowed: &count } } } #[derive(Props)] @@ -18,7 +14,5 @@ struct Testing<'a> { } fn unsafe_child_component<'a>(cx: Testing) -> Element { - cx.render(rsx! { - div { "{cx.borrowed:?}" } - }) + render! { div { "{cx.borrowed:?}" } } } diff --git a/packages/core/src/properties.rs b/packages/core/src/properties.rs index 62736679c..010da9510 100644 --- a/packages/core/src/properties.rs +++ b/packages/core/src/properties.rs @@ -102,10 +102,10 @@ impl Element> HasProps for F { #[test] fn test_empty_builder() { fn app() -> Element { - render!(div {}) + todo!() } fn app2(_: ()) -> Element { - render!(div {}) + todo!() } let builder = fc_to_builder(app); builder.build(); diff --git a/packages/core/tests/attr_cleanup.rs b/packages/core/tests/attr_cleanup.rs index 6d3bd157a..f4ca3641f 100644 --- a/packages/core/tests/attr_cleanup.rs +++ b/packages/core/tests/attr_cleanup.rs @@ -9,7 +9,7 @@ use dioxus_core::BorrowedAttributeValue; #[test] fn attrs_cycle() { - let mut dom = VirtualDom::new(|cx| { + let mut dom = VirtualDom::new(|| { let id = generation(); match generation() % 2 { 0 => render! { div {} }, @@ -36,18 +36,8 @@ fn attrs_cycle() { [ LoadTemplate { name: "template", index: 0, id: ElementId(2,) }, AssignId { path: &[0,], id: ElementId(3,) }, - SetAttribute { - name: "class", - value: (&*bump.alloc("1".into_value(&bump))).into(), - id: ElementId(3,), - ns: None - }, - SetAttribute { - name: "id", - value: (&*bump.alloc("1".into_value(&bump))).into(), - id: ElementId(3,), - ns: None - }, + SetAttribute { name: "class", value: "1".into_value(), id: ElementId(3,), ns: None }, + SetAttribute { name: "id", value: "1".into_value(), id: ElementId(3,), ns: None }, ReplaceWith { id: ElementId(1,), m: 1 }, ] ); diff --git a/packages/core/tests/borrowedstate.rs b/packages/core/tests/borrowedstate.rs deleted file mode 100644 index 4d533688b..000000000 --- a/packages/core/tests/borrowedstate.rs +++ /dev/null @@ -1,53 +0,0 @@ -#![allow(non_snake_case)] - -use dioxus::core::{ElementId, Mutation::*}; -use dioxus::prelude::*; - -#[test] -fn test_borrowed_state() { - let mut dom = VirtualDom::new(Parent); - - assert_eq!( - dom.rebuild_to_vec().santize().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,) }, - HydrateText { path: &[0,], value: "Hello w1!".to_string(), id: ElementId(4,) }, - ReplacePlaceholder { path: &[1,], m: 1 }, - ReplacePlaceholder { path: &[0,], m: 1 }, - AppendChildren { m: 1, id: ElementId(0) }, - ] - ); -} - -fn Parent() -> Element { - let w1 = cx.use_hook(|| String::from("w1")); - - render! { - div { Child { name: w1 } } - } -} - -#[derive(Props)] -struct ChildProps<'a> { - name: &'a str, -} - -fn Child<'a>(cx: ChildProps) -> Element { - render! { - div { - h1 { "it's nested" } - Child2 { name: cx.name } - } - } -} - -#[derive(Props)] -struct Grandchild<'a> { - name: &'a str, -} - -fn Child2<'a>(cx: Grandchild) -> Element { - render!( div { "Hello {cx.name}!" } ) -} diff --git a/packages/core/tests/context_api.rs b/packages/core/tests/context_api.rs index 7bfc03836..51b2cb148 100644 --- a/packages/core/tests/context_api.rs +++ b/packages/core/tests/context_api.rs @@ -4,7 +4,7 @@ use dioxus::prelude::*; #[test] fn state_shares() { fn app() -> Element { - cx.provide_context(generation().unwrap() as i32); + cx.provide_context(generation() as i32); render!(child_1 {}) } @@ -29,11 +29,15 @@ fn state_shares() { dom.mark_dirty(ScopeId::ROOT); _ = dom.render_immediate_to_vec(); - assert_eq!(dom.base_scope().consume_context::().unwrap(), 1); + dom.in_runtime(|| { + assert_eq!(ScopeId::ROOT.consume_context::().unwrap(), 1); + }); dom.mark_dirty(ScopeId::ROOT); _ = dom.render_immediate_to_vec(); - assert_eq!(dom.base_scope().consume_context::().unwrap(), 2); + dom.in_runtime(|| { + assert_eq!(ScopeId::ROOT.consume_context::().unwrap(), 2); + }); dom.mark_dirty(ScopeId(2)); assert_eq!( diff --git a/packages/core/tests/create_dom.rs b/packages/core/tests/create_dom.rs index 112811e5a..0ca944c1a 100644 --- a/packages/core/tests/create_dom.rs +++ b/packages/core/tests/create_dom.rs @@ -11,7 +11,7 @@ use dioxus_core::ElementId; #[test] fn test_original_diff() { - let mut dom = VirtualDom::new(|cx| { + let mut dom = VirtualDom::new(|| { render! { div { div { "Hello, world!" } } } @@ -31,7 +31,7 @@ fn test_original_diff() { #[test] fn create() { - let mut dom = VirtualDom::new(|cx| { + let mut dom = VirtualDom::new(|| { render! { div { div { @@ -94,7 +94,7 @@ fn create_list() { #[test] fn create_simple() { - let mut dom = VirtualDom::new(|cx| { + let mut dom = VirtualDom::new(|| { render! { div {} div {} @@ -121,7 +121,7 @@ fn create_simple() { } #[test] fn create_components() { - let mut dom = VirtualDom::new(|cx| { + let mut dom = VirtualDom::new(|| { render! { Child { "abc1" } Child { "abc2" } @@ -149,7 +149,7 @@ fn create_components() { #[test] fn anchors() { - let mut dom = VirtualDom::new(|cx| { + let mut dom = VirtualDom::new(|| { render! { if true { render!( div { "hello" } ) diff --git a/packages/core/tests/create_element.rs b/packages/core/tests/create_element.rs index 7a58924fd..d61b1576c 100644 --- a/packages/core/tests/create_element.rs +++ b/packages/core/tests/create_element.rs @@ -3,7 +3,7 @@ use dioxus::prelude::*; #[test] fn multiroot() { - let mut dom = VirtualDom::new(|cx| { + let mut dom = VirtualDom::new(|| { render! { div { "Hello a" } div { "Hello b" } diff --git a/packages/core/tests/create_fragments.rs b/packages/core/tests/create_fragments.rs index f9b4f0dd0..502405b00 100644 --- a/packages/core/tests/create_fragments.rs +++ b/packages/core/tests/create_fragments.rs @@ -24,7 +24,7 @@ fn empty_fragment_creates_nothing() { #[test] fn root_fragments_work() { - let mut vdom = VirtualDom::new(|cx| { + let mut vdom = VirtualDom::new(|| { render!( div { "hello" } div { "goodbye" } @@ -39,7 +39,7 @@ fn root_fragments_work() { #[test] fn fragments_nested() { - let mut vdom = VirtualDom::new(|cx| { + let mut vdom = VirtualDom::new(|| { render!( div { "hello" } div { "goodbye" } diff --git a/packages/core/tests/create_passthru.rs b/packages/core/tests/create_passthru.rs index 3628ac2af..65b60c2a6 100644 --- a/packages/core/tests/create_passthru.rs +++ b/packages/core/tests/create_passthru.rs @@ -53,7 +53,7 @@ fn nested_passthru_creates_add() { } #[component] - fn ChildComp<'a>(children: Element) -> Element { + fn ChildComp(children: Element) -> Element { render! {children} } diff --git a/packages/core/tests/diff_keyed_list.rs b/packages/core/tests/diff_keyed_list.rs index 91f86d56c..6b8b87852 100644 --- a/packages/core/tests/diff_keyed_list.rs +++ b/packages/core/tests/diff_keyed_list.rs @@ -10,7 +10,7 @@ use dioxus::prelude::*; /// Should result in moves, but not removals or additions #[test] fn keyed_diffing_out_of_order() { - let mut dom = VirtualDom::new(|cx| { + let mut dom = VirtualDom::new(|| { let order = match generation() % 2 { 0 => &[0, 1, 2, 3, /**/ 4, 5, 6, /**/ 7, 8, 9], 1 => &[0, 1, 2, 3, /**/ 6, 4, 5, /**/ 7, 8, 9], @@ -52,7 +52,7 @@ fn keyed_diffing_out_of_order() { /// Should result in moves only #[test] fn keyed_diffing_out_of_order_adds() { - let mut dom = VirtualDom::new(|cx| { + let mut dom = VirtualDom::new(|| { let order = match generation() % 2 { 0 => &[/**/ 4, 5, 6, 7, 8 /**/], 1 => &[/**/ 8, 7, 4, 5, 6 /**/], @@ -62,7 +62,7 @@ fn keyed_diffing_out_of_order_adds() { render!(order.iter().map(|i| render!(div { key: "{i}" }))) }); - _ = dom.rebuild_to_vec(&mut dioxus_core::NoOpMutations); + _ = dom.rebuild(&mut dioxus_core::NoOpMutations); dom.mark_dirty(ScopeId::ROOT); assert_eq!( @@ -78,7 +78,7 @@ fn keyed_diffing_out_of_order_adds() { /// Should result in moves only #[test] fn keyed_diffing_out_of_order_adds_3() { - let mut dom = VirtualDom::new(|cx| { + let mut dom = VirtualDom::new(|| { let order = match generation() % 2 { 0 => &[/**/ 4, 5, 6, 7, 8 /**/], 1 => &[/**/ 4, 8, 7, 5, 6 /**/], @@ -88,7 +88,7 @@ fn keyed_diffing_out_of_order_adds_3() { render!(order.iter().map(|i| render!(div { key: "{i}" }))) }); - _ = dom.rebuild_to_vec(&mut dioxus_core::NoOpMutations); + _ = dom.rebuild(&mut dioxus_core::NoOpMutations); dom.mark_dirty(ScopeId::ROOT); assert_eq!( @@ -104,7 +104,7 @@ fn keyed_diffing_out_of_order_adds_3() { /// Should result in moves onl #[test] fn keyed_diffing_out_of_order_adds_4() { - let mut dom = VirtualDom::new(|cx| { + let mut dom = VirtualDom::new(|| { let order = match generation() % 2 { 0 => &[/**/ 4, 5, 6, 7, 8 /**/], 1 => &[/**/ 4, 5, 8, 7, 6 /**/], @@ -114,7 +114,7 @@ fn keyed_diffing_out_of_order_adds_4() { render!(order.iter().map(|i| render!(div { key: "{i}" }))) }); - _ = dom.rebuild_to_vec(&mut dioxus_core::NoOpMutations); + _ = dom.rebuild(&mut dioxus_core::NoOpMutations); dom.mark_dirty(ScopeId::ROOT); assert_eq!( @@ -130,7 +130,7 @@ fn keyed_diffing_out_of_order_adds_4() { /// Should result in moves onl #[test] fn keyed_diffing_out_of_order_adds_5() { - let mut dom = VirtualDom::new(|cx| { + let mut dom = VirtualDom::new(|| { let order = match generation() % 2 { 0 => &[/**/ 4, 5, 6, 7, 8 /**/], 1 => &[/**/ 4, 5, 6, 8, 7 /**/], @@ -140,7 +140,7 @@ fn keyed_diffing_out_of_order_adds_5() { render!(order.iter().map(|i| render!(div { key: "{i}" }))) }); - _ = dom.rebuild_to_vec(&mut dioxus_core::NoOpMutations); + _ = dom.rebuild(&mut dioxus_core::NoOpMutations); dom.mark_dirty(ScopeId::ROOT); assert_eq!( @@ -155,7 +155,7 @@ fn keyed_diffing_out_of_order_adds_5() { /// Should result in moves onl #[test] fn keyed_diffing_additions() { - let mut dom = VirtualDom::new(|cx| { + let mut dom = VirtualDom::new(|| { let order: &[_] = match generation() % 2 { 0 => &[/**/ 4, 5, 6, 7, 8 /**/], 1 => &[/**/ 4, 5, 6, 7, 8, 9, 10 /**/], @@ -165,7 +165,7 @@ fn keyed_diffing_additions() { render!(order.iter().map(|i| render!(div { key: "{i}" }))) }); - _ = dom.rebuild_to_vec(&mut dioxus_core::NoOpMutations); + _ = dom.rebuild(&mut dioxus_core::NoOpMutations); dom.mark_dirty(ScopeId::ROOT); assert_eq!( @@ -180,7 +180,7 @@ fn keyed_diffing_additions() { #[test] fn keyed_diffing_additions_and_moves_on_ends() { - let mut dom = VirtualDom::new(|cx| { + let mut dom = VirtualDom::new(|| { let order: &[_] = match generation() % 2 { 0 => &[/**/ 4, 5, 6, 7 /**/], 1 => &[/**/ 7, 4, 5, 6, 11, 12 /**/], @@ -190,7 +190,7 @@ fn keyed_diffing_additions_and_moves_on_ends() { render!(order.iter().map(|i| render!(div { key: "{i}" }))) }); - _ = dom.rebuild_to_vec(&mut dioxus_core::NoOpMutations); + _ = dom.rebuild(&mut dioxus_core::NoOpMutations); dom.mark_dirty(ScopeId::ROOT); assert_eq!( @@ -209,7 +209,7 @@ fn keyed_diffing_additions_and_moves_on_ends() { #[test] fn keyed_diffing_additions_and_moves_in_middle() { - let mut dom = VirtualDom::new(|cx| { + let mut dom = VirtualDom::new(|| { let order: &[_] = match generation() % 2 { 0 => &[/**/ 1, 2, 3, 4 /**/], 1 => &[/**/ 4, 1, 7, 8, 2, 5, 6, 3 /**/], @@ -219,7 +219,7 @@ fn keyed_diffing_additions_and_moves_in_middle() { render!(order.iter().map(|i| render!(div { key: "{i}" }))) }); - _ = dom.rebuild_to_vec(&mut dioxus_core::NoOpMutations); + _ = dom.rebuild(&mut dioxus_core::NoOpMutations); // LIS: 4, 5, 6 dom.mark_dirty(ScopeId::ROOT); @@ -243,7 +243,7 @@ fn keyed_diffing_additions_and_moves_in_middle() { #[test] fn controlled_keyed_diffing_out_of_order() { - let mut dom = VirtualDom::new(|cx| { + let mut dom = VirtualDom::new(|| { let order: &[_] = match generation() % 2 { 0 => &[4, 5, 6, 7], 1 => &[0, 5, 9, 6, 4], @@ -253,7 +253,7 @@ fn controlled_keyed_diffing_out_of_order() { render!(order.iter().map(|i| render!(div { key: "{i}" }))) }); - _ = dom.rebuild_to_vec(&mut dioxus_core::NoOpMutations); + _ = dom.rebuild(&mut dioxus_core::NoOpMutations); // LIS: 5, 6 dom.mark_dirty(ScopeId::ROOT); @@ -277,7 +277,7 @@ fn controlled_keyed_diffing_out_of_order() { #[test] fn controlled_keyed_diffing_out_of_order_max_test() { - let mut dom = VirtualDom::new(|cx| { + let mut dom = VirtualDom::new(|| { let order: &[_] = match generation() % 2 { 0 => &[0, 1, 2, 3, 4], 1 => &[3, 0, 1, 10, 2], @@ -287,7 +287,7 @@ fn controlled_keyed_diffing_out_of_order_max_test() { render!(order.iter().map(|i| render!(div { key: "{i}" }))) }); - _ = dom.rebuild_to_vec(&mut dioxus_core::NoOpMutations); + _ = dom.rebuild(&mut dioxus_core::NoOpMutations); dom.mark_dirty(ScopeId::ROOT); assert_eq!( @@ -306,7 +306,7 @@ fn controlled_keyed_diffing_out_of_order_max_test() { // just making sure it doesnt happen in the core implementation #[test] fn remove_list() { - let mut dom = VirtualDom::new(|cx| { + let mut dom = VirtualDom::new(|| { let order: &[_] = match generation() % 2 { 0 => &[9, 8, 7, 6, 5], 1 => &[9, 8], @@ -316,7 +316,7 @@ fn remove_list() { render!(order.iter().map(|i| render!(div { key: "{i}" }))) }); - _ = dom.rebuild_to_vec(&mut dioxus_core::NoOpMutations); + _ = dom.rebuild(&mut dioxus_core::NoOpMutations); dom.mark_dirty(ScopeId::ROOT); assert_eq!( @@ -331,7 +331,7 @@ fn remove_list() { #[test] fn no_common_keys() { - let mut dom = VirtualDom::new(|cx| { + let mut dom = VirtualDom::new(|| { let order: &[_] = match generation() % 2 { 0 => &[1, 2, 3], 1 => &[4, 5, 6], @@ -341,7 +341,7 @@ fn no_common_keys() { render!(order.iter().map(|i| render!(div { key: "{i}" }))) }); - _ = dom.rebuild_to_vec(&mut dioxus_core::NoOpMutations); + _ = dom.rebuild(&mut dioxus_core::NoOpMutations); dom.mark_dirty(ScopeId::ROOT); assert_eq!( diff --git a/packages/core/tests/diff_unkeyed_list.rs b/packages/core/tests/diff_unkeyed_list.rs index 9022c4534..0e1b5a972 100644 --- a/packages/core/tests/diff_unkeyed_list.rs +++ b/packages/core/tests/diff_unkeyed_list.rs @@ -4,7 +4,7 @@ use pretty_assertions::assert_eq; #[test] fn list_creates_one_by_one() { - let mut dom = VirtualDom::new(|cx| { + let mut dom = VirtualDom::new(|| { let gen = generation(); render! { @@ -73,7 +73,7 @@ fn list_creates_one_by_one() { #[test] fn removes_one_by_one() { - let mut dom = VirtualDom::new(|cx| { + let mut dom = VirtualDom::new(|| { let gen = 3 - generation() % 4; render! { @@ -150,7 +150,7 @@ fn removes_one_by_one() { #[test] fn list_shrink_multiroot() { - let mut dom = VirtualDom::new(|cx| { + let mut dom = VirtualDom::new(|| { render! { div { (0..generation()).map(|i| render! { @@ -209,7 +209,7 @@ fn list_shrink_multiroot() { #[test] fn removes_one_by_one_multiroot() { - let mut dom = VirtualDom::new(|cx| { + let mut dom = VirtualDom::new(|| { let gen = 3 - generation() % 4; render! { @@ -274,7 +274,7 @@ fn removes_one_by_one_multiroot() { #[test] fn two_equal_fragments_are_equal_static() { - let mut dom = VirtualDom::new(|cx| { + let mut dom = VirtualDom::new(|| { render! { (0..5).map(|_| render! { div { "hello" } @@ -282,13 +282,13 @@ fn two_equal_fragments_are_equal_static() { } }); - _ = dom.rebuild_to_vec(&mut dioxus_core::NoOpMutations); + _ = dom.rebuild(&mut dioxus_core::NoOpMutations); assert!(dom.render_immediate_to_vec().edits.is_empty()); } #[test] fn two_equal_fragments_are_equal() { - let mut dom = VirtualDom::new(|cx| { + let mut dom = VirtualDom::new(|| { render! { (0..5).map(|i| render! { div { "hello {i}" } @@ -296,13 +296,13 @@ fn two_equal_fragments_are_equal() { } }); - _ = dom.rebuild_to_vec(&mut dioxus_core::NoOpMutations); + _ = dom.rebuild(&mut dioxus_core::NoOpMutations); assert!(dom.render_immediate_to_vec().edits.is_empty()); } #[test] fn remove_many() { - let mut dom = VirtualDom::new(|cx| { + let mut dom = VirtualDom::new(|| { let num = match generation() % 3 { 0 => 0, 1 => 1, diff --git a/packages/core/tests/error_boundary.rs b/packages/core/tests/error_boundary.rs index 97b03ad8e..50e226b19 100644 --- a/packages/core/tests/error_boundary.rs +++ b/packages/core/tests/error_boundary.rs @@ -5,7 +5,7 @@ use dioxus::prelude::*; #[test] fn catches_panic() { let mut dom = VirtualDom::new(app); - _ = dom.rebuild_to_vec(&mut dioxus_core::NoOpMutations); + _ = dom.rebuild(&mut dioxus_core::NoOpMutations); } fn app() -> Element { diff --git a/packages/core/tests/event_propagation.rs b/packages/core/tests/event_propagation.rs index 0792c9ae3..78136e8f3 100644 --- a/packages/core/tests/event_propagation.rs +++ b/packages/core/tests/event_propagation.rs @@ -9,7 +9,7 @@ fn events_propagate() { set_event_converter(Box::new(dioxus_html::SerializedHtmlEventConverter)); let mut dom = VirtualDom::new(app); - _ = dom.rebuild_to_vec(&mut dioxus_core::NoOpMutations); + _ = dom.rebuild(&mut dioxus_core::NoOpMutations); // Top-level click is registered dom.handle_event( diff --git a/packages/core/tests/lifecycle.rs b/packages/core/tests/lifecycle.rs index 78becc3b8..32846cc60 100644 --- a/packages/core/tests/lifecycle.rs +++ b/packages/core/tests/lifecycle.rs @@ -16,7 +16,7 @@ fn manual_diffing() { value: Shared<&'static str>, } - fn app(cx: Scope) -> Element { + fn app(cx: AppProps) -> Element { let val = cx.value.lock().unwrap(); render! { div { "{val}" } } }; @@ -24,7 +24,7 @@ fn manual_diffing() { let value = Arc::new(Mutex::new("Hello")); let mut dom = VirtualDom::new_with_props(app, AppProps { value: value.clone() }); - let _ = dom.rebuild_to_vec(&mut dioxus_core::NoOpMutations); + let _ = dom.rebuild(&mut dioxus_core::NoOpMutations); *value.lock().unwrap() = "goodbye"; @@ -56,7 +56,7 @@ fn events_generate() { }; let mut dom = VirtualDom::new(app); - _ = dom.rebuild_to_vec(&mut dioxus_core::NoOpMutations); + _ = dom.rebuild(&mut dioxus_core::NoOpMutations); dom.handle_event( "click", diff --git a/packages/core/tests/miri_full_app.rs b/packages/core/tests/miri_full_app.rs index 7167e6560..b8ad213e0 100644 --- a/packages/core/tests/miri_full_app.rs +++ b/packages/core/tests/miri_full_app.rs @@ -9,7 +9,7 @@ fn miri_rollover() { set_event_converter(Box::new(SerializedHtmlEventConverter)); let mut dom = VirtualDom::new(App); - _ = dom.rebuild_to_vec(&mut dioxus_core::NoOpMutations); + _ = dom.rebuild(&mut dioxus_core::NoOpMutations); for _ in 0..3 { dom.handle_event( @@ -23,7 +23,6 @@ fn miri_rollover() { } } -#[component] fn App() -> Element { let mut idx = use_signal(|| 0); let onhover = |_| println!("go!"); @@ -39,7 +38,7 @@ fn App() -> Element { } button { onclick: move |_| idx -= 1, "-" } ul { - (0..**idx).map(|i| render! { + (0..*idx()).map(|i| render! { ChildExample { i: i, onhover: onhover } }) } @@ -48,6 +47,6 @@ fn App() -> Element { } #[component] -fn ChildExample<'a>(i: i32, onhover: EventHandler<'a, MouseEvent>) -> Element { +fn ChildExample(i: i32, onhover: EventHandler) -> Element { render! { li { onmouseover: move |e| onhover.call(e), "{i}" } } } diff --git a/packages/core/tests/miri_simple.rs b/packages/core/tests/miri_simple.rs index f5e26a3dc..eb3df8320 100644 --- a/packages/core/tests/miri_simple.rs +++ b/packages/core/tests/miri_simple.rs @@ -8,7 +8,7 @@ fn app_drops() { let mut dom = VirtualDom::new(App); - _ = dom.rebuild_to_vec(&mut dioxus_core::NoOpMutations); + _ = dom.rebuild(&mut dioxus_core::NoOpMutations); dom.mark_dirty(ScopeId::ROOT); _ = dom.render_immediate_to_vec(); } @@ -26,7 +26,7 @@ fn hooks_drop() { let mut dom = VirtualDom::new(App); - _ = dom.rebuild_to_vec(&mut dioxus_core::NoOpMutations); + _ = dom.rebuild(&mut dioxus_core::NoOpMutations); dom.mark_dirty(ScopeId::ROOT); _ = dom.render_immediate_to_vec(); } @@ -41,7 +41,6 @@ fn contexts_drop() { } } - #[component] fn ChildComp() -> Element { let el = cx.consume_context::().unwrap(); @@ -50,7 +49,7 @@ fn contexts_drop() { let mut dom = VirtualDom::new(App); - _ = dom.rebuild_to_vec(&mut dioxus_core::NoOpMutations); + _ = dom.rebuild(&mut dioxus_core::NoOpMutations); dom.mark_dirty(ScopeId::ROOT); _ = dom.render_immediate_to_vec(); } @@ -67,13 +66,14 @@ fn tasks_drop() { let mut dom = VirtualDom::new(App); - _ = dom.rebuild_to_vec(&mut dioxus_core::NoOpMutations); + _ = dom.rebuild(&mut dioxus_core::NoOpMutations); dom.mark_dirty(ScopeId::ROOT); _ = dom.render_immediate_to_vec(); } #[test] fn root_props_drop() { + #[derive(Clone)] struct RootProps(String); let mut dom = VirtualDom::new_with_props( @@ -81,7 +81,7 @@ fn root_props_drop() { RootProps("asdasd".to_string()), ); - _ = dom.rebuild_to_vec(&mut dioxus_core::NoOpMutations); + _ = dom.rebuild(&mut dioxus_core::NoOpMutations); dom.mark_dirty(ScopeId::ROOT); _ = dom.render_immediate_to_vec(); } @@ -111,7 +111,7 @@ fn diffing_drops_old() { } let mut dom = VirtualDom::new(App); - _ = dom.rebuild_to_vec(&mut dioxus_core::NoOpMutations); + _ = dom.rebuild(&mut dioxus_core::NoOpMutations); dom.mark_dirty(ScopeId::ROOT); _ = dom.render_immediate_to_vec(); diff --git a/packages/core/tests/miri_stress.rs b/packages/core/tests/miri_stress.rs index fbfa5b295..11677d687 100644 --- a/packages/core/tests/miri_stress.rs +++ b/packages/core/tests/miri_stress.rs @@ -59,7 +59,7 @@ fn test_memory_leak() { let mut dom = VirtualDom::new(app); - _ = dom.rebuild_to_vec(&mut dioxus_core::NoOpMutations); + _ = dom.rebuild(&mut dioxus_core::NoOpMutations); for _ in 0..5 { dom.mark_dirty(ScopeId::ROOT); @@ -84,7 +84,7 @@ fn memo_works_properly() { ) } - #[derive(PartialEq, Props)] + #[derive(PartialEq, Clone, Props)] struct ChildProps { na: String, } @@ -95,7 +95,7 @@ fn memo_works_properly() { let mut dom = VirtualDom::new(app); - _ = dom.rebuild_to_vec(&mut dioxus_core::NoOpMutations); + _ = dom.rebuild(&mut dioxus_core::NoOpMutations); // todo!() // dom.hard_diff(ScopeId::ROOT); // dom.hard_diff(ScopeId::ROOT); @@ -121,13 +121,13 @@ fn free_works_on_root_hooks() { render!(child_component { inner: name.inner.clone() }) } - fn child_component(cx: Scope) -> Element { - render!( div { "{cx.inner}" } ) + fn child_component(props: AppProps) -> Element { + render!( div { "{props.inner}" } ) } let ptr = Rc::new("asdasd".to_string()); let mut dom = VirtualDom::new_with_props(app, AppProps { inner: ptr.clone() }); - let _ = dom.rebuild_to_vec(&mut dioxus_core::NoOpMutations); + let _ = dom.rebuild(&mut dioxus_core::NoOpMutations); // ptr gets cloned into props and then into the hook assert_eq!(Rc::strong_count(&ptr), 4); @@ -162,6 +162,7 @@ fn supports_async() { }); }); + let colors = colors(); let big = colors[0]; let mid = colors[1]; let small = colors[2]; @@ -184,7 +185,7 @@ fn supports_async() { rt.block_on(async { let mut dom = VirtualDom::new(app); - let _ = dom.rebuild_to_vec(&mut dioxus_core::NoOpMutations); + let _ = dom.rebuild(&mut dioxus_core::NoOpMutations); for _ in 0..10 { dom.wait_for_work().await; diff --git a/packages/core/tests/suspense.rs b/packages/core/tests/suspense.rs index 6f04106b1..88e743d1a 100644 --- a/packages/core/tests/suspense.rs +++ b/packages/core/tests/suspense.rs @@ -9,7 +9,7 @@ fn it_works() { .unwrap() .block_on(async { let mut dom = VirtualDom::new(app); - _ = dom.rebuild_to_vec(&mut dioxus_core::NoOpMutations); + _ = dom.rebuild(&mut dioxus_core::NoOpMutations); dom.wait_for_suspense().await; let out = dioxus_ssr::render(&dom); @@ -32,10 +32,10 @@ fn suspended_child() -> Element { let mut val = use_signal(|| 0); if *val() < 3 { - cx.spawn(async move { + spawn(async move { val += 1; }); - cx.suspend()?; + suspend()?; } render!("child") diff --git a/packages/core/tests/task.rs b/packages/core/tests/task.rs index 410b88f98..f61c45807 100644 --- a/packages/core/tests/task.rs +++ b/packages/core/tests/task.rs @@ -30,7 +30,7 @@ async fn it_works() { let mut dom = VirtualDom::new(app); - let _ = dom.rebuild_to_vec(&mut dioxus_core::NoOpMutations); + let _ = dom.rebuild(&mut dioxus_core::NoOpMutations); tokio::select! { _ = dom.wait_for_work() => {}