nodebb-plugin-ezoic-infinite 1.6.49 → 1.6.50

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.6.49",
3
+ "version": "1.6.50",
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
@@ -661,8 +661,8 @@ function globalGapFixInit() {
661
661
 
662
662
  // ---------------- insertion primitives ----------------
663
663
 
664
- function buildWrap(id, kindClass, afterPos, createPlaceholder) {
665
- const wrap = document.createElement('div');
664
+ function buildWrap(id, kindClass, afterPos, createPlaceholder, tagName) {
665
+ const wrap = document.createElement(tagName || 'div');
666
666
  wrap.className = `${WRAP_CLASS} ${kindClass}`;
667
667
  wrap.setAttribute('data-ezoic-after', String(afterPos));
668
668
  wrap.setAttribute('data-ezoic-wrapid', String(id));
@@ -673,6 +673,15 @@ function globalGapFixInit() {
673
673
  }
674
674
  wrap.style.width = '100%';
675
675
 
676
+ // If we're inserted into a UL/OL list, use an LI wrapper to keep valid markup.
677
+ // Otherwise browsers can re-parent the DIV, which looks like items/ads “remontent”
678
+ // and can break topic list rendering.
679
+ if ((tagName || '').toLowerCase() === 'li') {
680
+ wrap.style.listStyle = 'none';
681
+ wrap.style.padding = '0';
682
+ wrap.style.margin = '0';
683
+ }
684
+
676
685
  if (createPlaceholder) {
677
686
  const ph = document.createElement('div');
678
687
  ph.id = `${PLACEHOLDER_PREFIX}${id}`;
@@ -692,7 +701,10 @@ function globalGapFixInit() {
692
701
 
693
702
  insertingIds.add(id);
694
703
  try {
695
- const wrap = buildWrap(id, kindClass, afterPos, !existingPh);
704
+ const parent = target.parentElement;
705
+ const parentTag = parent && parent.tagName ? parent.tagName.toUpperCase() : '';
706
+ const tagName = (parentTag === 'UL' || parentTag === 'OL') ? 'li' : 'div';
707
+ const wrap = buildWrap(id, kindClass, afterPos, !existingPh, tagName);
696
708
  target.insertAdjacentElement('afterend', wrap);
697
709
 
698
710
  // If placeholder exists elsewhere (including pool), move it into the wrapper.