allow <svelte:self> to be part of a slot (#4532)

pull/4553/head
Tan Li Hau 4 years ago committed by GitHub
parent 91d758e35b
commit a66437b3c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -2,6 +2,7 @@
## Unreleased
* Allow `<svelte:self>` to be used in a slot ([#2798](https://github.com/sveltejs/svelte/issues/2798))
* Expose object of unknown props in `$$restProps` ([#2930](https://github.com/sveltejs/svelte/issues/2930))
## 3.19.2

@ -241,7 +241,7 @@ function read_tag_name(parser: Parser) {
while (i--) {
const fragment = parser.stack[i];
if (fragment.type === 'IfBlock' || fragment.type === 'EachBlock') {
if (fragment.type === 'IfBlock' || fragment.type === 'EachBlock' || fragment.type === 'InlineComponent') {
legal = true;
break;
}
@ -250,7 +250,7 @@ function read_tag_name(parser: Parser) {
if (!legal) {
parser.error({
code: `invalid-self-placement`,
message: `<svelte:self> components can only exist inside if-blocks or each-blocks`
message: `<svelte:self> components can only exist inside {#if} blocks, {#each} blocks, or slots passed to components`
}, start);
}

@ -1,6 +1,6 @@
{
"code": "invalid-self-placement",
"message": "<svelte:self> components can only exist inside if-blocks or each-blocks",
"message": "<svelte:self> components can only exist inside {#if} blocks, {#each} blocks, or slots passed to components",
"start": {
"line": 1,
"column": 1,

@ -0,0 +1,7 @@
<script>
export let count;
</script>
{#if count > 0}
<slot count={count-1}></slot>
{/if}

@ -0,0 +1,3 @@
export default {
html: '5 4 3 2 1 0',
};

@ -0,0 +1,10 @@
<script>
import Countdown from './Countdown.svelte';
export let count = 5;
</script>
{count}
<Countdown {count} let:count={i}>
<svelte:self count={i} />
</Countdown>
Loading…
Cancel
Save