mirror of
https://github.com/withastro/astro.git
synced 2024-12-16 21:46:22 -05:00
fix: void elements (#10493)
* Fix void elements HTML is not XML. It doesn't have self-closing tags, it has void element tags that don't need closing slashes. Now generated void elements (e.g. link with path to style file) do not pass validation, which can be easily fixed by simply removing two characters. * Add changeset * Apply suggestions from code review --------- Co-authored-by: Arsh <69170106+lilnasy@users.noreply.github.com>
This commit is contained in:
parent
ad57a02c33
commit
e4a6462751
2 changed files with 6 additions and 1 deletions
5
.changeset/thick-games-thank.md
Normal file
5
.changeset/thick-games-thank.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
"astro": patch
|
||||
---
|
||||
|
||||
`<link>` tags created by astro for optimized stylesheets now do not include the closing forward slash. This slash is optional for void elements such as link, but made some html validation fail.
|
|
@ -144,7 +144,7 @@ export function renderElement(
|
|||
}
|
||||
}
|
||||
if ((children == null || children == '') && voidElementNames.test(name)) {
|
||||
return `<${name}${internalSpreadAttributes(props, shouldEscape)} />`;
|
||||
return `<${name}${internalSpreadAttributes(props, shouldEscape)}>`;
|
||||
}
|
||||
return `<${name}${internalSpreadAttributes(props, shouldEscape)}>${children}</${name}>`;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue