Commit Graph

14 Commits

Author SHA1 Message Date
Taras Kushnir 28ba7ed860 Create html element explicitly 2026-01-14 10:12:59 +02:00
Taras Kushnir ba1dcb1492 Cosmetic improvements 2026-01-13 21:29:17 +02:00
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
Taras Kushnir 7a921f8858 Fix auto-start mode in popup widget mode 2025-11-29 13:06:49 +01:00
Taras Kushnir 1fc4440f83 Verify styles changed before updating them 2025-10-12 13:10:35 +03:00
Taras Kushnir 365f253b27 Fix immutable stylesheet error when updating widget styles 2025-10-12 13:08:10 +03:00
Taras Kushnir 6ae42a8b60 Add feature to widget to update data-styles 2025-10-11 21:40:45 +03:00
Taras Kushnir fe1b40b99d Add widget test
Mainly for bug fixed in 5df983a5c4
2025-10-10 16:09:12 +03:00
Taras Kushnir 8151214cb5 Use events instead of JS callbacks 2025-09-03 11:44:18 +03:00
Taras Kushnir 26d3c2bd31 Vibe-code few TS annotations for widget code 2025-07-15 18:12:48 +03:00
Taras Kushnir d6440d7d8b Cosmetic improvements 2025-06-29 13:49:33 +03:00
Taras Kushnir a8d848c070 Fix usage of widget library as a package 2025-06-29 13:21:10 +03:00
Taras Kushnir 30417742f9 Add nofollow rel attribute to widget link 2025-06-16 16:17:21 +03:00
Taras Kushnir 4951055189 Initial commit 2025-05-31 10:56:00 +03:00