diff --git a/packages/core/src/create.rs b/packages/core/src/create.rs index f332760a5..17f3229d6 100644 --- a/packages/core/src/create.rs +++ b/packages/core/src/create.rs @@ -65,11 +65,8 @@ impl<'b> VirtualDom { /// Create a new template [`VNode`] and write it to the [`Mutations`] buffer. /// /// This method pushes the ScopeID to the internal scopestack and returns the number of nodes created. - pub(crate) fn create_scope(&mut self, scope: ScopeId, template: &'b VNode<'b>) -> usize { - self.runtime.scope_stack.borrow_mut().push(scope); - let out = self.create(template); - self.runtime.scope_stack.borrow_mut().pop(); - out + pub(crate) fn create_scope(&mut self, _scope: ScopeId, template: &'b VNode<'b>) -> usize { + self.create(template) } /// Create this template and write its mutations diff --git a/packages/core/src/diff.rs b/packages/core/src/diff.rs index e3ca19c3a..270c81730 100644 --- a/packages/core/src/diff.rs +++ b/packages/core/src/diff.rs @@ -15,7 +15,6 @@ use DynamicNode::*; impl<'b> VirtualDom { pub(super) fn diff_scope(&mut self, scope: ScopeId) { - self.runtime.scope_stack.borrow_mut().push(scope); let scope_state = &mut self.get_scope(scope).unwrap(); unsafe { // Load the old and new bump arenas @@ -46,7 +45,6 @@ impl<'b> VirtualDom { (Aborted(l), Ready(r)) => self.replace_placeholder(l, [r]), }; } - self.runtime.scope_stack.borrow_mut().pop(); } fn diff_ok_to_err(&mut self, l: &'b VNode<'b>, p: &'b VPlaceholder) { diff --git a/packages/core/src/runtime.rs b/packages/core/src/runtime.rs index 839a055df..1ca778edd 100644 --- a/packages/core/src/runtime.rs +++ b/packages/core/src/runtime.rs @@ -45,7 +45,7 @@ pub struct Runtime { pub(crate) scope_contexts: RefCell>>, pub(crate) scheduler: Rc, - // While diffing we need some sort of way of breaking off a stream of suspended mutations. + // We use this to track the current scope pub(crate) scope_stack: RefCell>, } diff --git a/packages/core/src/scope_arena.rs b/packages/core/src/scope_arena.rs index 2d5e09b0b..58fe97a90 100644 --- a/packages/core/src/scope_arena.rs +++ b/packages/core/src/scope_arena.rs @@ -46,6 +46,7 @@ impl VirtualDom { } pub(crate) fn run_scope(&mut self, scope_id: ScopeId) -> &RenderReturn { + self.runtime.scope_stack.borrow_mut().push(scope_id); // Cycle to the next frame and then reset it // This breaks any latent references, invalidating every pointer referencing into it. // Remove all the outdated listeners @@ -94,6 +95,10 @@ impl VirtualDom { } // rebind the lifetime now that its stored internally - unsafe { allocated.extend_lifetime_ref() } + let result = unsafe { allocated.extend_lifetime_ref() }; + + self.runtime.scope_stack.borrow_mut().pop(); + + result } }