chore: add todo comment

This commit is contained in:
三咲智子 Kevin Deng 2023-11-24 11:39:49 +08:00
parent 1d5436fbf8
commit 567feccb39
No known key found for this signature in database
GPG Key ID: 69992F2250DFD93E
3 changed files with 38 additions and 20 deletions

View File

@ -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. 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] counter
- [x] simple bindings - [x] simple bindings
- [x] simple events - [x] simple events
@ -23,8 +25,17 @@ PR are welcome! Please create a issue before you start to work on it.
- [ ] `v-pre` - [ ] `v-pre`
- [ ] `v-cloak` - [ ] `v-cloak`
- [ ] `v-memo` - [ ] `v-memo`
- [ ] Fragment
- [ ] Remove DOM API in codegen - [ ] Remove DOM API in codegen
- [ ] Fragment
- [ ] Built-in Components
- [ ] Transition
- [ ] TransitionGroup
- [ ] KeepAlive
- [ ] Teleport
- [ ] Suspense
- [ ] Component
- [ ] runtime
- [ ] compiler
- ... - ...
- [ ] SSR - [ ] SSR
- [ ] Performance & Optimization - [ ] Performance & Optimization

View File

@ -50,6 +50,7 @@ export function generate(
} }
for (const [expr, effects] of Object.entries(ir.effect)) { 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` let scope = `watchEffect(() => {\n`
helpers.add('watchEffect') helpers.add('watchEffect')
for (const effect of effects) { for (const effect of effects) {

View File

@ -134,17 +134,14 @@ export function transform(
vaporHelpers: new Set([]), vaporHelpers: new Set([]),
} }
const ctx = createRootContext(ir, root, options) const ctx = createRootContext(ir, root, options)
transformChildren(ctx, true) transformChildren(ctx)
ctx.registerTemplate() ctx.registerTemplate()
ir.children = ctx.children ir.children = ctx.children
return ir return ir
} }
function transformChildren( function transformChildren(ctx: TransformContext<RootNode | ElementNode>) {
ctx: TransformContext<RootNode | ElementNode>,
root?: boolean,
) {
const { const {
node: { children }, node: { children },
} = ctx } = ctx
@ -177,7 +174,15 @@ function transformChildren(
) )
break break
} }
case 12 satisfies NodeTypes.TEXT_CALL:
// never?
break
default: { default: {
// TODO handle other types
// CompoundExpressionNode
// IfNode
// IfBranchNode
// ForNode
ctx.template += `[type: ${node.type}]` ctx.template += `[type: ${node.type}]`
} }
} }
@ -202,9 +207,9 @@ function transformElement(ctx: TransformContext<ElementNode>) {
props.forEach((prop) => transformProp(prop, ctx)) props.forEach((prop) => transformProp(prop, ctx))
ctx.template += node.isSelfClosing ? '/>' : `>` ctx.template += node.isSelfClosing ? '/>' : `>`
if (children.length > 0) { if (children.length) transformChildren(ctx)
transformChildren(ctx)
} // TODO remove unnecessary close tag
if (!node.isSelfClosing) ctx.template += `</${tag}>` if (!node.isSelfClosing) ctx.template += `</${tag}>`
} }
@ -265,10 +270,10 @@ function transformInterpolation(
element: id, element: id,
}) })
} }
} else { return
// TODO
} }
// TODO
// TODO: CompoundExpressionNode: {{ count + 1 }}
} }
function transformProp( function transformProp(
@ -287,16 +292,17 @@ function transformProp(
} }
if (!node.exp) { if (!node.exp) {
// TODO // TODO: Vue 3.4 supported shorthand syntax
// https://github.com/vuejs/core/pull/9451
return return
} else if (node.exp.type === (8 satisfies NodeTypes.COMPOUND_EXPRESSION)) { } else if (node.exp.type === (8 satisfies NodeTypes.COMPOUND_EXPRESSION)) {
// TODO // TODO: CompoundExpressionNode: :foo="count + 1"
return return
} else if ( } else if (!node.arg) {
!node.arg || // TODO support v-bind="{}"
node.arg.type === (8 satisfies NodeTypes.COMPOUND_EXPRESSION) return
) { } else if (node.arg.type === (8 satisfies NodeTypes.COMPOUND_EXPRESSION)) {
// TODO // TODO support :[foo]="bar"
return 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) { function processExpression(ctx: TransformContext, expr: string) {
if (ctx.options.bindingMetadata?.[expr] === 'setup-ref') { if (ctx.options.bindingMetadata?.[expr] === 'setup-ref') {
expr += '.value' expr += '.value'