浏览代码

PushRoot before adding children

Evan Almloff 3 年之前
父节点
当前提交
43b5a230f0
共有 2 个文件被更改,包括 2 次插入2 次删除
  1. 1 1
      packages/core/src/diff.rs
  2. 1 1
      tests/diffing.rs

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

@@ -423,8 +423,8 @@ impl<'b> DiffState<'b> {
         match (old.children.len(), new.children.len()) {
         match (old.children.len(), new.children.len()) {
             (0, 0) => {}
             (0, 0) => {}
             (0, _) => {
             (0, _) => {
-                let created = self.create_children(new.children);
                 self.mutations.push_root(root);
                 self.mutations.push_root(root);
+                let created = self.create_children(new.children);
                 self.mutations.append_children(created as u32);
                 self.mutations.append_children(created as u32);
             }
             }
             (_, _) => self.diff_children(old.children, new.children),
             (_, _) => self.diff_children(old.children, new.children),

+ 1 - 1
tests/diffing.rs

@@ -749,8 +749,8 @@ fn add_nested_elements() {
     assert_eq!(
     assert_eq!(
         change.edits,
         change.edits,
         [
         [
-            CreateElement { root: 2, tag: "div" },
             PushRoot { root: 1 },
             PushRoot { root: 1 },
+            CreateElement { root: 2, tag: "div" },
             AppendChildren { many: 1 },
             AppendChildren { many: 1 },
         ]
         ]
     );
     );