wip: move everything over to a stack dst

This commit is contained in:
Jonathan Kelley committed 2021-10-29 17:12:30 -04:00
1 parent 12a9758c3c
commit 0e9d5fc530
36 files changed
+224 -185

No files matched your search

+9 -9
View File
@@ -10,17 +10,17 @@ fn test_borrowed_state() {
let _ = VirtualDom::new(Parent);
}
fn Parent((cx, _): Component<()>) -> DomTree {
fn Parent((cx, _): Component<()>) -> Element {
let value = cx.use_hook(|_| String::new(), |f| &*f, |_| {});
cx.render(rsx! {
rsx! {
div {
Child { name: value }
Child { name: value }
Child { name: value }
Child { name: value }
}
})
}
}
#[derive(Props)]
@@ -28,13 +28,13 @@ struct ChildProps<'a> {
name: &'a str,
}
fn Child<'a>((cx, props): Component<'a, ChildProps>) -> DomTree<'a> {
cx.render(rsx! {
fn Child<'a>((cx, props): Component<'a, ChildProps>) -> Element<'a> {
rsx! {
div {
h1 { "it's nested" }
Child2 { name: props.name }
}
})
}
}
#[derive(Props)]
@@ -42,8 +42,8 @@ struct Grandchild<'a> {
name: &'a str,
}
fn Child2<'a>((cx, props): Component<'a, Grandchild>) -> DomTree<'a> {
cx.render(rsx! {
fn Child2<'a>((cx, props): Component<'a, Grandchild>) -> Element<'a> {
rsx! {
div { "Hello {props.name}!" }
})
}
}
+16 -16
View File
@@ -22,13 +22,13 @@ fn new_dom<P: 'static + Send>(app: FC<P>, props: P) -> VirtualDom {
#[test]
fn test_original_diff() {
static APP: FC<()> = |(cx, props)| {
cx.render(rsx! {
rsx! {
div {
div {
"Hello, world!"
}
}
})
}
};
let mut dom = new_dom(APP, ());
@@ -58,7 +58,7 @@ fn test_original_diff() {
#[test]
fn create() {
static APP: FC<()> = |(cx, props)| {
cx.render(rsx! {
rsx! {
div {
div {
"Hello, world!"
@@ -72,7 +72,7 @@ fn create() {
}
}
}
})
}
};
let mut dom = new_dom(APP, ());
@@ -121,11 +121,11 @@ fn create() {
#[test]
fn create_list() {
static APP: FC<()> = |(cx, props)| {
cx.render(rsx! {
rsx! {
{(0..3).map(|f| rsx!{ div {
"hello"
}})}
})
}
};
let mut dom = new_dom(APP, ());
@@ -170,12 +170,12 @@ fn create_list() {
#[test]
fn create_simple() {
static APP: FC<()> = |(cx, props)| {
cx.render(rsx! {
rsx! {
div {}
div {}
div {}
div {}
})
}
};
let mut dom = new_dom(APP, ());
@@ -208,19 +208,19 @@ fn create_simple() {
#[test]
fn create_components() {
static App: FC<()> = |(cx, props)| {
cx.render(rsx! {
rsx! {
Child { "abc1" }
Child { "abc2" }
Child { "abc3" }
})
}
};
static Child: FC<()> = |(cx, props)| {
cx.render(rsx! {
rsx! {
h1 {}
div { {cx.children()} }
p {}
})
}
};
let mut dom = new_dom(App, ());
@@ -269,10 +269,10 @@ fn create_components() {
#[test]
fn anchors() {
static App: FC<()> = |(cx, props)| {
cx.render(rsx! {
rsx! {
{true.then(|| rsx!{ div { "hello" } })}
{false.then(|| rsx!{ div { "goodbye" } })}
})
}
};
let mut dom = new_dom(App, ());
@@ -303,9 +303,9 @@ fn suspended() {
|| async {
//
},
|cx, p| cx.render(rsx! { "hi "}),
|cx, p| rsx! { "hi "},
);
cx.render(rsx! { {val} })
rsx! { {val} }
};
let mut dom = new_dom(App, ());
+2 -2
View File
@@ -807,14 +807,14 @@ fn controlled_keyed_diffing_out_of_order_max_test() {
fn suspense() {
let dom = new_dom();
let edits = dom.create(LazyNodes::new(|f| {
let edits = dom.create(Some(LazyNodes::new(|f| {
use std::cell::{Cell, RefCell};
VNode::Suspended(f.bump().alloc(VSuspended {
task_id: 0,
callback: RefCell::new(None),
dom_id: Cell::new(None),
}))
}));
})));
assert_eq!(
edits.edits,
[CreatePlaceholder { root: 0 }, AppendChildren { many: 1 }]
+4 -4
View File
@@ -14,7 +14,7 @@ mod test_logging;
#[test]
fn please_work() {
static App: FC<()> = |(cx, props)| {
cx.render(rsx! {
rsx! {
div {
hidden: "true"
"hello"
@@ -24,13 +24,13 @@ fn please_work() {
Child {}
}
div { "hello" }
})
}
};
static Child: FC<()> = |(cx, props)| {
cx.render(rsx! {
rsx! {
div { "child" }
})
}
};
let mut dom = VirtualDom::new(App);
+1 -1
View File
@@ -22,7 +22,7 @@ fn manual_diffing() {
static App: FC<AppProps> = |(cx, props)| {
let val = props.value.lock().unwrap();
cx.render(rsx! { div { "{val}" } })
rsx! { div { "{val}" } }
};
let value = Arc::new(Mutex::new("Hello"));
+2 -2
View File
@@ -15,12 +15,12 @@ fn shared_state_test() {
static App: FC<()> = |(cx, props)| {
cx.provide_state(MySharedState("world!"));
rsx!(cx, Child {})
rsx!(Child {})
};
static Child: FC<()> = |(cx, props)| {
let shared = cx.consume_state::<MySharedState>()?;
rsx!(cx, "Hello, {shared.0}")
rsx!("Hello, {shared.0}")
};
let mut dom = VirtualDom::new(App);
+13 -13
View File
@@ -19,7 +19,7 @@ use dioxus_html as dioxus_elements;
fn app_runs() {
static App: FC<()> = |(cx, props)| {
//
cx.render(rsx!( div{"hello"} ))
rsx!( div{"hello"} )
};
let mut vdom = VirtualDom::new(App);
let edits = vdom.rebuild();
@@ -29,10 +29,10 @@ fn app_runs() {
#[test]
fn fragments_work() {
static App: FC<()> = |(cx, props)| {
cx.render(rsx!(
rsx!(
div{"hello"}
div{"goodbye"}
))
)
};
let mut vdom = VirtualDom::new(App);
let edits = vdom.rebuild();
@@ -43,10 +43,10 @@ fn fragments_work() {
#[test]
fn lists_work() {
static App: FC<()> = |(cx, props)| {
cx.render(rsx!(
rsx!(
h1 {"hello"}
{(0..6).map(|f| rsx!(span{ "{f}" }))}
))
)
};
let mut vdom = VirtualDom::new(App);
let edits = vdom.rebuild();
@@ -56,11 +56,11 @@ fn lists_work() {
#[test]
fn conditional_rendering() {
static App: FC<()> = |(cx, props)| {
cx.render(rsx!(
rsx!(
h1 {"hello"}
{true.then(|| rsx!(span{ "a" }))}
{false.then(|| rsx!(span{ "b" }))}
))
)
};
let mut vdom = VirtualDom::new(App);
@@ -73,16 +73,16 @@ fn conditional_rendering() {
#[test]
fn child_components() {
static App: FC<()> = |(cx, props)| {
cx.render(rsx!(
rsx!(
{true.then(|| rsx!(Child { }))}
{false.then(|| rsx!(Child { }))}
))
)
};
static Child: FC<()> = |(cx, props)| {
cx.render(rsx!(
rsx!(
h1 {"hello"}
h1 {"goodbye"}
))
)
};
let mut vdom = VirtualDom::new(App);
let edits = vdom.rebuild();
@@ -92,8 +92,8 @@ fn child_components() {
#[test]
fn suspended_works() {
static App: FC<()> = |(cx, props)| {
let title = use_suspense(cx, || async { "bob" }, |cx, f| cx.render(rsx! { "{f}"}));
cx.render(rsx!("hello" { title }))
let title = use_suspense(cx, || async { "bob" }, |cx, f| rsx! { "{f}"});
rsx!("hello" { title })
};
let mut vdom = VirtualDom::new(App);