Passing component to nested slots gives TypeError: Cannot read property 'parentNode' of null
Version
3.0.11
Reproduction link
https://codesandbox.io/s/naughty-carson-95syx?file=/src/App.vue
Steps to reproduce
Click the rendered dropdown button with the
What is expected?
Expect to be able to render arbitrary content, including other components, in the nested slots.
What is actually happening?
When a component is included in the nested slot content, an error is thrown: "TypeError: Cannot read property 'parentNode' of null."
This error goes away and normal behavior is seen when only text is included in the slot.
I am implementing a custom toolbar with buttons that can be passed content to be displayed in a popover. The
Here is a workaround https://codesandbox.io/s/nostalgic-water-cjnrw?file=/src/ControlButton.vue, see the ControlButton.vue
Edit: https://github.com/vuejs/vue-next/issues/1745#issuecomment-669936498
Also, if you are trying to check for presence of a slot, you should do !!$slots.default in the template (don't call it)
Removing && this.$slots.popoverContent()
of the hasPopover
function also works, that's strange...
https://codesandbox.io/s/eloquent-sun-29s91?file=/src/ControlButton.vue
The root cause of the problem is the same as https://github.com/vuejs/vue-next/issues/1745, I am thinking of a solution...
FYI @HcySunYang when using your workaround, the same error re-appeared when using the production build (built with vite). @Alanscut solution (just removing function call) works in both dev and in production build.