diff --git a/site/content/docs/02-template-syntax.md b/site/content/docs/02-template-syntax.md index 456ea26418..a17314f27f 100644 --- a/site/content/docs/02-template-syntax.md +++ b/site/content/docs/02-template-syntax.md @@ -1641,6 +1641,8 @@ The only supported binding is `bind:this`, since the element type specific bindi If `this` has a nullish value, the element and its children will not be rendered. +If `this` is the name of a void tag (e.g., `br`) and `` has child elements, a runtime error will be thrown in development mode. + ```sv + +

+ + + + + 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 new file mode 100644 index 0000000000..4016725e21 --- /dev/null +++ b/test/runtime/samples/dynamic-element-void-with-content-1/_config.js @@ -0,0 +1,9 @@ +export default { + compileOptions: { + dev: true + }, + props: { + tag: 'br' + }, + error: ' is self-closing and cannot have content.' +}; diff --git a/test/runtime/samples/dynamic-element-void-with-content-1/main.svelte b/test/runtime/samples/dynamic-element-void-with-content-1/main.svelte new file mode 100644 index 0000000000..bcf3fed2c3 --- /dev/null +++ b/test/runtime/samples/dynamic-element-void-with-content-1/main.svelte @@ -0,0 +1,5 @@ + + +foo 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 new file mode 100644 index 0000000000..4016725e21 --- /dev/null +++ b/test/runtime/samples/dynamic-element-void-with-content-2/_config.js @@ -0,0 +1,9 @@ +export default { + compileOptions: { + dev: true + }, + props: { + tag: 'br' + }, + error: ' is self-closing and cannot have content.' +}; diff --git a/test/runtime/samples/dynamic-element-void-with-content-2/main.svelte b/test/runtime/samples/dynamic-element-void-with-content-2/main.svelte new file mode 100644 index 0000000000..0225654545 --- /dev/null +++ b/test/runtime/samples/dynamic-element-void-with-content-2/main.svelte @@ -0,0 +1,5 @@ + + +
bar
diff --git a/test/runtime/samples/dynamic-element-void-with-content-3/Nested.svelte b/test/runtime/samples/dynamic-element-void-with-content-3/Nested.svelte new file mode 100644 index 0000000000..e62294a135 --- /dev/null +++ b/test/runtime/samples/dynamic-element-void-with-content-3/Nested.svelte @@ -0,0 +1 @@ +
This is nested
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 new file mode 100644 index 0000000000..4016725e21 --- /dev/null +++ b/test/runtime/samples/dynamic-element-void-with-content-3/_config.js @@ -0,0 +1,9 @@ +export default { + compileOptions: { + dev: true + }, + props: { + tag: 'br' + }, + error: ' is self-closing and cannot have content.' +}; diff --git a/test/runtime/samples/dynamic-element-void-with-content-3/main.svelte b/test/runtime/samples/dynamic-element-void-with-content-3/main.svelte new file mode 100644 index 0000000000..97045e1766 --- /dev/null +++ b/test/runtime/samples/dynamic-element-void-with-content-3/main.svelte @@ -0,0 +1,6 @@ + + + diff --git a/test/runtime/samples/dynamic-element-void-with-content-4/Nested.svelte b/test/runtime/samples/dynamic-element-void-with-content-4/Nested.svelte new file mode 100644 index 0000000000..e62294a135 --- /dev/null +++ b/test/runtime/samples/dynamic-element-void-with-content-4/Nested.svelte @@ -0,0 +1 @@ +
This is nested
diff --git a/test/runtime/samples/dynamic-element-void-with-content-4/_config.js b/test/runtime/samples/dynamic-element-void-with-content-4/_config.js new file mode 100644 index 0000000000..4b2a279aaa --- /dev/null +++ b/test/runtime/samples/dynamic-element-void-with-content-4/_config.js @@ -0,0 +1,6 @@ +export default { + props: { + tag: 'br' + }, + html: '
' +}; diff --git a/test/runtime/samples/dynamic-element-void-with-content-4/main.svelte b/test/runtime/samples/dynamic-element-void-with-content-4/main.svelte new file mode 100644 index 0000000000..97045e1766 --- /dev/null +++ b/test/runtime/samples/dynamic-element-void-with-content-4/main.svelte @@ -0,0 +1,6 @@ + + +