All files / base tooltip-icon-modal.js

100% Statements 8/8
87.5% Branches 7/8
100% Functions 2/2
100% Lines 8/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22          6x 5x 3x   2x           1x 3x 3x 3x      
/**
  Toggles visibility of modal dialog.
  @param {HTMLElement} modal Modal dialog to show or hide.
*/
export function toggleModal(modal) {
  if (modal && modal.classList.contains("p-tooltip__modal")) {
    if (modal.style.display === "none") {
      modal.style.display = "flex";
    } else {
      modal.style.display = "none";
    }
  }
}
 
// Add click handler for clicks on elements with aria-controls
document.addEventListener("click", function (event) {
  const targetControls = event.target.getAttribute("aria-controls");
  Eif (targetControls) {
    toggleModal(document.getElementById(targetControls));
  }
});