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

* fix: allow svelte:self in snippets

* Create funny-wombats-argue.md
baseballyama-docs/string-event
Paolo Ricciuti 1 year ago committed by GitHub
parent 73ae5ef5bc
commit e90ded677e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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

@ -141,7 +141,7 @@ const special_elements = {
/** @param {string} name */ /** @param {string} name */
'duplicate-svelte-element': (name) => `A component can only have one <${name}> element`, 'duplicate-svelte-element': (name) => `A component can only have one <${name}> element`,
'invalid-self-placement': () => '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-element-definition': () => `<svelte:element> must have a 'this' attribute`,
'missing-svelte-component-definition': () => `<svelte:component> 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}`, 'invalid-svelte-element-definition': () => `Invalid element definition — must be an {expression}`,

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

@ -4,7 +4,7 @@ export default test({
error: { error: {
code: 'invalid-self-placement', code: 'invalid-self-placement',
message: 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] position: [1, 1]
} }
}); });

Loading…
Cancel
Save