Skip to content

Conversation

@Hugos68
Copy link
Contributor

@Hugos68 Hugos68 commented Feb 28, 2025

Closes #13327

Utilizes the new idPrefix option from server/client side rendering added in sveltejs/svelte#15403 in Svelte to inject a unique prefix generated by Astro.

Changes

  • Enables different Svelte islands to generate non colliding $props.id

Testing

No tests were added because it looks like the Svelte integration isn't tested, at all?

Docs

This would only solve problems, it's highly unlikely a user depended on colliding ID's for their app to work. It's also a very niche use case using two client side Astro Svelte components with $props.id

…zing the new `uidPrefix` option exposed for both server and client side rendering.
@changeset-bot
Copy link

changeset-bot bot commented Feb 28, 2025

🦋 Changeset detected

Latest commit: 37bc918

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added pkg: svelte Related to Svelte (scope) pkg: integration Related to any renderer integration (scope) labels Feb 28, 2025
@florian-lefebvre
Copy link
Member

@Hugos68 ping me when the related svelte PR is merged and released

@Hugos68
Copy link
Contributor Author

Hugos68 commented Mar 4, 2025

@florian-lefebvre Merged and released in: sveltejs/svelte#15428. API is available in version 5.22.0!

@Hugos68
Copy link
Contributor Author

Hugos68 commented Mar 4, 2025

I'll aim to update my PR and will request a review after.

@Hugos68
Copy link
Contributor Author

Hugos68 commented Mar 4, 2025

@florian-lefebvre I've implemented the prefix for the server side part of islands. I don't know how to apply it to the client, some help would be much appreciated.

@florian-lefebvre
Copy link
Member

I'll look into it later today!

@florian-lefebvre
Copy link
Member

Looking at sveltejs/svelte#15428, I think svelte takes care of ids on the client

@Hugos68
Copy link
Contributor Author

Hugos68 commented Mar 5, 2025

incrementId came from context, but I see you've added the missing import and file. Like I said, I was a bit puzzled so ended up reverting a bunch of stuff but didn't that correctly.

@Hugos68
Copy link
Contributor Author

Hugos68 commented Mar 5, 2025

Looking at sveltejs/svelte#15428, I think svelte takes care of ids on the client

Ok, sounds good, so then if the server side prefixing looks correct I'll move it to a ready for review PR.

@Hugos68 Hugos68 marked this pull request as ready for review March 5, 2025 10:27
Copy link
Member

@florian-lefebvre florian-lefebvre left a comment

Choose a reason for hiding this comment

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

Thanks for the help and the contribution upstream!

@florian-lefebvre florian-lefebvre self-assigned this Mar 5, 2025
@Hugos68
Copy link
Contributor Author

Hugos68 commented Mar 5, 2025

Yeah I think I borked something when merging upstream changes back to this branch, thanks for picking these up.

@florian-lefebvre florian-lefebvre merged commit a05e6ab into withastro:main Mar 5, 2025
26 of 27 checks passed
@astrobot-houston astrobot-houston mentioned this pull request Mar 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: integration Related to any renderer integration (scope) pkg: svelte Related to Svelte (scope)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[@astrojs/svelte] $props.id is identical across islands.

2 participants