fix: atomic SVG replaceWith() on sparkline update, no empty-frame bounce
This commit is contained in:
parent
0874583a4f
commit
6929d8f51f
|
|
@ -95,7 +95,14 @@
|
|||
_fetchingSparkline.add(ping.monitor_id);
|
||||
try {
|
||||
const res = await fetch(`/dashboard/monitors/${ping.monitor_id}/sparkline`, { credentials: 'same-origin' });
|
||||
if (res.ok) sparkEl.innerHTML = await res.text();
|
||||
if (res.ok) {
|
||||
const tmp = document.createElement('div');
|
||||
tmp.innerHTML = await res.text();
|
||||
const newSvg = tmp.firstElementChild;
|
||||
const oldSvg = sparkEl.querySelector('svg');
|
||||
if (newSvg && oldSvg) oldSvg.replaceWith(newSvg);
|
||||
else if (newSvg) sparkEl.appendChild(newSvg);
|
||||
}
|
||||
} catch {}
|
||||
_fetchingSparkline.delete(ping.monitor_id);
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue