Skip to content

[Vapor]: A compilation error occurs when an element cannot be used as a direct child #14392

@jackma9604

Description

@jackma9604

Vue version

3.6.0-beta.5

Link to minimal reproduction

https://play.vuejs.org/#eNp9UcFOwzAM/ZUol4I0WqQBh6lMArQDHAABx0ioa72SkSZRkpZJVf8dO93KDmiX5Nnv2X5Oen5nbdq1wBc896WTNjAPobWsK6xxS6Flg3dgPXOwmbGBbZxpWIIVidCl0T6wxtfsluizBGFyLrTQeTY2wwYYBGisKgJgxFgeirUaIQU0gxDhatn3sd0w5BlGe022FyGYSvNKdss8o5OmHU3gMx48OtvIOt16o3GznioEL01jpQL3YoNE54IvWGSIK5QyP08xF1wLs0O+/ILy+5/81u8oJ/irAw+uA8EnLhSuhjDSq/dn2CGeyMZUrUL1CfINvFEteRxl962u0PaRLrp9jD8jdf3hV7sA2h+WIqOkHKJecPyshxOr/9mdp1exTugBX/GzA0c98QHn6U16ebGGUKTXfPgFRpu3Sw==

Steps to reproduce

opening the link prompts an error.

What is expected?

correctly render {{ msg }}!

What is actually happening?

Console prompt error: Cannot read properties of null (reading 'firstChild')

System Info

System:
    OS: Windows 11 10.0.26100
    CPU: (16) x64 Intel(R) Core(TM) Ultra 7 255H
    Memory: 16.59 GB / 31.43 GB
  Binaries:
    Node: 22.18.0 - D:\Document\nodejs\node.EXE
    npm: 10.9.3 - D:\Document\nodejs\npm.CMD
    pnpm: 10.28.2 - D:\Document\nodejs\pnpm.CMD
  Browsers:
    Chrome: 144.0.7559.110
    Edge: Chromium (140.0.3485.54)

Any additional comments?

After investigation, it was found that the problem occurred here
Please guide me on how to make the modifications. I am more than happy to provide Pr.

if (
context.parent &&
context.parent.node.type === NodeTypes.ELEMENT &&
!isValidHTMLNesting(context.parent.node.tag, tag)
) {
context.reference()
context.dynamic.template = context.pushTemplate(template)
context.dynamic.flags |= DynamicFlag.INSERT | DynamicFlag.NON_TEMPLATE
} else {
context.template += template
}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    🔨 p3-minor-bugPriority 3: this fixes a bug, but is an edge case that only affects very specific usage.scope: vaporrelated to vapor mode

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions