refactor: fix memory leak in auth-modal, consolidate escapeHTML helper across 11 components
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { t } from '../i18n.js'
|
||||
import { escapeHTML } from '../utils/helpers.js'
|
||||
|
||||
/**
|
||||
* Error Boundary Component
|
||||
@@ -37,7 +38,7 @@ class ErrorBoundary extends HTMLElement {
|
||||
<div class="error-boundary">
|
||||
<div class="error-icon">⚠️</div>
|
||||
<h3 class="error-title">${t('error.title') || 'Etwas ist schiefgelaufen'}</h3>
|
||||
<p class="error-message">${this.escapeHtml(errorMessage)}</p>
|
||||
<p class="error-message">${escapeHTML(errorMessage)}</p>
|
||||
<button class="btn btn-primary error-retry" type="button">
|
||||
${t('error.retry') || 'Erneut versuchen'}
|
||||
</button>
|
||||
@@ -59,14 +60,6 @@ class ErrorBoundary extends HTMLElement {
|
||||
this.error = null
|
||||
}
|
||||
|
||||
escapeHtml(str) {
|
||||
if (!str) return ''
|
||||
return String(str)
|
||||
.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/"/g, '"')
|
||||
}
|
||||
}
|
||||
|
||||
customElements.define('error-boundary', ErrorBoundary)
|
||||
@@ -137,7 +130,7 @@ function showErrorToast(message) {
|
||||
toast.className = 'error-toast'
|
||||
toast.innerHTML = /* html */`
|
||||
<span class="error-toast-icon">⚠️</span>
|
||||
<span class="error-toast-message">${escapeHtml(message)}</span>
|
||||
<span class="error-toast-message">${escapeHTML(message)}</span>
|
||||
<button class="error-toast-close" aria-label="Schließen">×</button>
|
||||
`
|
||||
|
||||
@@ -155,15 +148,6 @@ function showErrorToast(message) {
|
||||
requestAnimationFrame(() => toast.classList.add('visible'))
|
||||
}
|
||||
|
||||
function escapeHtml(str) {
|
||||
if (!str) return ''
|
||||
return String(str)
|
||||
.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/"/g, '"')
|
||||
}
|
||||
|
||||
// Styles
|
||||
const style = document.createElement('style')
|
||||
style.textContent = /* css */`
|
||||
|
||||
Reference in New Issue
Block a user