Files
MajoorWaldi-ComfyUI-Majoor-…/js/utils/events.js
T
MajoorWaldi dc72be0139 feat: enhance JS testing and linting setup
- Added coverage reporting for Vitest with configuration in vitest.config.mjs
- Updated package.json to include new scripts for JS coverage, linting, and formatting
- Modified run_quality_gate.py to allow skipping ESLint and Prettier checks
- Introduced .prettierrc for consistent code formatting
- Created .prettierignore to exclude specific files and directories from formatting
2026-03-28 14:14:28 +01:00

25 lines
670 B
JavaScript

/**
* Event helpers.
*
* Keep event dispatch best-effort (never throw) but avoid fully silent failures.
*/
export function safeDispatchCustomEvent(
eventName,
detail,
{ target = null, warnPrefix = "[Majoor]" } = {},
) {
const t = target || (typeof window !== "undefined" ? window : null);
if (!t || typeof t.dispatchEvent !== "function") return false;
try {
return t.dispatchEvent(new CustomEvent(eventName, { detail }));
} catch (e) {
try {
console.warn(`${warnPrefix} Failed to dispatch event: ${eventName}`, e);
} catch (e) {
console.debug?.(e);
}
return false;
}
}