fix: don't hoist snippets with bind:group
#15040
Open
+46
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #15037
This is a bit of weird one...the point is that the snippet was technically not accessing anything from the instance so it was hoisted but it was using
bind:group
so it needed thebinding_group
...i tried to think it it make sense to export a snippet with a bind group but i don't think it does (especially since we specify in the docs that forbind:group
to work inputs needs to be in the same component) and i don't even think we could do it because even if we would accept thebinding_group
as an argument for the snippet a component that renders that snippet should know that it needs abinding_group
in some way and i don't think it's doable.However while trying to come up with various situations where the snippet could've been exported i noticed that we can technically "kinda" export snippets by passing them as prop. So a user could do something like this
App.svelte
Component.svelte
this is a bit weird because now
App
has thebinding_group
array but thestate
is insideComponent
. So i was wondering...should we disallowbind:group
in snippets all togheter? Technically we can't do it now since it would be a breaking change but i wonder if we should do something about this weirdness.Before submitting the PR, please make sure you do the following
feat:
,fix:
,chore:
, ordocs:
.packages/svelte/src
, add a changeset (npx changeset
).Tests and linting
pnpm test
and lint the project withpnpm lint