Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 13 additions & 28 deletions crates/biome_html_formatter/src/html/auxiliary/element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,35 +130,20 @@ impl FormatNodeRule<HtmlElement> for FormatHtmlElement {
flat_children,
expanded_children,
} => {
// FIXME: `if_group_breaks` and `if_group_fits_on_line` are supposed to be inverses of each other,
// and they are. However, if the condition in the `if` below is not met, then neither of the 2
// calls print any content. This is a bug.
if opening_element.attributes().len() > 1 {
write!(
f,
[
// If the attribute group breaks, prettier always breaks the children as well.
&if_group_breaks(&expanded_children)
.with_group_id(Some(attr_group_id)),
// If the attribute group does NOT break, print whatever fits best for the children.
&if_group_fits_on_line(&best_fitting![
format_args![flat_children],
format_args![expanded_children]
])
.with_group_id(Some(attr_group_id)),
]
)?;
} else {
// The workaround for the bug mentioned above is to unconditionally print the children in the
// cases where the previous block would not print anything.
write!(
f,
[&best_fitting![
let expanded_children = expanded_children.memoized();
write!(
f,
[
// If the attribute group breaks, prettier always breaks the children as well.
&if_group_breaks(&expanded_children).with_group_id(Some(attr_group_id)),
// If the attribute group does NOT break, print whatever fits best for the children.
&if_group_fits_on_line(&best_fitting![
format_args![flat_children],
format_args![expanded_children]
]]
)?;
}
format_args![expanded_children],
])
.with_group_id(Some(attr_group_id)),
]
)?;
}
}
}
Expand Down