Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

initEvent is deprecated #84

Open
Cypaaa opened this issue Jun 25, 2024 · 1 comment
Open

initEvent is deprecated #84

Cypaaa opened this issue Jun 25, 2024 · 1 comment

Comments

@Cypaaa
Copy link

Cypaaa commented Jun 25, 2024

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
Copy link
Author

Cypaaa commented Jun 25, 2024

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);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant