Skip to content

Conversation

Copy link

Copilot AI commented Nov 26, 2025

When <template v-for v-slot> is used, the AST incorrectly keeps both directives on an ELEMENT node instead of creating a FOR node wrapping an ELEMENT with slot directive. This breaks AST consumers like Volar.

<Foo>
  <template v-for="i in 3" v-slot />
</Foo>

Before: ELEMENT(directives: for, slot)
After: FORELEMENT(directives: slot)

Changes

  • transform.ts: Allow v-for structural transform to proceed when v-slot is present (previously skipped all structural directives)
  • vFor.ts:
    • Skip codegen for <template v-for v-slot> (handled by buildSlots)
    • Preserve template element as FOR child when it has v-slot
  • vSlot.ts: Handle FOR nodes containing templates with v-slot in buildSlots

Test

Added vForSlotIssue.spec.ts verifying correct AST structure.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • googlechromelabs.github.io
    • Triggering command: /usr/local/bin/node node install.mjs (dns block)
  • https://storage.googleapis.com/chrome-for-testing-public/142.0.7444.59/linux64/chrome-linux64.zip
    • Triggering command: /usr/local/bin/node node install.mjs (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>compiler-dom create unexpected nodes with v-for + v-slot</issue_title>
<issue_description>### Version
3.0.9

Reproduction link

https://vue-next-template-explorer.netlify.app/#%7B%22src%22%3A%22%3CFoo%3E%5Cn%20%20%3Ctemplate%20v-for%3D%5C%22i%20in%203%5C%22%20%2F%3E%5Cn%20%20%3Ctemplate%20v-for%3D%5C%22i%20in%203%5C%22%20v-slot%20%2F%3E%5Cn%3C%2FFoo%3E%22%2C%22options%22%3A%7B%22mode%22%3A%22module%22%2C%22filename%22%3A%22Foo.vue%22%2C%22prefixIdentifiers%22%3Afalse%2C%22optimizeImports%22%3Afalse%2C%22hoistStatic%22%3Afalse%2C%22cacheHandlers%22%3Afalse%2C%22scopeId%22%3Anull%2C%22inline%22%3Afalse%2C%22ssrCssVars%22%3A%22%7B%20color%20%7D%22%2C%22bindingMetadata%22%3A%7B%22TestComponent%22%3A%22setup-const%22%2C%22setupRef%22%3A%22setup-ref%22%2C%22setupConst%22%3A%22setup-const%22%2C%22setupLet%22%3A%22setup-let%22%2C%22setupMaybeRef%22%3A%22setup-maybe-ref%22%2C%22setupProp%22%3A%22props%22%2C%22vMySetupDir%22%3A%22setup-const%22%7D%7D%7D

Steps to reproduce

Check the console for the AST

What is expected?

AST tree is:

  • ROOT
    • ELEMENT
      • FOR
      • FOR
        • ELEMENT(directives: slot)

What is actually happening?

AST tree is:

  • ROOT
    • ELEMENT
      • FOR
      • ELEMENT(directives: for, slot)

Related: vuejs/language-tools#110

Comments on the Issue (you are @copilot in this section)

@johnsoncodehk Can we change this implement if this is not the design?

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits November 26, 2025 09:59
…mbined

Co-authored-by: johnsoncodehk <16279759+johnsoncodehk@users.noreply.github.com>
Co-authored-by: johnsoncodehk <16279759+johnsoncodehk@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix unexpected nodes creation with v-for and v-slot fix(compiler-core): create FOR node in AST when v-for + v-slot are combined Nov 26, 2025
Copilot AI requested a review from johnsoncodehk November 26, 2025 10:07
Copilot finished work on behalf of johnsoncodehk November 26, 2025 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

compiler-dom create unexpected nodes with v-for + v-slot

2 participants