nice-select2 icon indicating copy to clipboard operation
nice-select2 copied to clipboard

initEvent is deprecated

Open Cypaaa opened this issue 1 year ago • 1 comments

Hi, I saw the nice-select2.js file contains a lot of initEvent which is deprecated. You should consider updating the code to keep the support of every browser.

Here is the documentation url in case you cannot click the link above: https://developer.mozilla.org/en-US/docs/Web/API/Event/initEvent

Cypaaa avatar Jun 25 '24 09:06 Cypaaa

Here is an updated version of the code containing initEvent:

// utility functions
function triggerClick(el) {
  const event = new MouseEvent("click", {
    bubbles: true,
    cancelable: false,
  });
  el.dispatchEvent(event);
}

function triggerChange(el) {
  const event = new Event("change", {
    bubbles: true,
    cancelable: false,
  });
  el.dispatchEvent(event);
}

function triggerFocusIn(el) {
  const event = new FocusEvent("focusin", {
    bubbles: true,
    cancelable: false,
  });
  el.dispatchEvent(event);
}

function triggerFocusOut(el) {
  const event = new FocusEvent("focusout", {
    bubbles: true,
    cancelable: false,
  });
  el.dispatchEvent(event);
}

function triggerModalOpen(el) {
  const event = new UIEvent("modalopen", {
    bubbles: true,
    cancelable: false,
  });
  el.dispatchEvent(event);
}

function triggerModalClose(el) {
  const event = new UIEvent("modalclose", {
    bubbles: true,
    cancelable: false,
  });
  el.dispatchEvent(event);
}

Cypaaa avatar Jun 25 '24 09:06 Cypaaa

Thanks for that

Tsjippy avatar Feb 03 '25 12:02 Tsjippy

fixed in 2.3.1

Tsjippy avatar Feb 03 '25 12:02 Tsjippy