Skip to content

$scopedSlots is empty until render() #11714

Open
@KaelWD

Description

@KaelWD

Version

2.6.11

Reproduction link

https://codepen.io/kaelwd/pen/rNLNYGL?editors=1011

Steps to reproduce

Open the console

What is expected?

"ScopedComponent beforeMount" true to be logged

What is actually happening?

"ScopedComponent beforeMount" false


This was discovered in vuetify: vuetifyjs/vuetify#11533 (comment)

The real setup is a watcher on a computed property that depends on $slots. The watcher is called before mount to get an initial value, causing the computed property to be executed and return an incorrect value.

Minimal example with the watcher if that helps: https://codepen.io/kaelwd/pen/vYKYWbV?editors=1010

This works as expected in vue 3: https://codepen.io/kaelwd/pen/gOMOXoB?editors=1011

The bug seems to have existed since scoped slots were introduced in v2.1, but it wasn't a problem here until v2.6 when scoped slots started being used everywhere with v-slot

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions