allow <svelte:self> to be part of a slot

pull/4532/head
Tan Li Hau 6 years ago
parent 91d758e35b
commit 9c3108f98b

@ -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 within a component`
}, 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 within a component",
"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