@arraypress/waveform-player 1.24.2 → 1.24.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/waveform-player.cjs +5 -2
- package/dist/waveform-player.esm.js +2 -2
- package/dist/waveform-player.js +5 -2
- package/dist/waveform-player.min.js +2 -2
- package/package.json +4 -4
- package/src/js/core.js +9 -1
- package/src/js/index.js +14 -3
- package/dist/waveform-player.cjs.map +0 -7
- package/dist/waveform-player.esm.js.map +0 -7
- package/dist/waveform-player.min.js.map +0 -7
package/src/js/index.js
CHANGED
|
@@ -43,8 +43,10 @@ const isBrowser = () => typeof window !== 'undefined' && typeof document !== 'un
|
|
|
43
43
|
* reads the element's `data-*` attributes for configuration). Each successfully
|
|
44
44
|
* initialized element is flagged with `data-waveform-initialized="true"` so
|
|
45
45
|
* repeat calls are idempotent and never double-initialize the same element.
|
|
46
|
-
*
|
|
47
|
-
*
|
|
46
|
+
* Elements already claimed by a programmatically constructed player carry no
|
|
47
|
+
* such flag, so they are skipped by instance lookup instead. Construction errors
|
|
48
|
+
* are caught and logged so one broken element cannot abort the rest of the scan.
|
|
49
|
+
* A no-op in non-DOM environments (e.g. SSR).
|
|
48
50
|
*
|
|
49
51
|
* @returns {void}
|
|
50
52
|
*/
|
|
@@ -54,7 +56,16 @@ function autoInit() {
|
|
|
54
56
|
const elements = document.querySelectorAll('[data-waveform-player]');
|
|
55
57
|
|
|
56
58
|
elements.forEach(element => {
|
|
57
|
-
|
|
59
|
+
// Skip elements already claimed by a player. The `data-waveform-initialized`
|
|
60
|
+
// flag only covers elements this scan built; an element constructed
|
|
61
|
+
// programmatically (`new WaveformPlayer(el)`) carries no flag, so without
|
|
62
|
+
// the instance lookup a later scan would build a second player over it.
|
|
63
|
+
if (
|
|
64
|
+
element.dataset.waveformInitialized === 'true' ||
|
|
65
|
+
WaveformPlayer.getInstance(element)
|
|
66
|
+
) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
58
69
|
|
|
59
70
|
try {
|
|
60
71
|
new WaveformPlayer(element);
|