Also fix encoding of <textarea> (#6497)

This commit is contained in:
Laurenz 2025-06-24 17:52:15 +02:00 committed by GitHub
parent 9e3c1199ed
commit f2f527c451
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 14 additions and 1 deletions

View File

@ -113,7 +113,7 @@ fn write_element(w: &mut Writer, element: &HtmlElement) -> SourceResult<()> {
/// Encodes the children of an element. /// Encodes the children of an element.
fn write_children(w: &mut Writer, element: &HtmlElement) -> SourceResult<()> { fn write_children(w: &mut Writer, element: &HtmlElement) -> SourceResult<()> {
// See HTML spec § 13.1.2.5. // See HTML spec § 13.1.2.5.
if element.tag == tag::pre && starts_with_newline(element) { if matches!(element.tag, tag::pre | tag::textarea) && starts_with_newline(element) {
w.buf.push('\n'); w.buf.push('\n');
} }

View File

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body><textarea>
enter</textarea></body>
</html>

View File

@ -11,6 +11,9 @@
#html.pre("\nhello") #html.pre("\nhello")
#html.pre("\n\nhello") #html.pre("\n\nhello")
--- html-textarea-starting-with-newline html ---
#html.textarea("\nenter")
--- html-script html --- --- html-script html ---
// This should be pretty and indented. // This should be pretty and indented.
#html.script( #html.script(