Feat: view -> render

This commit is contained in:
Jonathan Kelley committed 2021-02-28 21:21:17 -05:00
1 parent 10a236fc65
commit c8bb392cad
24 files changed
+204 -48

No files matched your search

+2 -2
View File
@@ -44,7 +44,7 @@ mod tests {
static TestComponent: FC<()> = |ctx, props| {
//
ctx.view(html! {
ctx.render(html! {
<div>
</div>
})
@@ -52,7 +52,7 @@ mod tests {
static TestComponent2: FC<()> = |ctx, props| {
//
ctx.view(|bump: &Bump| VNode::text("blah"))
ctx.render(|bump: &Bump| VNode::text("blah"))
};
#[test]
+2 -2
View File
@@ -73,10 +73,10 @@ impl<'a> Context<'a> {
/// let lazy_tree = html! {<div>"Hello World"</div>};
///
/// // Actually build the tree and allocate it
/// ctx.view(lazy_tree)
/// ctx.render(lazy_tree)
/// }
///```
pub fn view(self, lazy_nodes: impl FnOnce(&'a Bump) -> VNode<'a> + 'a) -> DomTree {
pub fn render(self, lazy_nodes: impl FnOnce(&'a Bump) -> VNode<'a> + 'a) -> DomTree {
let safe_nodes = lazy_nodes(self.bump);
let unsafe_nodes = unsafe { std::mem::transmute::<VNode<'a>, VNode<'static>>(safe_nodes) };
self.final_nodes.deref().borrow_mut().replace(unsafe_nodes);
+1 -1
View File
@@ -30,7 +30,7 @@ mod tests {
fn ensure_creation() -> Result<(), ()> {
let mut dom = VirtualDom::new(|ctx, props| {
//
ctx.view(html! { <div>"hello world" </div> })
ctx.render(html! { <div>"hello world" </div> })
});
// dom.progress()?;
+6 -6
View File
@@ -266,7 +266,7 @@ mod tests {
use crate::prelude::format_args_f;
static ListenerTest: FC<()> = |ctx, props| {
ctx.view(html! {
ctx.render(html! {
<div onclick={|_| println!("Hell owlrld")}>
"hello"
</div>
@@ -288,7 +288,7 @@ mod tests {
fn test_scope() {
let example: FC<()> = |ctx, props| {
use crate::builder::*;
ctx.view(|b| div(b).child(text("a")).finish())
ctx.render(|b| div(b).child(text("a")).finish())
};
let props = ();
@@ -318,7 +318,7 @@ mod tests {
let childprops: ExampleProps<'a> = ExampleProps { name: content };
// let childprops: ExampleProps<'a> = ExampleProps { name: content };
ctx.view(move |b: &'a Bump| {
ctx.render(move |b: &'a Bump| {
div(b)
.child(text(props.name))
// .child(text(props.name))
@@ -336,7 +336,7 @@ mod tests {
}
fn child_example<'b>(ctx: Context<'b>, props: &'b ExampleProps) -> DomTree {
ctx.view(move |b| {
ctx.render(move |b| {
div(b)
.child(text(props.name))
//
@@ -346,7 +346,7 @@ mod tests {
static CHILD: FC<ExampleProps> = |ctx, props: &'_ ExampleProps| {
// todo!()
ctx.view(move |b| {
ctx.render(move |b| {
div(b)
.child(text(props.name))
//
@@ -371,7 +371,7 @@ mod tests {
// stored value
// let (text, set_val) = crate::hooks::use_state(&ctx, || "abcd".to_string());
ctx.view(move |b| {
ctx.render(move |b| {
todo!()
// div(b)
// // .child(text(props.name))
+1 -1
View File
@@ -290,7 +290,7 @@ mod tests {
#[test]
fn start_dom() {
let mut dom = VirtualDom::new(|ctx, props| {
ctx.view(|bump| {
ctx.render(|bump| {
use crate::builder::*;
div(bump).child(text("hello, world")).finish()
})