refactor: Improve toast notification rendering and event handling

- Refactored the ShowToastJS function to create toast elements using DOM methods for better safety and maintainability.
- Changed the event listener for the 'showToast' event from document.body to document for improved event handling.
- Ensured that the message content is set using textContent to prevent potential XSS vulnerabilities.
This commit is contained in:
StarFleetCPTN
2025-04-07 11:21:11 -07:00
parent 0f46b20fc4
commit 16e7b7e6e5
2 changed files with 31 additions and 18 deletions
+1 -1
View File
@@ -449,7 +449,7 @@ function enhanceMobileForms() {
// Listen for custom 'showToast' event triggered by HX-Trigger
document.body.addEventListener('showToast', function(event) {
document.addEventListener('showToast', function(event) { // Changed from document.body
// Debug logs removed
if (event.detail && event.detail.message && event.detail.type) {
// Call the globally defined showToast function from toast_js.templ