Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SSR Teleport] An error occurred when the disabled attribute has different values in multiple Teleport #7169

Closed
tolking opened this issue Nov 18, 2022 · 6 comments

Comments

@tolking
Copy link
Contributor

tolking commented Nov 18, 2022

Vue version

3.2.45

Link to minimal reproduction

https://sfc.vuejs.org/#__DEV____SSR__eNp9kM1uwyAQhF8Fba8x3C1qqX0OLna8bYnMj5bFjRT53bu4jlQ1Uk4ww8wH7A3ectZrRejBljP5zKog1zy4aM2vIVsRjCEvI6MopezsV+XnVwdTujoYrBFjz8kZ44I5EStOEnjZE6qffRmnBVuHqaKUWljieWC8sjXtSpHmXn+Gu3enypzi8L4v1hzygdPE8Xo4gQ/N7sKY9aWkKD+/tYY7DoqDXu1O82Q0TTv4Ys6lN6Z8nNu8LkUn+jSy01Qj+4AaS+gmSt8FScAOTn8YRswVqSOMMxLSM+a/6AO3YTcXN9h+AJ+JmU4=

Steps to reproduce

There is a difference between local and the Vue SFC Playground

local

  1. input
<script setup>
</script>

<template>
  <div id="box"></div>

  <teleport to="#box" :disabled="true">
    <p>text</p>
  </teleport>

  <teleport to="#box">
    <button>Button</button>
  </teleport>
</template>
  1. inject the teleport markup into the correct location in final page HTML

// entry-server.js

const ctx = {}
const html = await renderToString(app, ctx)

console.log(ctx.teleports) // { '#box': '<!--teleport anchor--><button>Button</button><!--teleport anchor-->' }

then modify the content of #box to

<div id="box"><!--teleport anchor--><button>Button</button><!--teleport anchor--></div>
  1. hydration error on the client
<div id="box"><button>Button</button><button>Button</button><!--teleport anchor--></div>

What is expected?

render the content correctly

What is actually happening?

[Vue warn]: Hydration children mismatch in

: server rendered element contains fewer child nodes than client vdom.

the wrong DOM was matched on the client

System Info

No response

Any additional comments?

No response

@baiwusanyu-c
Copy link
Member

baiwusanyu-c commented Nov 18, 2022

你的意思是给容器添加<!--teleport anchor--><button>Button</button><!--teleport anchor-->
但最终渲染到浏览器少了一个 <!--teleport anchor-->
reproduce

@baiwusanyu-c
Copy link
Member

I think this usage does not conform to the documentation. It is pointed out in the documentation that when rendering a teleport in ssr, its target container should only contain the rendered content of the teleport, that is, the initial container should not contain child nodes
image
(target as TeleportTargetElement)._lpa || target.firstChild

@tolking
Copy link
Contributor Author

tolking commented Nov 18, 2022

Replace the teleport content when handling during SSR.

@edison1105
Copy link
Member

duplicate of #6152 ?

@tolking
Copy link
Contributor Author

tolking commented Nov 22, 2022

duplicate of #6152 ?

I feel that the reasons for the two issues are different

@tolking
Copy link
Contributor Author

tolking commented Sep 1, 2024

I feel like the problem has been fixed Link

@tolking tolking closed this as completed Sep 1, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Sep 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants