Skip to content

Commit 5d96791

Browse files
committed
Disable annotations in development and simply cleanup logic
1 parent c8f65a3 commit 5d96791

2 files changed

Lines changed: 6 additions & 21 deletions

File tree

app/javascript/controllers/content_loader_controller.js

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,14 @@ export default class extends Controller {
77
this.load()
88
}
99

10-
stripHtmlComments(input) {
11-
let previous
12-
let output = input
13-
14-
do {
15-
previous = output
16-
output = output.replace(/<!--[\s\S]*?-->/g, '')
17-
} while (output !== previous)
18-
19-
return output
20-
}
21-
2210
load() {
2311
fetch(this.urlValue)
2412
.then(response => response.text())
2513
.then(html => {
2614
const parentElement = this.element.parentElement
27-
// Strip HTML comments and trim whitespace
28-
const cleanedHtml = this.stripHtmlComments(html).trim()
2915
// Replace the entire element with the fetched HTML, or remove if empty
30-
if (cleanedHtml) {
31-
this.element.outerHTML = cleanedHtml
16+
if (html.trim()) {
17+
this.element.outerHTML = html
3218
// Hide primo links if libkey link is present
3319
if (parentElement.querySelector('.libkey-link')) {
3420
const resultGet = parentElement.closest('.result-get')
@@ -39,11 +25,9 @@ export default class extends Controller {
3925
}
4026
}
4127
} else {
42-
// Remove only this loader element
43-
this.element.remove();
44-
// Remove result-get container if it's now empty (no fulfillment links and no other content)
28+
this.element.remove()
4529
if (!parentElement.textContent.trim()) {
46-
parentElement.remove();
30+
parentElement.remove()
4731
}
4832
}
4933
})

config/environments/development.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@
6868
# config.i18n.raise_on_missing_translations = true
6969

7070
# Annotate rendered view with file names.
71-
config.action_view.annotate_rendered_view_with_filenames = true
71+
# Disabled because annotation comments pollute dynamically-loaded HTML fragments (e.g. ThirdIron responses)
72+
# config.action_view.annotate_rendered_view_with_filenames = true
7273

7374
# Uncomment if you wish to allow Action Cable access from any origin.
7475
# config.action_cable.disable_request_forgery_protection = true

0 commit comments

Comments
 (0)