throw warning instead of error (#7834)

pull/7693/head
Yuichiro Yamashita 2 years ago committed by GitHub
parent adcaa3c050
commit 1e2a55c88e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -117,7 +117,9 @@ export function validate_dynamic_element(tag: unknown) {
export function validate_void_dynamic_element(tag: undefined | string) {
if (tag && is_void(tag)) {
throw new Error(`<svelte:element this="${tag}"> is self-closing and cannot have content.`);
console.warn(
`<svelte:element this="${tag}"> is self-closing and cannot have content.`
);
}
}

@ -5,5 +5,5 @@ export default {
props: {
tag: 'br'
},
error: '<svelte:element this="br"> is self-closing and cannot have content.'
warnings: ['<svelte:element this="br"> is self-closing and cannot have content.']
};

@ -5,5 +5,5 @@ export default {
props: {
tag: 'br'
},
error: '<svelte:element this="br"> is self-closing and cannot have content.'
warnings: ['<svelte:element this="br"> is self-closing and cannot have content.']
};

@ -5,5 +5,5 @@ export default {
props: {
tag: 'br'
},
error: '<svelte:element this="br"> is self-closing and cannot have content.'
warnings: ['<svelte:element this="br"> is self-closing and cannot have content.']
};

@ -0,0 +1,6 @@
export default {
compileOptions: {
dev: true
},
warnings: ['<svelte:element this="input"> is self-closing and cannot have content.']
};

@ -0,0 +1,10 @@
<script>
const tags = [{ t: 'div', content: 'hello world' }, { t: 'input' }];
</script>
{#each tags as tag}
{tag.t} <br />
<svelte:element this={tag.t}>
{#if tag.t !== 'input'}{tag.content}{/if}
</svelte:element>
{/each}
Loading…
Cancel
Save