Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

fix(nuxt): pass params to client-only slot #6584

Merged
merged 5 commits into from
Aug 17, 2022
Merged

Conversation

huang-julien
Copy link
Member

πŸ”— Linked issue

resolve nuxt/nuxt#14563

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

nuxt/nuxt#14563 Boom.client component compilation: SFC playground (See SSR part line 33)

In #6165 the params of the setupState (when it is a function) were ignored.

: () => {
return mounted$.value
// use Fragment to avoid oldChildren is null issue
? h(Fragment, null, [h(setupState(props, ctx), ctx.attrs)])

This PR make the setupState render function reproduce the same behavior when overriding the render option of the component here:

if (_render) {
// override the component render (non script setup component)
component.render = (ctx, ...args) => {
return ctx.mounted$
? h(Fragment, null, [h(_render(ctx, ...args), ctx.$attrs ?? ctx._.attrs)])
: h('div', ctx.$attrs ?? ctx._.attrs)
}

You can test this here https://github.com/huang-julien/nuxt-3/tree/test/client-slot-fix

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@netlify
Copy link

netlify bot commented Aug 12, 2022

βœ… Deploy Preview for nuxt3-docs ready!

Name Link
πŸ”¨ Latest commit d39fc4e
πŸ” Latest deploy log https://app.netlify.com/sites/nuxt3-docs/deploys/62fba45f87e58e00092717f7
😎 Deploy Preview https://deploy-preview-6584--nuxt3-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.

@danielroe
Copy link
Member

You are quick!

@huang-julien
Copy link
Member Author

@danielroe thank you! πŸ‘

@pi0 pi0 changed the title fix(nuxt): fix client-only setupState param fix(nuxt): pass params to client-only slot Aug 12, 2022
@pi0
Copy link
Member

pi0 commented Aug 12, 2022

Thanks for the quick fix! I'm wondering if we could add a test page to basic fixture to ensure this behavior keeps working.

@huang-julien
Copy link
Member Author

Thanks for the quick fix! I'm wondering if we could add a test page to basic fixture to ensure this behavior keeps working.

yes i think so, i can do it if you want (monday). I'm not sure about this but does nuxt test utils compile the SFCs to simulate a behavior in prod ?

2 different SFC needs to be tested:

  • SFC with a setup script (attrs, props ...)
  • SFC without setup script exporting an object (attrs, props ...)

@pi0
Copy link
Member

pi0 commented Aug 13, 2022

does nuxt test utils compile the SFCs to simulate a behavior in prod ?

Yes. test fixture is being compiled and built before running tests. We can have a dedicated page for test suite.

@huang-julien huang-julien marked this pull request as draft August 15, 2022 18:46
@huang-julien
Copy link
Member Author

huang-julien commented Aug 15, 2022

@pi0 I might have an issue with the tests. The ClientOnlySetupScript.client.vue component in test/fixtures/basic has a different behavior in tests compared to the built env. The attributes are not being rendered to the html. I could'nt reproduce this issue by building the playground. Even if there's no more errors, the HTML rendered and sent by the server is different in build/prod vs test.

@huang-julien huang-julien marked this pull request as ready for review August 16, 2022 14:13
Copy link
Member

@pi0 pi0 left a comment

Choose a reason for hiding this comment

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

Thanks <3

@pi0 pi0 merged commit c688e18 into nuxt:main Aug 17, 2022
@pi0 pi0 mentioned this pull request Aug 26, 2022
@danielroe danielroe added the 3.x label Jan 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Usage of slots in client-only components throwing errors in production
3 participants