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

Hint to use addEventListener instead of the onchange property #28105

Merged
merged 14 commits into from
Jul 24, 2023

Conversation

Tofandel
Copy link
Contributor

@Tofandel Tofandel commented Jul 21, 2023

Description

The onchange is a global and if multiple libraries use it, they will override each other's listener, it's better to recommend the use of addEventListener which I also documented on the linked page instead of screen.orientation.onchange

Motivation

I could not find a proper replacement when looking at the deprecated event and the linked page, because it only proposes a global onchange, I had to google it and find this stackoverflow answer to find that ScreenOrientation supports the use of addEventListener

The onchange is a global and if multiple libraries use it, they will override each other, it's better to recommend the use of `addEventListener` (which is not documented on the linked page)
@Tofandel Tofandel requested a review from a team as a code owner July 21, 2023 09:25
@Tofandel Tofandel requested review from Elchi3 and removed request for a team July 21, 2023 09:25
@github-actions github-actions bot added the Content:WebAPI Web API docs label Jul 21, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Jul 21, 2023

@Tofandel Tofandel requested a review from a team as a code owner July 21, 2023 11:55
@wbamberg
Copy link
Collaborator

@Tofandel , this PR changes every line in our redirects file, I guess from this commit: 30410d3, which gives us a massive diff. Can you tell us what this change is, and why and how you made it?

@sideshowbarker
Copy link
Collaborator

@Tofandel , this PR changes every line in our redirects file, I guess from this commit: 30410d3, which gives us a massive diff. Can you tell us what this change is, and why and how you made it?

That commit had changed all the line ending in the file to Windows CRLF rather than just LF. The substantive part of the change was this:

-/en-US/docs/Web/API/ScreenOrientation/onchange	/en-US/docs/Web/API/ScreenOrientation
+/en-US/docs/Web/API/ScreenOrientation/onchange	/en-US/docs/Web/API/ScreenOrientation#events

…so I backed out the CRLF change and amended and force-pushed the commit to just include that change.

@Tofandel
Copy link
Contributor Author

Tofandel commented Jul 22, 2023

I was using the github UI for those changes so it's a bit weird it changed all the line endings in the txt file but not the md files

Thanks for fixing the commit

@wbamberg
Copy link
Collaborator

Thanks for the PR, @Tofandel , and Mike for fixing the redirects file. It's the weekend here but I will look at this PR on Monday.

Copy link
Collaborator

@wbamberg wbamberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your PR, @Tofandel . You're right that there's work we need to do here but this isn't quite it.

We don't give the onxyz properties their own pages on MDN any more, but we do have pages for the events, which have URLs like xyz_event and titles like xyz, and we list these pages under the "Events" heading in the interface page.

See https://developer.mozilla.org/en-US/docs/Web/API/Animation#events for an example.

So we need a new page at https://developer.mozilla.org/en-US/docs/Web/API/ScreenOrientation/change_event, that describes the event, following a roughly similar pattern to https://developer.mozilla.org/en-US/docs/Web/API/Animation/finish_event (see also the template at https://developer.mozilla.org/en-US/docs/MDN/Writing_guidelines/Page_structures/Page_types/API_event_subpage_template).

Then we can link to that page from the entry at https://pr28105.content.dev.mdn.mozit.cloud/en-US/docs/Web/API/ScreenOrientation#events.

Please let me know if you want to make this change. If you don't I'm happy to close this PR have make the change myself.

@Tofandel
Copy link
Contributor Author

Tofandel commented Jul 24, 2023

@wbamberg This is what I noticed when I copied the events presentation from another api page, but adding a sub page was a bit out of my depth

I added it but I'm not sure why this headers are showing, because I don't think it is in fact experimental and secure context
image

Copy link
Collaborator

@wbamberg wbamberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is pretty great! I had a few comments, mostly copy-edits.

files/en-us/web/api/screenorientation/index.md Outdated Show resolved Hide resolved
files/en-us/web/api/screenorientation/index.md Outdated Show resolved Hide resolved
Copy link
Collaborator

@wbamberg wbamberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 looks awesome, thank you for your contribution, @Tofandel !

@wbamberg wbamberg merged commit 0f1d3cb into mdn:main Jul 24, 2023
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:WebAPI Web API docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants