antfu/vue-reuse-template

ReuseTemplate error

hminghe opened this issue · 2 comments

Describe the bug

ReuseTemplate is slot

<template>
  <Comp >
    <!-- ERROR -->
    <!-- getCurrentInstance().parent === <Comp /> -->
    <ReuseTemplate />
  </Comp>
 
  <!-- getCurrentInstance().parent === CurrentComp   -->
  <ReuseTemplate />
</template>

Reproduction

https://play.vuejs.org/#eNqVUctqwzAQ/JWNL3Yglum12IGSS3sthV4MwTgbY9ALaR0oIf9eSVbcuglue9PsY3ZmdE6etGanAZPHpLSt6TWBRRr0tpa90MoQnMHgES5wNEpA6kbTqbVTQsc6KzzwTF/tVxwsvqHQvCGc5mbVuFDLshivu7sOUGw7BFCGM+HpwCrPoUPaDcagpBdpqZEtZmumG1+AqqriRrGFPL+uzbUUI3HQ7J8B/YnZxfWN+A5tWUzik01yDeV/8dayVe48CNtB5ftZ+oycK3hXhh9W6Xo5r0N/Co+aSssVRbcArRMz+p4mfsi9+ZtfdG/uBHbjZXSjODKuumwhYUYfGtl+LxuByxa9k4e5+Msnq5D1uA==

System Info

G

Used Package Manager

pnpm

Validations

  • Follow our Code of Conduct
  • Read the Contributing Guide.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.

我暂时想到的只有, 删除 DefineTemplateReuseTemplate 两个组件, 只用 createReusableTemplate 定义,createReusableTemplate 时,内部自己维护 TemplateRegistry

antfu commented

Nice catch. I thought .parent would be the component creating it.

And yeah, I have to remove the default component to fix it for now. I will try to explore other solutions in the mean time