-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[fix] rendering void tag for
<svelte:element>
(#7453)
- Loading branch information
1 parent
e01115a
commit 0d017f4
Showing
22 changed files
with
135 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const void_element_names = /^(?:area|base|br|col|command|embed|hr|img|input|keygen|link|meta|param|source|track|wbr)$/; | ||
|
||
export function is_void(name: string) { | ||
return void_element_names.test(name) || name.toLowerCase() === '!doctype'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
export default { | ||
props: { | ||
propTag: 'hr' | ||
}, | ||
html: '<h1></h1><col><img><hr><input><br>', | ||
|
||
test({ assert, component, target }) { | ||
assert.htmlEqual(target.innerHTML, '<h1></h1><col><img><hr><input><br>'); | ||
component.propTag = 'link'; | ||
assert.htmlEqual(target.innerHTML, '<h1></h1><col><img><link><input><br>'); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<script> | ||
export let propTag; | ||
const static_tag = 'input'; | ||
const func_tag = () => 'br'; | ||
</script> | ||
|
||
<h1></h1> | ||
<svelte:element this="{'col'}"></svelte:element> | ||
<svelte:element this="img"></svelte:element> | ||
<svelte:element this="{propTag}"></svelte:element> | ||
<svelte:element this="{static_tag}"></svelte:element> | ||
<svelte:element this="{func_tag()}"></svelte:element> |
9 changes: 9 additions & 0 deletions
9
test/runtime/samples/dynamic-element-void-with-content-1/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export default { | ||
compileOptions: { | ||
dev: true | ||
}, | ||
props: { | ||
tag: 'br' | ||
}, | ||
error: '<svelte:element this="br"> is self-closing and cannot have content.' | ||
}; |
5 changes: 5 additions & 0 deletions
5
test/runtime/samples/dynamic-element-void-with-content-1/main.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<script> | ||
export let tag; | ||
</script> | ||
|
||
<svelte:element this='{tag}'>foo</svelte:element> |
9 changes: 9 additions & 0 deletions
9
test/runtime/samples/dynamic-element-void-with-content-2/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export default { | ||
compileOptions: { | ||
dev: true | ||
}, | ||
props: { | ||
tag: 'br' | ||
}, | ||
error: '<svelte:element this="br"> is self-closing and cannot have content.' | ||
}; |
5 changes: 5 additions & 0 deletions
5
test/runtime/samples/dynamic-element-void-with-content-2/main.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<script> | ||
export let tag; | ||
</script> | ||
|
||
<svelte:element this='{tag}'><div>bar</div></svelte:element> |
1 change: 1 addition & 0 deletions
1
test/runtime/samples/dynamic-element-void-with-content-3/Nested.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<div>This is nested</div> |
9 changes: 9 additions & 0 deletions
9
test/runtime/samples/dynamic-element-void-with-content-3/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export default { | ||
compileOptions: { | ||
dev: true | ||
}, | ||
props: { | ||
tag: 'br' | ||
}, | ||
error: '<svelte:element this="br"> is self-closing and cannot have content.' | ||
}; |
6 changes: 6 additions & 0 deletions
6
test/runtime/samples/dynamic-element-void-with-content-3/main.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<script> | ||
import Nested from './Nested.svelte'; | ||
export let tag; | ||
</script> | ||
|
||
<svelte:element this='{tag}'><Nested/></svelte:element> |
1 change: 1 addition & 0 deletions
1
test/runtime/samples/dynamic-element-void-with-content-4/Nested.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<div>This is nested</div> |
6 changes: 6 additions & 0 deletions
6
test/runtime/samples/dynamic-element-void-with-content-4/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export default { | ||
props: { | ||
tag: 'br' | ||
}, | ||
html: '<br>' | ||
}; |
6 changes: 6 additions & 0 deletions
6
test/runtime/samples/dynamic-element-void-with-content-4/main.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<script> | ||
import Nested from './Nested.svelte'; | ||
export let tag; | ||
</script> | ||
|
||
<svelte:element this='{tag}'><Nested/></svelte:element> |