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

Replace usage of alert() in mouseEvent #7778

Merged
merged 2 commits into from
Aug 10, 2021

Conversation

AnilSeervi
Copy link
Contributor

Fixes portion of #7566

@AnilSeervi AnilSeervi requested a review from a team as a code owner August 10, 2021 04:16
@AnilSeervi AnilSeervi requested review from sideshowbarker and removed request for a team August 10, 2021 04:16
@github-actions
Copy link
Contributor

github-actions bot commented Aug 10, 2021

Preview URLs

Flaws

URL: /en-US/docs/Web/API/MouseEvent
Title: MouseEvent
on GitHub
Flaw count: 1

  • macros:
    • /en-US/docs/Web/API/MouseEvent/mozPressure does not exist

External URLs

URL: /en-US/docs/Web/API/MouseEvent
Title: MouseEvent
on GitHub

No new external URLs

(this comment was updated 2021-08-10 12:54:07.506858)

@teoli2003
Copy link
Contributor

Are you sure the demo is working? I can't get canceled to be displayed in the output field.

@AnilSeervi
Copy link
Contributor Author

Are you sure the demo is working? I can't get canceled to be displayed in the output field.

May I know how canceled triggered in the previous example.

@teoli2003
Copy link
Contributor

teoli2003 commented Aug 10, 2021

I don't know how the original example was working and I think that focusing on the cancelation doesn't bring much.

How about doing this:

<p><label><input type="checkbox" id="checkbox"> Checked</label></p>
<p><button id="button">Click me to send a MouseEvent to the checkbox</button></p>

and

function simulateClick() {

  //Get the element to send a click event to
  let cb = document.getElementById("checkbox"); 
  
  //Create a synthetic click MouseEvent
  let evt = new MouseEvent("click", {
    bubbles: true,
    cancelable: true,
    view: window
  });

  // Send the event to the checkbox element
  cb.dispatchEvent(evt);
 
}

document.getElementById("button").addEventListener('click', simulateClick);

I think it demonstrates the feature better, and does not make use of alert().

@AnilSeervi
Copy link
Contributor Author

Yes, this looks okay.
Will Change to just dispatching the event.

@sideshowbarker sideshowbarker merged commit 9ac9ff2 into mdn:main Aug 10, 2021
@AnilSeervi AnilSeervi deleted the replace-alert()-in-mouseEvent branch August 11, 2021 04:40
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants