Files
PrivateCaptcha/widget
Luke Watts 2a1e074b17 fix: guard against custom element 'progress-ring' already existing (#250)
When the widget script is loaded multiple times (possible in SPA environments with framework component lifecycles), the application crashes with:

```
Uncaught DOMException: CustomElementRegistry.define: 'progress-ring' has already been defined as a custom element
```

This occurs because `customElements.define()` throws an error if called twice with the same element name, and the Custom Elements API provides no way to undefine or replace registered elements.

### Solution
Added a guard to check if the custom element is already registered before attempting to define it:
```javascript
if (typeof window !== "undefined" && 
    window.customElements && 
    !window.customElements.get('progress-ring')) {
    window.customElements.define('progress-ring', ProgressRing);
}
```

### Why This Matters
- **Prevents crashes** in SPA environments where components mount/unmount repeatedly
- **Idempotent behavior** - script can safely be included multiple times

This is a defensive programming practice recommended for any third-party script that registers custom elements, as you cannot control how integrators will load your code.
2026-01-13 21:19:49 +02:00
..
2025-12-19 20:02:56 +01:00
2025-05-31 10:56:00 +03:00
2025-10-11 09:49:26 +03:00
2025-12-15 15:49:57 +01:00
2025-10-10 16:09:12 +03:00
2025-05-31 10:56:00 +03:00
2025-05-31 10:56:00 +03:00