Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions js/src/html/beautifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,8 @@ Beautifier.prototype._handle_tag_close = function(printer, raw_token, last_tag_t
printer.set_space_before_token(raw_token.text[0] === '/', true); // space before />, no space before >
if (this._is_wrap_attributes_force_expand_multiline && last_tag_token.has_wrapped_attrs) {
printer.print_newline(false);
} else if (this._is_wrap_attributes_preserve && raw_token.newlines) {
printer.print_preserved_newlines(raw_token);
}
}
printer.print_token(raw_token);
Expand Down
43 changes: 43 additions & 0 deletions test/data/html/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -1206,6 +1206,49 @@ exports.test_data = {
'^^^indent_attr$$$(typeaheadOnSelect)="onSuggestionSelected($event)" />'
]
}]
}, {
name: "Issue #1707 -- Preserve newline before closing bracket",
description: "",
template: "^^^ $$$",
matrix: [{
options: [
{ name: "wrap_attributes", value: "'preserve-aligned'" }
],
indent_attr: ' '
}, {
options: [
{ name: "wrap_attributes", value: "'preserve'" }
],
indent_attr: ' '
}],
tests: [{
input: [
'<tag',
' attr1="val1"',
' attr2="val2"',
'>content</tag>'
],
output: [
'<tag',
'^^^indent_attr$$$attr1="val1"',
'^^^indent_attr$$$attr2="val2"',
'>content</tag>'
]
}, {
input: [
'<img',
' src="image.png"',
'/>'
],
output: [
'<img',
'^^^indent_attr$$$src="image.png"',
'/>'
]
}, {
fragment: true,
unchanged: '<tag attr="value">content</tag>'
}]
}, {
name: "Test wrap_attributes_min_attrs with force/force-xx options",
description: "",
Expand Down