diff --git a/packages/core/src/scope.rs b/packages/core/src/scope.rs index 5dcde5a2e..821e3d9cb 100644 --- a/packages/core/src/scope.rs +++ b/packages/core/src/scope.rs @@ -84,25 +84,14 @@ impl Scope { /// /// Props is ?Sized because we borrow the props and don't need to know the size. P (sized) is used as a marker (unsized) pub fn run_scope<'b>(&'b mut self) -> Result<()> { - // pub fn run_scope<'bump>(&'bump mut self) -> Result<()> { - // let frame = { - { - let frame = self.frames.next(); - frame.bump.reset(); - } - // frame - // }; - // self.new_frame() + // cycle to the next frame and then reset it + // this breaks any latent references + self.frames.next().bump.reset(); let ctx = Context { - // arena: &self.hook_arena, - // hooks: &self.hooks, - // bump: &frame.bump, idx: 0.into(), _p: PhantomData {}, scope: self, - // scope: self.myidx, - // listeners: &self.listeners, }; let caller = self.caller.upgrade().expect("Failed to get caller"); @@ -118,14 +107,11 @@ impl Scope { - The VNode has a private API and can only be used from accessors. - Public API cannot drop or destructure VNode */ - let new_head = unsafe { - // frame.head_node = unsafe { - // // use the same type, just manipulate the lifetime + // use the same type, just manipulate the lifetime type ComComp<'c> = Rc>; let caller = std::mem::transmute::, ComComp<'b>>(caller); - let r: DomTree = (caller.as_ref())(ctx); - r + (caller.as_ref())(ctx) }; self.frames.cur_frame_mut().head_node = new_head.root; diff --git a/packages/core/src/virtual_dom.rs b/packages/core/src/virtual_dom.rs index a0cc77c78..091f4731c 100644 --- a/packages/core/src/virtual_dom.rs +++ b/packages/core/src/virtual_dom.rs @@ -229,3 +229,20 @@ impl UpdateFunnel { } } } + +macro_rules! UpdateFunnel { + (root: $root:expr) => { + VirtualDom::new($root) + }; +} + +// #[test] +// fn test_new_vdom() { +// let dom = UpdateFunnel! { +// root: |ctx, props| { +// ctx.render(rsx!{ + +// }) +// } +// }; +// } diff --git a/packages/web/examples/todomvc_simple.rs b/packages/web/examples/todomvc_simple.rs index 053a81348..b8077bb8e 100644 --- a/packages/web/examples/todomvc_simple.rs +++ b/packages/web/examples/todomvc_simple.rs @@ -79,10 +79,12 @@ pub fn TodoList(ctx: Context, props: &()) -> DomTree { FilterState::Completed => item.checked, }) .map(|(id, item)| { - rsx!(TodoEntry { - key: "{order}", - item: item.clone() - }) + TodoEntry!(); + todo!() + // rsx!(TodoEntry { + // key: "{order}", + // item: item.clone() + // }) }) } @@ -99,9 +101,24 @@ pub struct TodoEntryProps { item: Rc, } -pub fn TodoEntry(ctx: Context, props: &TodoEntryProps) -> DomTree { +mod mac { + #[macro_export] + macro_rules! TodoEntry { + () => {}; + } +} + +// pub fn TodoEntry(ctx: Context, props: &TodoEntryProps) -> DomTree { +// #[inline_props] +pub fn TodoEntry( + ctx: Context, + baller: &impl Fn() -> (), + caller: &impl Fn() -> (), + todo: &Rc, +) -> DomTree { + // pub fn TodoEntry(ctx: Context, todo: &Rc) -> DomTree { let (is_editing, set_is_editing) = use_state(&ctx, || false); - let todo = &props.item; + // let todo = &props.item; ctx.render(rsx! ( li { @@ -111,11 +128,11 @@ pub fn TodoEntry(ctx: Context, props: &TodoEntryProps) -> DomTree { type: "checkbox" "{todo.checked}" } - {is_editing.then(|| rsx!( + {is_editing.then(|| rsx!{ input { value: "{contents}" } - ))} + })} } )) }