Skip to content

Hydration error with scoped slots #164

Open
vuejs/vue
#11963
@gpanos

Description

@gpanos

Hi all,
There are some issues rendering slotted components and using this module with components auto discovery enabled.
Original issue

I think an example will illustrate the problem better:
Having a simple slotted component:
Let's call it Card.vue

<template>
  <div>
    <div>
      <slot name="title"></slot>
    </div>
    <div>
      <slot name="content"></slot>
    </div>
  </div>
</template>

<script>
export default {}
</script>

Having a simple component let's call it Text.vue

<template>
  <div>
    Random text
  </div>
</template>

<script>
export default {}
</script>

Now using these components together throws a hydration error:

    <Card>
        <template #title>
          <Text />
        </template>
        <template #content>
          <Text />
          <Text />
        </template>
    </Card>

    <Card>
        <template #title>
          <Text />
        </template>
        <template #content>
          <Text />
          <Text />
        </template>
    </Card>
[Vue warn]: The client-side rendered virtual DOM tree is not matching server-rendered content. This is likely caused by incorrect HTML markup, for example nesting block-level elements inside <p>, or missing <tbody>.

The really weird part is that using the same markup just once doesn't throw an error.

    <Card>
        <template #title>
          <Text />
        </template>
        <template #content>
          <Text />
          <Text />
        </template>
    </Card>

No error

Original issue
Sandbox to reproduce
Sandbox to prove it's working with simple vue-cli and vue-server-render application
Sandbox to prove it's working in Nuxt without component auto discovery
Related issues

Thanks a lot in advance everyone,
I am trying to dig dipper into this and help as much as I can so let me know if I can provide anything more to help you out.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingupstream

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions