Explorar o código

remove some unused unsafe blocks

Evan Almloff hai 1 ano
pai
achega
717f38a5ec

+ 3 - 3
packages/core/src/diff.rs

@@ -993,7 +993,7 @@ impl VirtualDom {
             .expect("VComponents to always have a scope");
 
         // Remove the component from the dom
-        match unsafe { self.get_scope(scope).unwrap().root_node() } {
+        match self.get_scope(scope).unwrap().root_node() {
             RenderReturn::Ready(t) => self.remove_node(t, gen_muts, to),
             RenderReturn::Aborted(placeholder) => {
                 self.remove_placeholder(placeholder, gen_muts, to)
@@ -1012,7 +1012,7 @@ impl VirtualDom {
             Some(Placeholder(t)) => t.id.get().unwrap(),
             Some(Component(comp)) => {
                 let scope = comp.scope.get().unwrap();
-                match unsafe { self.get_scope(scope).unwrap().root_node() } {
+                match self.get_scope(scope).unwrap().root_node() {
                     RenderReturn::Ready(t) => self.find_first_element(t),
                     _ => todo!("cannot handle nonstandard nodes"),
                 }
@@ -1028,7 +1028,7 @@ impl VirtualDom {
             Some(Placeholder(t)) => t.id.get().unwrap(),
             Some(Component(comp)) => {
                 let scope = comp.scope.get().unwrap();
-                match unsafe { self.get_scope(scope).unwrap().root_node() } {
+                match self.get_scope(scope).unwrap().root_node() {
                     RenderReturn::Ready(t) => self.find_last_element(t),
                     _ => todo!("cannot handle nonstandard nodes"),
                 }

+ 1 - 1
packages/core/src/scope_arena.rs

@@ -34,7 +34,7 @@ impl VirtualDom {
     pub(crate) fn run_scope(&mut self, scope_id: ScopeId) -> RenderReturn {
         self.runtime.scope_stack.borrow_mut().push(scope_id);
 
-        let new_nodes = unsafe {
+        let new_nodes = {
             let scope = &self.scopes[scope_id.0];
 
             let context = scope.context();

+ 1 - 1
packages/core/src/virtual_dom.rs

@@ -549,7 +549,7 @@ impl VirtualDom {
         match unsafe { self.run_scope(ScopeId::ROOT) } {
             // Rebuilding implies we append the created elements to the root
             RenderReturn::Ready(node) => {
-                let m = self.create_scope(ScopeId::ROOT, &node);
+                let m = self.create_scope(ScopeId::ROOT, &node, to);
                 to.append_children(ElementId(0), m);
             }
             // If an error occurs, we should try to render the default error component and context where the error occured