refactor(rendering): restore NodeDetails active tab; keyed partial updates by IP; add escapeHtml in base Component and use in members; simplify ApiClient methods by removing redundant try/catch

This commit is contained in:
2025-08-31 11:24:39 +02:00
parent b757cb68da
commit 1bdaed9a2c
3 changed files with 51 additions and 87 deletions

View File

@@ -550,7 +550,7 @@ class Component {
}
renderError(message) {
const safe = String(message || 'An error occurred');
const safe = this.escapeHtml(String(message || 'An error occurred'));
const html = `
<div class="error">
<strong>Error:</strong><br>
@@ -569,6 +569,16 @@ class Component {
this.setHTML('', html);
}
// Basic HTML escaping for dynamic values
escapeHtml(str) {
return String(str)
.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&#039;');
}
// Tab helpers
setupTabs(container = this.container, options = {}) {
const { onChange } = options;