nodebb-plugin-ezoic-infinite 1.5.62 → 1.5.63

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 +18 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-ezoic-infinite",
3
- "version": "1.5.62",
3
+ "version": "1.5.63",
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
@@ -329,12 +329,12 @@ function withInternalDomChange(fn) {
329
329
  }
330
330
 
331
331
  function safeDestroyById(id) {
332
- try {
333
- const ez = window.ezstandalone;
334
- if (ez && typeof ez.destroyPlaceholders === 'function') {
335
- ez.destroyPlaceholders([`${PLACEHOLDER_PREFIX}${id}`]);
336
- }
337
- } catch (e) {}
332
+ // IMPORTANT:
333
+ // Do NOT call ez.destroyPlaceholders here.
334
+ // In NodeBB ajaxify/infinite-scroll flows, Ezoic can be mid-refresh.
335
+ // Destroy calls can create churn, reduce fill, and generate "does not exist" spam.
336
+ // We only remove our wrapper; Ezoic manages slot lifecycle.
337
+ return;
338
338
  }
339
339
 
340
340
  function pruneOrphanWraps(kindClass, items) {
@@ -408,12 +408,23 @@ function buildWrap(id, kindClass, afterPos) {
408
408
  if (insertingIds.has(id)) return null;
409
409
 
410
410
  const existingPh = document.getElementById(`${PLACEHOLDER_PREFIX}${id}`);
411
- if (existingPh && existingPh.isConnected) return null;
412
411
 
413
412
  insertingIds.add(id);
414
413
  try {
415
414
  const wrap = buildWrap(id, kindClass, afterPos);
416
415
  target.insertAdjacentElement('afterend', wrap);
416
+
417
+ // If a placeholder with this id already exists elsewhere (some Ezoic flows
418
+ // pre-create placeholders), move it into our wrapper instead of aborting.
419
+ // replaceChild moves the node atomically (no detach window).
420
+ if (existingPh && existingPh !== wrap.firstElementChild) {
421
+ try {
422
+ existingPh.setAttribute('data-ezoic-id', String(id));
423
+ wrap.replaceChild(existingPh, wrap.firstElementChild);
424
+ } catch (e) {
425
+ // Keep the new placeholder if replace fails.
426
+ }
427
+ }
417
428
  return wrap;
418
429
  } finally {
419
430
  insertingIds.delete(id);