Skip to content

fix: make scoped slots rendering consistent for stubs - #2068

Merged
lmiller1990 merged 1 commit into
vuejs:devfrom
xanf:xanf-fix-shallow-mount-weird-stubs
Jun 5, 2023
Merged

fix: make scoped slots rendering consistent for stubs#2068
lmiller1990 merged 1 commit into
vuejs:devfrom
xanf:xanf-fix-shallow-mount-weird-stubs

Conversation

@xanf

@xanf xanf commented Apr 30, 2023

Copy link
Copy Markdown
Contributor

This MR fixes extremely weird stubbing behavior. Currently scoped slot stubs will be rendered only for components, which are located at root level of other component. Basically:

<some-cmp>foo</some-cmp>

will have scoped slots rendered on stub, while

<div><some-cmp>foo</some-cmp>

will have only default slot rendered.
This is caused because slot lookup was performed on parent instead of instance itself

What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Build-related changes
  • Other, please describe:

Does this PR introduce a breaking change? (check one)

  • Yes
  • No

This is definitely a breaking change: now we try to render more scoped slots than before. Basically, that means that some tests which rely that slots were not previously rendered will fail. However, I see this definitely a better thing than current confusing approach

The PR fulfills these requirements:

If adding a new feature, the PR's description includes:

  • A convincing reason for adding this feature (to avoid wasting your time, it's best to open a suggestion issue first and wait for approval before working on it)

Other information:

@netlify

netlify Bot commented Apr 30, 2023

Copy link
Copy Markdown

Deploy Preview for vue-test-utils-v1 ready!

Name Link
🔨 Latest commit 57a88a1
🔍 Latest deploy log https://app.netlify.com/sites/vue-test-utils-v1/deploys/644ded31b3d42c00078a2e3e
😎 Deploy Preview https://deploy-preview-2068--vue-test-utils-v1.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

getScopedSlotRenderFunctions(this)
.map(x => {
let result = null
try {

@xanf xanf Apr 30, 2023

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This try catch is best-effort attempt to mitigate migration from existing state. Since we're now rendering more scoped slots on stubs than previously there is higher chance of blow up.

While it might create some confusion (hey, some my slots are rendering, some are not) considering close EOL of Vue.js 2 I'm thinking of this one as acceptable trade-off

For example at GitLab codebase, without try - catch this MR entirely blows over 700 tests, with try catch - less than 100, however I'm open for discussion on removing it

@lmiller1990

Copy link
Copy Markdown
Member

Sorry, just saw this one @xanf. I'll review it now.

@lmiller1990
lmiller1990 merged commit 6b73d4b into vuejs:dev Jun 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants