Do not expose default slot let bindings to named slots #6049
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.
BREAKING CHANGE
Default slot let bindings are not available on named slots anymore and vice versa:
This makes slot bindings more consistent as the behavior is undefined when for example the default slot is from a list and the named slot is not.
To fix this, make the bindings you need available on the named slot (or default slot) and bind to them there.
PR description
Fixes #5865
Fixes #5684
Fixes #7245
Fixes #7709
@Rich-Harris this takes an opposite approach of #2419 from fixing #2320
where defining the
let:value
on Component,<Component let:value>
will only apply to the default slot.To make it clear,
<Component>
levelvalue
in named slot will have"missing-declaration"
warninglet:
on the<Component>
<Component >
#2419 exposes the default slot data to named slot:
This assumes that the default slot will always be there whenever
foo
slot exists, and there will be 1 default slot.This immediately turns complicated and does not make sense if there's multiple of default
<slot />
This MR fixes #2320 with a separate direction, where specifying
let:data
in the<Component>
attribute will be solely for default slot and will not be available to the named slot.Before submitting the PR, please make sure you do the following
Tests
npm test
and lint the project withnpm run lint