Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/parse/state/tag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion test/parser/samples/error-self-reference/error.json
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<script>
export let count;
</script>

{#if count > 0}
<slot count={count-1}></slot>
{/if}
3 changes: 3 additions & 0 deletions test/runtime/samples/self-reference-component/_config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default {
html: '5 4 3 2 1 0',
};
10 changes: 10 additions & 0 deletions test/runtime/samples/self-reference-component/main.svelte
Original file line number Diff line number Diff line change
@@ -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>