Skip to content

Commit 9fc3771

Browse files
committed
Insert trimmed html
1 parent 5d7bb76 commit 9fc3771

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

app/javascript/controllers/content_loader_controller.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ export default class extends Controller {
1313
.then(html => {
1414
const parentElement = this.element.parentElement;
1515
// Replace the entire element with the fetched HTML, or remove if empty
16-
if (html && html.trim()) {
17-
this.element.outerHTML = html;
16+
const trimmedHtml = html.trim();
17+
if (trimmedHtml) {
18+
this.element.outerHTML = trimmedHtml;
1819
} else {
1920
this.element.remove();
2021
}

0 commit comments

Comments
 (0)