Skip to content

Attribute are not applied to a child component when SSR-ed with compiler option whitespace: 'preserve' #8072

Closed

Description

@bill876

Vue version

3.2.47

Link to minimal reproduction

https://stackblitz.com/edit/vue-ssr-repro-xlrnx1

Steps to reproduce

Open the homepage in the reproduction.
Look at the "Register now!" html.

What is expected?

The "Register now!" link has class wide and is 500px wide.

What is actually happening?

The "Register now!" link does not have class wide.

System Info

No response

Any additional comments?

The "Register now!" link (from component MyCta.vue) should have attributes that are set from the parent component MyWideCta.vue.
One example is class wide, which should make the link box 500px wide.

This indeed happens most of the time.

However, if
(1) the root element in MyCta.vue can be one of multiple, controlled with v-if
AND (2) compilerOptions has whitespace: 'preserve' set,
the server-rendered result does not have the attributes from the parent applied to MyCta root element.

The client rendering works as expected, which can be seen by clicking on another page link and back to home.

Changing MyCta.vue to always have a single root element, or removing whitespace: 'preserve' option, makes the ssr result the same as client-rendered result.

Activity

  1. jonysk commented on May 23, 2024

    @jonysk

    any updates or plans to resolve this issue?

  2. added
    🔨 p3-minor-bug
    on Nov 1, 2024
  3. added a commit that references this issue on Dec 18, 2025
    4783118
  4. locked and limited conversation to collaborators on Jan 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    🔨 p3-minor-bugscope: ssr

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions