Browse Source

fix: root

三咲智子 Kevin Deng 2 năm trước cách đây
mục cha
commit
f1e5bee7d5

+ 9 - 9
packages/compiler-vapor/__tests__/__snapshots__/compile.test.ts.snap

@@ -13,7 +13,7 @@ export function render() {
         1: [n3],
       },
     ],
-  } = children(root);
+  } = children(n0);
   const n2 = createTextNode(count.value);
   insert(n2, n1, n3);
   watchEffect(() => {
@@ -32,7 +32,7 @@ export function render() {
   const n0 = t0();
   const {
     0: [n1],
-  } = children(root);
+  } = children(n0);
   watchEffect(() => {
     setAttr(n1, 'id', undefined, id.value);
   });
@@ -49,7 +49,7 @@ export function render() {
   const n0 = t0();
   const {
     0: [n1],
-  } = children(root);
+  } = children(n0);
   watchEffect(() => {
     setHtml(n1, undefined, '');
   });
@@ -66,7 +66,7 @@ export function render() {
   const n0 = t0();
   const {
     0: [n1],
-  } = children(root);
+  } = children(n0);
   watchEffect(() => {
     setHtml(n1, undefined, code.value);
   });
@@ -83,7 +83,7 @@ export function render() {
   const n0 = t0();
   const {
     0: [n1],
-  } = children(root);
+  } = children(n0);
   watchEffect(() => {
     on(n1, 'click', handleClick);
   });
@@ -100,7 +100,7 @@ export function render() {
   const n0 = t0();
   const {
     0: [n1],
-  } = children(root);
+  } = children(n0);
   watchEffect(() => {
     setAttr(n1, 'id', undefined, foo);
   });
@@ -121,7 +121,7 @@ export function render() {
         1: [n3],
       },
     ],
-  } = children(root);
+  } = children(n0);
   const n2 = createTextNode(msg.value);
   insert(n2, n1, 0 /* InsertPosition.FIRST */);
   setText(n2, undefined, msg.value);
@@ -139,7 +139,7 @@ export function render() {
   const n0 = t0();
   const {
     0: [n1],
-  } = children(root);
+  } = children(n0);
   watchEffect(() => {
     setText(n1, undefined, '');
   });
@@ -156,7 +156,7 @@ export function render() {
   const n0 = t0();
   const {
     0: [n1],
-  } = children(root);
+  } = children(n0);
   watchEffect(() => {
     setText(n1, undefined, str.value);
   });

+ 1 - 1
packages/compiler-vapor/__tests__/__snapshots__/fixtures.test.ts.snap

@@ -20,7 +20,7 @@ const increment = () => count.value++
 
 return (() => {
 const n0 = t0()
-const { 1: [n1], 2: [n3], 3: [n5], 4: [n6], 6: [n7],} = children(root)
+const { 1: [n1], 2: [n3], 3: [n5], 4: [n6], 6: [n7],} = children(n0)
 const n2 = createTextNode(count.value)
 insert(n2, n1)
 const n4 = createTextNode(double.value)

+ 3 - 1
packages/compiler-vapor/src/generate.ts

@@ -30,7 +30,9 @@ export function generate(
   {
     code += `const n${ir.children.id} = t0()\n`
     if (Object.keys(ir.children.children).length) {
-      code += `const {${genChildren(ir.children.children)}} = children(root)\n`
+      code += `const {${genChildren(ir.children.children)}} = children(n${
+        ir.children.id
+      })\n`
       vaporHelpers.add('children')
     }