Skip to content

Commit fb22c93

Browse files
stofostrolucky
andauthored
Fix the JS code in the profiler panel for Symfony 7 (#1748)
Co-authored-by: Gabriel Ostrolucký <[email protected]>
1 parent 846ba31 commit fb22c93

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

Resources/views/Collector/db.html.twig

+11-6
Original file line numberDiff line numberDiff line change
@@ -447,9 +447,16 @@
447447
var targetElement = document.getElementById(targetId);
448448
449449
if (targetElement.style.display != 'block') {
450-
Sfjs.load(targetId, link.href, null, function(xhr, el) {
451-
el.innerHTML = 'An error occurred while loading the query explanation.';
452-
});
450+
if (targetElement.getAttribute('data-sfurl') !== link.href) {
451+
fetch(link.href, {
452+
headers: {'X-Requested-With': 'XMLHttpRequest'}
453+
}).then(async function (response) {
454+
targetElement.innerHTML = await response.text()
455+
targetElement.setAttribute('data-sfurl', link.href)
456+
}, function () {
457+
targetElement.innerHTML = 'An error occurred while loading the query explanation.';
458+
})
459+
}
453460
454461
targetElement.style.display = 'block';
455462
link.innerHTML = 'Hide query explanation';
@@ -490,15 +497,13 @@
490497
});
491498
492499
for (i = 0; i < items.length; ++i) {
493-
Sfjs.removeClass(items[i], i % 2 ? 'even' : 'odd');
494-
Sfjs.addClass(items[i], i % 2 ? 'odd' : 'even');
495500
target.appendChild(items[i]);
496501
}
497502
}
498503
499504
if (navigator.clipboard) {
500505
document.querySelectorAll('[data-clipboard-text]').forEach(function(button) {
501-
Sfjs.removeClass(button, 'hidden');
506+
button.classList.remove('hidden');
502507
button.addEventListener('click', function() {
503508
navigator.clipboard.writeText(button.getAttribute('data-clipboard-text'));
504509
})

0 commit comments

Comments
 (0)