-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Render void elements as self-closing tags (#2064)
* Render void elements as self-closing tags * changeset * nit: only check void element names if there is no child content * nit: only check void element names if there is no child content * add tests
- Loading branch information
Jonathan Neal
committed
Dec 1, 2021
1 parent
b348ca6
commit 5bda895
Showing
5 changed files
with
64 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'astro': patch | ||
--- | ||
|
||
Fixes an issue where void elements are rendered with opening and closing tags. |
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
18 changes: 18 additions & 0 deletions
18
packages/astro/test/fixtures/astro-basic/src/components/Input.astro
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,18 @@ | ||
--- | ||
const { | ||
type: initialType, | ||
...props | ||
} = { | ||
...Astro.props | ||
} as { | ||
[K: string]: any; | ||
}; | ||
const isSelect = /^select$/i.test(initialType); | ||
const isTextarea = /^textarea$/i.test(initialType); | ||
const Control = isSelect ? 'select' : isTextarea ? 'textarea' : 'input'; | ||
if (Control === 'input' && initialType) props.type = initialType; | ||
--- | ||
<Control {...props}>{'default' in Astro.slots ? <slot /> : null}</Control> |
16 changes: 16 additions & 0 deletions
16
packages/astro/test/fixtures/astro-basic/src/pages/input.astro
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,16 @@ | ||
--- | ||
import Input from '../components/Input.astro'; | ||
--- | ||
|
||
<html> | ||
<head> | ||
<!-- Head Stuff --> | ||
</head> | ||
<body> | ||
<Input /> | ||
<Input type="password" /> | ||
<Input type="text" /> | ||
<Input type="select"><option>option</option></Input> | ||
<Input type="textarea">textarea</Input> | ||
</body> | ||
</html> |