File tree Expand file tree Collapse file tree 5 files changed +98
-1
lines changed
crates/biome_html_formatter
tests/specs/html/bracket-same-line Expand file tree Collapse file tree 5 files changed +98
-1
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " @biomejs/biome " : patch
3+ ---
4+
5+ Fixed [ #9524 ] ( https://github.com/biomejs/biome/issues/9524 ) : remove extra space before ` > ` when ` bracketSameLine ` is true and the self-closing slash is absent in HTML formatter.
Original file line number Diff line number Diff line change @@ -42,7 +42,14 @@ impl FormatNodeRule<HtmlSelfClosingElement> for FormatHtmlSelfClosingElement {
4242 // in the same group as the attributes, unless the token is being borrowed.
4343 // When these tokens are borrowed, they are managed by the sibling `HtmlElementList` formatter.
4444 if bracket_same_line {
45- write!( f, [ hard_space( ) ] ) ?;
45+ let is_void = node. is_void_element( ) . unwrap_or_default( ) ;
46+ let will_have_slash = self_close_void_elements. is_always( )
47+ || ( slash_token. is_some( )
48+ && !( is_void && self_close_void_elements. is_never( ) ) ) ;
49+
50+ if will_have_slash {
51+ write!( f, [ hard_space( ) ] ) ?;
52+ }
4653 } else if attributes. len( ) >= 1 {
4754 if self_close_void_elements. is_always( ) {
4855 write!( f, [ soft_line_break_or_space( ) ] ) ?;
Original file line number Diff line number Diff line change 1+ {
2+ "html" : {
3+ "formatter" : {
4+ "bracketSameLine" : true
5+ }
6+ }
7+ }
Original file line number Diff line number Diff line change 1+ < img
2+ src ="test.png "
3+ alt ="test " />
4+ < br />
5+ < input
6+ type ="text "
7+ name ="test " />
8+ < hr >
Original file line number Diff line number Diff line change 1+ -- -
2+ source : crates / biome_formatter_test / src / snapshot_builder .rs
3+ assertion_line : 212
4+ info : bracket - same - line / void_elements .html
5+ -- -
6+
7+ # Input
8+
9+ ` ` ` html
10+ <img
11+ src = " test.png"
12+ alt = " test" />
13+ <br />
14+ <input
15+ type = " text"
16+ name = " test" />
17+ <hr >
18+
19+ ```
20+
21+
22+ =============================
23+
24+ # Outputs
25+
26+ ## Output 1
27+
28+ -----
29+ Indent style: Tab
30+ Indent width: 2
31+ Line ending: LF
32+ Line width: 80
33+ Attribute Position: Auto
34+ Bracket same line: false
35+ Whitespace sensitivity: css
36+ Indent script and style: false
37+ Self close void elements: never
38+ Trailing newline: true
39+ -----
40+
41+ ```html
42+ <img src = " test.png" alt = " test" >
43+ <br >
44+ <input type = " text" name = " test" >
45+ <hr >
46+
47+ ```
48+
49+ ## Output 1
50+
51+ -----
52+ Indent style: Tab
53+ Indent width: 2
54+ Line ending: LF
55+ Line width: 80
56+ Attribute Position: Auto
57+ Bracket same line: true
58+ Whitespace sensitivity: css
59+ Indent script and style: false
60+ Self close void elements: never
61+ Trailing newline: true
62+ -----
63+
64+ ```html
65+ <img src = " test.png" alt = " test" >
66+ <br >
67+ <input type = " text" name = " test" >
68+ <hr >
69+
70+ ```
You can’t perform that action at this time.
0 commit comments