replaceButton = (popup, buttonToReplace) => {
  const actions = dom.getActions()
  const loader = dom.getLoader()
  if (!actions || !loader) {
    return
  }

  if (!buttonToReplace && dom.isVisible(dom.getConfirmButton())) {
    buttonToReplace = dom.getConfirmButton()
  }

  dom.show(actions)
  if (buttonToReplace) {
    dom.hide(buttonToReplace)
    loader.setAttribute('data-button-to-replace', buttonToReplace.className)
    actions.insertBefore(loader, buttonToReplace)
  }
  dom.addClass([popup, actions], swalClasses.loading)
}
@param {HTMLElement} popup
@param {HTMLButtonElement | null} [buttonToReplace]