Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[docs]: improve slot scope auto exposing "params" behaviour #1924

Merged

Conversation

renatodeleao
Copy link
Contributor

@renatodeleao renatodeleao commented Dec 27, 2022

Hello again 👋
I had a bunch of specs that rely on the previous VTU1 behaviour, where slot scope was auto-exposed as a props object for string templates and realised that in VTU2 they are exposed as params

if (!hasWrappingTemplate) {
template = `<template #default="params">${template}</template>`
}

While VTU1 docs mention that behaviour, VTU2 docs didn't explicitly do it as the only example provided used an <template #scope="params"> which doesn't document the implicit behaviour if not providing a wrapping <template> tag.

Update both main docs and migration guide, since I believe this is a common bump in the road while migrating codebases.

As always feel free to edit the writing style and examples to suite the rest of the docs.
Cheers ✌️

https://github.com/vuejs/test-utils/blob/39d86ad5abe71bac8d76c5b82f11f30225cf8673/src/utils/compileSlots.ts#L10

The only example provided used an explicit #default="params", but it doesn't mention that if you don't explicitly wrap it, the slot scope becomes also available as params. In VTU1, they were exposed as props, so i think it's better to be explicit about it.
@netlify
Copy link

netlify bot commented Dec 27, 2022

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

Name Link
🔨 Latest commit dfce58e
🔍 Latest deploy log https://app.netlify.com/sites/vue-test-utils-docs/deploys/63ab1473388f9e00082d05fd
😎 Deploy Preview https://deploy-preview-1924--vue-test-utils-docs.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.

Copy link
Member

@cexbrayat cexbrayat left a comment

Choose a reason for hiding this comment

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

Thanks @renatodeleao 👍

@cexbrayat cexbrayat merged commit 802c7e4 into vuejs:main Dec 28, 2022
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.

None yet

2 participants