source/article-ads.old.js
/**
 * Replace elements with new
 * @param {HTMLElement} newElement
 * @param {HTMLElement} oldElement
 */
Replace elements with new
@param {HTMLElement} newElement
@param {HTMLElement} oldElement
Replace elements with new @param { HTMLElement } newElement @param { HTMLElement } oldElement
function replaceWith(newElement, oldElement) {
  if (!oldElement.parentNode) {
    console.log(oldElement, "parent null");
    let d = document.createElement("div");
    d.appendChild(oldElement);
  } else {
    oldElement.parentNode.replaceChild(newElement, oldElement);
  }
}
function replaceWith ( newElement , oldElement ) { if ( ! oldElement . parentNode ) { console . log ( oldElement , "parent null" ) ; let d = document . createElement ( "div" ) ; d . appendChild ( oldElement ) ; } else { oldElement . parentNode . replaceChild ( newElement , oldElement ) ; } }
Replace elements with new
 @param {HTMLElement} newElement
 @param {HTMLElement} oldElement
Replace elements with new @param { HTMLElement } newElement @param { HTMLElement } oldElement
//console.log(oldElement.parentNode.tagName); /*
   try {
     oldElement.parentNode.replaceChild(newElement, oldElement);
   } catch (e) {}
   */