`compiler-dom` create unexpected nodes with `v-for` + `v-slot`
Version
3.0.9
Reproduction link
Steps to reproduce
Check the console for the AST
What is expected?
AST tree is:
- ROOT
- ELEMENT
- FOR
- FOR
- ELEMENT(directives: slot)
- ELEMENT
What is actually happening?
AST tree is:
- ROOT
- ELEMENT
- FOR
- ELEMENT(directives: for, slot)
- ELEMENT
This seems to be intentional. With or without v-slot
determines whether it needs to be processed by the vFor
transform, so in essence, they are treated differently. We can see the details here https://github.com/vuejs/vue-next/blob/master/packages/compiler-core/src/transform.ts#L463-L465
<template v-for="..." v-slot>
generates code like createSlots({ ... })
since it's dynamically generated slots. In this case the codegen tree is the source of truth and the original AST is left untouched. We can technically adjust the behavior, but it will solely be for external tooling and actually risks breaking existing compiler logic. I think it's better to keep the behavior and special case it in Volar.