-
Notifications
You must be signed in to change notification settings - Fork 22.6k
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
Update index.md #20048
Update index.md #20048
Conversation
at first glance it looks like the dragenter event was missed, then it's celar you put only dragover on both cases to show that you can cancel the even by employing ether way, I just aim to make it so the codeblobk guides more by including both necessary events.
Preview URLsFlawsURL:
External URLsURL: No new external URLs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @pauIbanez , and thanks for your PR!
I agree that some change like this would be an improvement. However, note that the attribute has an on
prefix.
However, we should not use HTML event handler properties in our examples! See https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Building_blocks/Events#inline_event_handlers_%E2%80%94_dont_use_these.
So I think it would be better to rewrite this section to use addEventListener()
and preventDefault()
- something like:
If you want to allow a drop, you must prevent the default handling by cancelling both the
dragenter
and dragover events by calling theirpreventDefault()
method:element.addEventListener('dragenter', e => {e.preventDefault()}); element.addEventListener('dragover', e => {e.preventDefault()});
We should also go through this whole page replacing HTML event attributes with addEventListener
- for example the page also does this at https://github.com/mdn/content/blob/main/files/en-us/web/api/html_drag_and_drop_api/drag_operations/index.md?plain=1#L32.
Please let me know if you want to do this, or you'd rather I close this PR and make these updates myself.
You can close and make the changes yourself. I agree on the formatting ofc, and sorry for the on prefixes. I was doing research while working with react and I used react's events instead of the vanila ones. Thank you for your service to the comunity! |
Thanks for letting me know! I just filed #20403 for this. |
at first glance it looks like the dragenter event was missed, then it's celar you put only dragover on both cases to show that you can cancel the even by employing ether way, I just aim to make it so the codeblobk guides more by including both necessary events.
Summary
Motivation
Supporting details
Related issues
Metadata