Skip to content

compiler-sfc: HTML comment nodes are missing from element children when the element is a Vue transition #9047

@Sidnioulz

Description

@Sidnioulz

Vue version

3.3.4

Link to minimal reproduction

https://github.com/Sidnioulz/vue-sfcmod/blob/feat/template/src/template/__tests__/stringify.spec.ts

Steps to reproduce

  1. Use compileTemplate to compile with the following pattern: <Transition><!-- Comment --><input /></Transition>
  2. Explore the AST
  3. Notice the absence of a children node for the comment

What is expected?

There should be a node in the children with type 3 / COMMENT, which contains the comment.

What is actually happening?

It seems that when the element node is a Vue transition, specifically, comment nodes are missing. TransitionGroup works fine, though.

System Info

No response

Any additional comments?

I'm writing a codemod engine for Vue templates and this issue prevents me from preserving comments in templates.

For repro, I have a unit test suite with a test named 'Comment inside transition'. It may have been merged to main by the time you read this, though.

Relevant code in core: https://github.com/vuejs/core/blob/main/packages/compiler-dom/__tests__/transforms/Transition.spec.ts#L150. This is intentional, though I don't understand what the harm is in preserving comments.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions