nodebb-plugin-ezoic-infinite 1.7.5 → 1.7.6

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/public/client.js +15 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-ezoic-infinite",
3
- "version": "1.7.5",
3
+ "version": "1.7.6",
4
4
  "description": "Production-ready Ezoic infinite ads integration for NodeBB 4.x",
5
5
  "main": "library.js",
6
6
  "license": "MIT",
package/public/client.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * NodeBB Ezoic Infinite Ads — client.js v21.1
2
+ * NodeBB Ezoic Infinite Ads — client.js v21.2
3
3
  *
4
4
  * Historique des corrections majeures
5
5
  * ────────────────────────────────────
@@ -252,8 +252,12 @@
252
252
 
253
253
  function dropWrap(w) {
254
254
  try {
255
+ // Unobserve seulement si le placeholder est encore dans le DOM.
256
+ // unobserve() sur un nœud détaché corrompt l'IO interne de pubads
257
+ // → "Failed to execute 'observe': parameter 1 is not of type 'Element'"
258
+ // sur tous les observe() suivants.
255
259
  const ph = w.querySelector(`[id^="${PH_PREFIX}"]`);
256
- if (ph instanceof Element) S.io?.unobserve(ph);
260
+ if (ph instanceof Element && ph.isConnected) S.io?.unobserve(ph);
257
261
  const id = parseInt(w.getAttribute(A_WRAPID), 10);
258
262
  if (Number.isFinite(id)) S.mountedIds.delete(id);
259
263
  const key = w.getAttribute(A_ANCHOR);
@@ -385,7 +389,7 @@
385
389
 
386
390
  function observePh(id) {
387
391
  const ph = document.getElementById(`${PH_PREFIX}${id}`);
388
- if (ph?.isConnected) try { getIO()?.observe(ph); } catch (_) {}
392
+ if (ph instanceof Element && ph.isConnected) try { getIO()?.observe(ph); } catch (_) {}
389
393
  }
390
394
 
391
395
  function enqueueShow(id) {
@@ -565,6 +569,14 @@
565
569
  function cleanup() {
566
570
  blockedUntil = ts() + 1500;
567
571
  poolsReady = false;
572
+
573
+ // Déconnecter l'IO AVANT les dropWrap pour éviter tout unobserve parasite.
574
+ // disconnect() vide la liste interne des cibles observées — les références
575
+ // aux placeholders de la page courante sont effacées proprement.
576
+ // L'IO sera recréé à ajaxify.end via getIO().
577
+ try { S.io?.disconnect(); } catch (_) {}
578
+ S.io = null;
579
+
568
580
  mutate(() => document.querySelectorAll(`.${WRAP_CLASS}`).forEach(dropWrap));
569
581
  wrapByKey.clear();
570
582
  S.cfg = null;