]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
chore: add todo comment
author三咲智子 Kevin Deng <sxzz@sxzz.moe>
Fri, 24 Nov 2023 03:39:49 +0000 (11:39 +0800)
committer三咲智子 Kevin Deng <sxzz@sxzz.moe>
Fri, 24 Nov 2023 03:42:16 +0000 (11:42 +0800)
README.md
packages/compiler-vapor/src/generate.ts
packages/compiler-vapor/src/transform.ts

index c68d3e0b992332363bc819e38f3b2a7c1ec23c83..3f7569ed3dc08dc286a6c32c20c63bcbd318b29f 100644 (file)
--- a/README.md
+++ b/README.md
@@ -6,6 +6,8 @@ This repository is a fork of [vuejs/core](https://github.com/vuejs/core) and is
 
 PR are welcome! Please create a issue before you start to work on it.
 
+See the To-do list below or `// TODO` comments in code (`compiler-vapor` and `runtime-vapor` packages).
+
 - [x] counter
   - [x] simple bindings
   - [x] simple events
@@ -23,8 +25,17 @@ PR are welcome! Please create a issue before you start to work on it.
   - [ ] `v-pre`
   - [ ] `v-cloak`
   - [ ] `v-memo`
-- [ ] Fragment
 - [ ] Remove DOM API in codegen
+- [ ] Fragment
+- [ ] Built-in Components
+  - [ ] Transition
+  - [ ] TransitionGroup
+  - [ ] KeepAlive
+  - [ ] Teleport
+  - [ ] Suspense
+- [ ] Component
+  - [ ] runtime
+  - [ ] compiler
 - ...
 - [ ] SSR
 - [ ] Performance & Optimization
index 153fe033eadd6d68a4f10730510494d9c5a454a8..0a64b732d7617c165c396e6f68c8a554c134ad0e 100644 (file)
@@ -50,6 +50,7 @@ export function generate(
   }
 
   for (const [expr, effects] of Object.entries(ir.effect)) {
+    // TODO don't use watchEffect from vue/core, implement `effect` function in runtime-vapor package
     let scope = `watchEffect(() => {\n`
     helpers.add('watchEffect')
     for (const effect of effects) {
index 270ee758830165c2f311332220e0950a9f819333..e2fe911a582aa9163a6c3d4d884862df392eee15 100644 (file)
@@ -134,17 +134,14 @@ export function transform(
     vaporHelpers: new Set([]),
   }
   const ctx = createRootContext(ir, root, options)
-  transformChildren(ctx, true)
+  transformChildren(ctx)
   ctx.registerTemplate()
   ir.children = ctx.children
 
   return ir
 }
 
-function transformChildren(
-  ctx: TransformContext<RootNode | ElementNode>,
-  root?: boolean,
-) {
+function transformChildren(ctx: TransformContext<RootNode | ElementNode>) {
   const {
     node: { children },
   } = ctx
@@ -177,7 +174,15 @@ function transformChildren(
         )
         break
       }
+      case 12 satisfies NodeTypes.TEXT_CALL:
+        // never?
+        break
       default: {
+        // TODO handle other types
+        // CompoundExpressionNode
+        // IfNode
+        // IfBranchNode
+        // ForNode
         ctx.template += `[type: ${node.type}]`
       }
     }
@@ -202,9 +207,9 @@ function transformElement(ctx: TransformContext<ElementNode>) {
   props.forEach((prop) => transformProp(prop, ctx))
   ctx.template += node.isSelfClosing ? '/>' : `>`
 
-  if (children.length > 0) {
-    transformChildren(ctx)
-  }
+  if (children.length) transformChildren(ctx)
+
+  // TODO remove unnecessary close tag
   if (!node.isSelfClosing) ctx.template += `</${tag}>`
 }
 
@@ -265,10 +270,10 @@ function transformInterpolation(
         element: id,
       })
     }
-  } else {
-    // TODO
+    return
   }
-  // TODO
+
+  // TODO: CompoundExpressionNode: {{ count + 1 }}
 }
 
 function transformProp(
@@ -287,16 +292,17 @@ function transformProp(
   }
 
   if (!node.exp) {
-    // TODO
+    // TODO: Vue 3.4 supported shorthand syntax
+    // https://github.com/vuejs/core/pull/9451
     return
   } else if (node.exp.type === (8 satisfies NodeTypes.COMPOUND_EXPRESSION)) {
-    // TODO
+    // TODO: CompoundExpressionNode: :foo="count + 1"
+    return
+  } else if (!node.arg) {
+    // TODO support v-bind="{}"
     return
-  } else if (
-    !node.arg ||
-    node.arg.type === (8 satisfies NodeTypes.COMPOUND_EXPRESSION)
-  ) {
-    // TODO
+  } else if (node.arg.type === (8 satisfies NodeTypes.COMPOUND_EXPRESSION)) {
+    // TODO support :[foo]="bar"
     return
   }
 
@@ -319,7 +325,7 @@ function transformProp(
   }
 }
 
-// TODO: reference packages/compiler-core/src/transforms/transformExpression.ts
+// TODO: reuse packages/compiler-core/src/transforms/transformExpression.ts
 function processExpression(ctx: TransformContext, expr: string) {
   if (ctx.options.bindingMetadata?.[expr] === 'setup-ref') {
     expr += '.value'