core icon indicating copy to clipboard operation
core copied to clipboard

Static slot content vnode's el property remains null after the component is mounted

Open oliverzy opened this issue 3 years ago • 8 comments

Vue version

3.2.40

Link to minimal reproduction

https://sfc.vuejs.org/#eNqNUktu2zAQvcqUG8mARKaflSsbKZoC3QRdtEAXZReqNHbU8BeSshMIukjOkjvlCiEpR0gcIAggQHjz3rxHcmYgX4yhux7JklSusZ3x4ND3Zs1VJ422HgawuCmgd/hTaO9ghI3VErLQlH2eVV+1NAeCsgiiaeQBuKrYZB1MA/Aojag9BgRQRe26artdggD7K0zfhCoWmSo5BkHF5mZSkCm6lLWh/51W4QpDyjsQjpMlpEqsheNEzMmF98YtGeuVudzSRkt2Gjhme+U7iWWr5elH+oF+OgnRzj+tU3Sy/Gf13qENiZwUT8xZKO7QlhZVixbtq2FH2meBR9yL0Jg5cjWGB3h85zcPrwCtznW4EbYFKLz2v7rm8niiXDVaOQ/SbWEV+/PsOwqh4be2on2XLQ5TnVQuLcVqjsgf6Tkpr92NaiBfwGo9zYOxel93fj7B3AMQTbVAKvQ2z85wU/fCQzSGsx/n8E2gROXv726zYkqm7aTJF39O/lIU0WlcvL5yF+/Xw5CuN44VCyhVO2V6D7tS6hbFipPAczJRMSksYfo9X8LxAX5THf4=

Steps to reproduce

See the vue sfc playground link.

What is expected?

Switch Vue version to 3.2.39, the output is the dom element which is correctA. image

What is actually happening?

Switch Vue version to 3.2.40,the output is null which is wrong. image

System Info

No response

Any additional comments?

No response

oliverzy avatar Oct 11 '22 03:10 oliverzy

It should be caused by the change here. https://github.com/vuejs/core/blob/fc5bdb36ed429d6c3c956f373206ce75467adaf3/packages/runtime-core/src/vnode.ts#L738-L744

see #6591

zhangzhonghe avatar Oct 11 '22 04:10 zhangzhonghe

As @zhangzhonghe said, when fixing bug #6591 , @yyx990803 removed the reference to the dom on the hoisted vnodes to avoid memory leaks, you can bind a key to avoid hoisted

<template>
  <Comp><div key='wqewqewq'>
    wqewqewq
    </div></Comp>
</template>

baiwusanyu-c avatar Oct 16 '22 12:10 baiwusanyu-c

This is technically a breaking change, I think the workaround above is not ideal

oliverzy avatar Oct 17 '22 02:10 oliverzy

duplicate of #815

This is not a breaking change!

zhangzhonghe avatar Oct 17 '22 06:10 zhangzhonghe

OK, strictly speaking, it's an undocumented internal api change since 3.2.40. Let's see how can we proceed with this. One of our internal component library relies on this behavior, currently we have to lock the vue version to 3.2.39 for quick fix.

oliverzy avatar Oct 17 '22 07:10 oliverzy

I don't think labeling this as an important bug is warranted. it's essentially an edge case when using an API that's not even public, strictly speaking.

LinusBorg avatar Oct 18 '22 13:10 LinusBorg

I use an only render slots.default component to avoid this bug temporarily.

https://sfc.vuejs.org/#eNqNU9tq20AQ/ZWpKEgGeZVenlzZpCSF9iHkoYU+RHlQpLGtZi/q7spOMPqRfkv/qb/Q2dUlVkLTgEDMnJlz5rJzCD7WNds1GCyC1BS6qi0YtE29ymQlaqUtHEDjOobG4FeurIEW1loJCCkp/DBGnSlR9wBLnOFIHZ4mHS0RkmFR1Dy3SBZA6uJWaVntvAmw/4n+66w0cUjq2SggTcbkIA462bnIa/bDKEnlH1xW1gMmCxbgPc5HpTg7C7bW1maRJI2sbzesUCI5JSzRjbSVwHmpxOk79pa9PyFpY4/9DI2Y32i1N6hJMQviI/KEnDvUc42yRI36WbFHsRPBR9gTUafZZrKlAQwzfvHiYlDyQlFHWMYg8c5+q4rbGDZozxpNivaLNDaXBf5rw9uKl5eS3z+sefAMu85koYgEhNnA0qlH4WfkXMF3pXn5KpxRDI2sjzL+OS3HAqMpXDj2nkY2nA/o2EWUm3tZQDSD5arbdb7PKzv25vmc2/EpjoyrTRRe3TSb63Nc5w234HTh/PICPnEUNII/v3+FcVcYK7uYaHZ1cs2wl59Sras7LP9D5ttgu5w3yF53NO3s+bPYvlkdDn6IbZsmZHlvJevGwm4uVIl8mQWEZ0F/R+NqaFgEec0BdN3QFfmfdzzs7clVTTbqXta0sCnVcWr7F4nMe6E=

van-fe avatar Nov 16 '22 08:11 van-fe