0
0
mirror of https://github.com/sveltejs/svelte.git synced 2024-11-21 11:28:58 +01:00

fix: allow svelte:self in snippets (#9439)

* fix: allow svelte:self in snippets

* Create funny-wombats-argue.md
This commit is contained in:
Paolo Ricciuti 2023-11-14 22:55:33 +01:00 committed by GitHub
parent 73ae5ef5bc
commit e90ded677e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 3 deletions

View File

@ -0,0 +1,5 @@
---
"svelte": patch
---
fix: allow svelte:self in snippets

View File

@ -141,7 +141,7 @@ const special_elements = {
/** @param {string} name */
'duplicate-svelte-element': (name) => `A component can only have one <${name}> element`,
'invalid-self-placement': () =>
`<svelte:self> components can only exist inside {#if} blocks, {#each} blocks, or slots passed to components`,
`<svelte:self> components can only exist inside {#if} blocks, {#each} blocks, {#snippet} blocks or slots passed to components`,
'missing-svelte-element-definition': () => `<svelte:element> must have a 'this' attribute`,
'missing-svelte-component-definition': () => `<svelte:component> must have a 'this' attribute`,
'invalid-svelte-element-definition': () => `Invalid element definition — must be an {expression}`,

View File

@ -333,7 +333,8 @@ function read_tag_name(parser) {
if (
fragment.type === 'IfBlock' ||
fragment.type === 'EachBlock' ||
fragment.type === 'Component'
fragment.type === 'Component' ||
fragment.type === 'SnippetBlock'
) {
legal = true;
break;

View File

@ -4,7 +4,7 @@ export default test({
error: {
code: 'invalid-self-placement',
message:
'<svelte:self> components can only exist inside {#if} blocks, {#each} blocks, or slots passed to components',
'<svelte:self> components can only exist inside {#if} blocks, {#each} blocks,, {#snippet} blocks or slots passed to components',
position: [1, 1]
}
});