-
Notifications
You must be signed in to change notification settings - Fork 22.5k
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
Un-deprecate navigator.platform (was: Replace Deprecated_Header in navigator.platform doc and adjust navigator.userAgentData.platform note wording) #14452
Merged
teoli2003
merged 9 commits into
main
from
sideshowbarker/navigator.platform-discouraged
Mar 31, 2022
Merged
Changes from 2 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
4db8611
Adjust wording of note about navigator.userAgentData.platform
sideshowbarker f73b2d9
Replace Deprecated_Header in navigator.platform doc
sideshowbarker 43505ac
Update files/en-us/web/api/navigator/platform/index.md
sideshowbarker 57fdcf0
Drop “yet” in text about navigator.userAgentData.platform not being s…
sideshowbarker 5d2d85b
Un-deprecate navigator.platform; improve advice and example
sideshowbarker e0e202c
Refine explanation of matching on navigator.platform value
sideshowbarker 0475b6d
Fix markdown formatting of example navigator.platform values
sideshowbarker d17aee1
Grammar fix
sideshowbarker f87bca0
Update files/en-us/web/api/navigator/platform/index.md
sideshowbarker File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@sideshowbarker @teoli2003 Does it make sense to remove the info/links to
NavigatorUAData.platform
?I understand the desire to point to feature detection, and the reasoning why
navigator.platform
shouldn't be deprecated.But despite the spec change to
navigator.platform
my take is that you would be much better off usingNavigatorUAData.platform
. The user hints are more fully designed and specified - and while they aren't on all platforms, neither is the value ofnavigator.platform
reliable on any platform.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.
I think it doesn’t make sense to remove it completely — which is why I moved it to being a See Also — but I think given the current state of things, it doesn’t make sense to give it as much prominence as it had.
I think giving it that amount of prominence made sense when we had
navigator.platform
marked as Deprecated — because in that case, we actually had people asking, OK, if this is deprecated, then what’s the alternative?But as the fact that #14429 was raised kind of shows, we create a different problem when when we give this particular alternative the kind of prominence we were giving it — especially if we say it’s recommended.
One thing we need to recognize is the people who work on non-Blink/Chrome browsers projects are not super happy if MDN promotes the use of some feature to developers when the current reality of that feature is that in practice it’s a Blink-only feature — even when that feature has a well-intentioned actively-maintained spec.
But it doesn’t matter how good the spec is if other browser projects aren’t implementing and it and aren’t even showing interest. And in the specific case of Client Hints, there was even at one time some discussion about having https://mozilla.github.io/standards-positions/ list is a Harmful.
It’s now marked “non-harmful” there but anyway we need to recognize that the Mozilla engineering team does not seem to be any interest in ever implementing Client Hints.
And while the Safari/WebKit team also doesn’t seem opposed to ever implementing Client Hints (see https://lists.webkit.org/pipermail/webkit-dev/2020-May/thread.html#31195), working on actually implementing doesn’t seem to be any significant priority for them — to the point that they haven’t even bothered to list it at https://webkit.org/status/.
After looking through a lot of
navigator.platform
usages in Stack Overflow questions and answers in GitHub code, I can say that in nearly all cases where people are usingnavigator.platform
in code, they are not using it for good reasons — and the kinds of things they are doing are things that we actually want to discourage developers from doing.The same goes for ways in which somebody might use
NavigatorUAData.platform
— the underlying problem with both properties is that it’s fundamentally a bad idea to try to be finding out information about the user’s environment rather than only relying on feature detection.I am aware of only one single case in which it makes sense to try and get information about the user’s platform — and that’s the deciding-on-which-modifier-key-to-advise-to-the-user case which I added an example for in the patch here.
Other than that one case, I’m not aware of even a single other best-practice case of something to do in code based on finding out information about the user’s platform — whether by using
navigator.platform
or with Client Hints.The key big differences are that
navigator.platform
is actually implemented in every browser engine (even if its reliability may vary), andnavigator.platform
is part of a standard that’s gone through the process of getting agreement and endorsements among multiple browser projects.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.
Thanks for the detailed explanation. I can get on board with it being a "see also".