[SSR Teleport] An error occurred when the disabled attribute has different values in multiple Teleport
Vue version
3.2.45
Link to minimal reproduction
Steps to reproduce
There is a difference between local and the Vue SFC Playground
local
- 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>
- 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>
- 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
the wrong DOM was matched on the client
System Info
No response
Any additional comments?
No response
你的意思是给容器添加<!--teleport anchor--><button>Button</button><!--teleport anchor-->
但最终渲染到浏览器少了一个 <!--teleport anchor-->
吗
reproduce
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 (target as TeleportTargetElement)._lpa || target.firstChild
duplicate of https://github.com/vuejs/core/issues/6152 ?