sveltejs / svelte

Cybernetically enhanced web apps
https://svelte.dev
MIT License
76.8k stars 3.98k forks source link

fix: prevent ownership validation from infering with component context #11438

Closed dummdidumm closed 2 weeks ago

dummdidumm commented 2 weeks ago

Ownership validation had a false positive when rendering a component as slotted content of another component. To fix this, #11401 did set the current component context to the context the snippet was declared in, not to the context it is rendered in. This was flawed because it means that component context was altered in a way that setContext/getContext failed because the parent chain was incorrect. This fixes that by introducing a separate global (dev time only) which tracks the component function the ownership needs.

fixes #11429

Before submitting the PR, please make sure you do the following

Tests and linting

changeset-bot[bot] commented 2 weeks ago

🦋 Changeset detected

Latest commit: d87c13956704c49c7af3d9d961f58b6022f4d197

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

This PR includes changesets to release 1 package | Name | Type | | ------ | ----- | | svelte | Patch |

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

dummdidumm commented 2 weeks ago

Self-merging because this is a pretty nasty bug