From 1e2a55c88e753cefc6acc668c83fee6cdbc70f31 Mon Sep 17 00:00:00 2001 From: Yuichiro Yamashita Date: Mon, 12 Sep 2022 03:48:13 +0900 Subject: [PATCH] throw warning instead of error (#7834) --- src/runtime/internal/dev.ts | 4 +++- .../dynamic-element-void-with-content-1/_config.js | 2 +- .../dynamic-element-void-with-content-2/_config.js | 2 +- .../dynamic-element-void-with-content-3/_config.js | 2 +- .../dynamic-element-void-with-content-5/_config.js | 6 ++++++ .../dynamic-element-void-with-content-5/main.svelte | 10 ++++++++++ 6 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 test/runtime/samples/dynamic-element-void-with-content-5/_config.js create mode 100644 test/runtime/samples/dynamic-element-void-with-content-5/main.svelte diff --git a/src/runtime/internal/dev.ts b/src/runtime/internal/dev.ts index df40f94230..02677172fa 100644 --- a/src/runtime/internal/dev.ts +++ b/src/runtime/internal/dev.ts @@ -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(` is self-closing and cannot have content.`); + console.warn( + ` is self-closing and cannot have content.` + ); } } diff --git a/test/runtime/samples/dynamic-element-void-with-content-1/_config.js b/test/runtime/samples/dynamic-element-void-with-content-1/_config.js index 4016725e21..2888a8437b 100644 --- a/test/runtime/samples/dynamic-element-void-with-content-1/_config.js +++ b/test/runtime/samples/dynamic-element-void-with-content-1/_config.js @@ -5,5 +5,5 @@ export default { props: { tag: 'br' }, - error: ' is self-closing and cannot have content.' + warnings: [' is self-closing and cannot have content.'] }; diff --git a/test/runtime/samples/dynamic-element-void-with-content-2/_config.js b/test/runtime/samples/dynamic-element-void-with-content-2/_config.js index 4016725e21..2888a8437b 100644 --- a/test/runtime/samples/dynamic-element-void-with-content-2/_config.js +++ b/test/runtime/samples/dynamic-element-void-with-content-2/_config.js @@ -5,5 +5,5 @@ export default { props: { tag: 'br' }, - error: ' is self-closing and cannot have content.' + warnings: [' is self-closing and cannot have content.'] }; diff --git a/test/runtime/samples/dynamic-element-void-with-content-3/_config.js b/test/runtime/samples/dynamic-element-void-with-content-3/_config.js index 4016725e21..2888a8437b 100644 --- a/test/runtime/samples/dynamic-element-void-with-content-3/_config.js +++ b/test/runtime/samples/dynamic-element-void-with-content-3/_config.js @@ -5,5 +5,5 @@ export default { props: { tag: 'br' }, - error: ' is self-closing and cannot have content.' + warnings: [' is self-closing and cannot have content.'] }; diff --git a/test/runtime/samples/dynamic-element-void-with-content-5/_config.js b/test/runtime/samples/dynamic-element-void-with-content-5/_config.js new file mode 100644 index 0000000000..6e56f6bdba --- /dev/null +++ b/test/runtime/samples/dynamic-element-void-with-content-5/_config.js @@ -0,0 +1,6 @@ +export default { + compileOptions: { + dev: true + }, + warnings: [' is self-closing and cannot have content.'] +}; diff --git a/test/runtime/samples/dynamic-element-void-with-content-5/main.svelte b/test/runtime/samples/dynamic-element-void-with-content-5/main.svelte new file mode 100644 index 0000000000..990772b1e6 --- /dev/null +++ b/test/runtime/samples/dynamic-element-void-with-content-5/main.svelte @@ -0,0 +1,10 @@ + + +{#each tags as tag} + {tag.t}
+ + {#if tag.t !== 'input'}{tag.content}{/if} + +{/each}