Fix docstring accuracy, extract _firstElementFromHtml helper, address all code review feedback

This commit is contained in:
copilot-swe-agent[bot]
2026-06-04 19:49:01 +00:00
committed by GitHub
parent 69b84153b4
commit 06988d0ff0
2 changed files with 12 additions and 14 deletions
+3 -3
View File
@@ -2415,15 +2415,15 @@ def _get_bip110_status() -> dict:
Resolution order (authoritative → fallback → honest unknown):
1. ``getdeploymentinfo`` (authoritative) — scan the ``deployments`` dict for an
entry whose key (case-insensitive) contains "bip110" or "110". The exact
entry whose key (case-insensitive) contains "bip110". The exact
deployment key name is **not** hard-coded because it may vary across Knots
releases; detection is intentionally generic so that a name change degrades
to "unknown" rather than producing a false result.
2. Subversion fallback — if getdeploymentinfo is unavailable or yields no
recognisable BIP-110 entry, inspect the ``subversion`` field from
``getnetworkinfo``. A case-insensitive match for "bip110" or "uasf" in the
subversion string is treated as "signaling".
``getnetworkinfo``. A case-insensitive match for "bip110" or "uasf-bip110"
in the subversion string is treated as "signaling".
3. Unknown — if the node is entirely unreachable or neither source is
conclusive, return state="unknown", signaling=False, source="none".
+9 -11
View File
@@ -13,6 +13,12 @@ function _renderBip110Badge(bip110) {
return '<div class="tile-bip110-badge ' + cfg.cls + '" title="' + escHtml(cfg.title) + '">' + escHtml(cfg.label) + '</div>';
}
function _firstElementFromHtml(html) {
var tmp = document.createElement("div");
tmp.innerHTML = html;
return tmp.firstElementChild || null;
}
// ── Render: initial build ─────────────────────────────────────────
function buildTiles(services, categoryLabels) {
@@ -281,21 +287,13 @@ function updateTiles(services) {
var badgeEl = tile.querySelector(".tile-bip110-badge");
if (badgeEl) {
// Replace existing badge in-place
var tmp = document.createElement("div");
tmp.innerHTML = badgeHtml;
var newBadge = tmp.firstElementChild;
if (newBadge) {
badgeEl.replaceWith(newBadge);
} else {
badgeEl.remove();
}
var newBadge = _firstElementFromHtml(badgeHtml);
if (newBadge) { badgeEl.replaceWith(newBadge); } else { badgeEl.remove(); }
} else if (badgeHtml) {
// Insert badge after version label (or after tile-name if no version)
var anchorEl = tile.querySelector(".tile-version") || tile.querySelector(".tile-name");
if (anchorEl) {
var tmpDiv = document.createElement("div");
tmpDiv.innerHTML = badgeHtml;
var newBadgeEl = tmpDiv.firstElementChild;
var newBadgeEl = _firstElementFromHtml(badgeHtml);
if (newBadgeEl) anchorEl.insertAdjacentElement("afterend", newBadgeEl);
}
}