-
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
Conversation
- Don’t say that navigator.userAgentData.platform is “recommended”; it’s sufficient to just point out that it exists as an alternative. - Since it’s so far only in Blink, say “not yet supported by **most** browsers” rather than “not yet supported by some major browsers. See #14429
For the navigator.platform article, this change replaces the Deprecated_Header macro and its boilerplate text with some more-appropriate alternative pseudo-boilerplate text. See #14429
Preview URLsFlawsURL:
External URLsURL: No new external URLs (this comment was updated 2022-03-31 12:21:10.854391) |
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.
Since I complained about this already, I'm happy to see this! Approving but leaving open in case @hsivonen has a comment.
Co-authored-by: wbamberg <will@bootbonnet.ca>
Thanks. I suggest dropping both instances of the word "yet". |
👍 Made it so in 57fdcf0 |
Marking this as Draft so that we make sure not to merge it until we also get resolution on some of the details discussed in #14429 (comment) |
On further thought, instead of just suggesting the code be updated while also mentioning a Blink-specific API for also doing the discouraged thing it would make sense to mention that in general, Web developers should feature-detect relevant things when applicable and not care about the platform as a general rule. |
Given the spec change at whatwg/html#7762 we no longer have justification for marking navigator.platform as deprecated. Related MDN change: mdn/content#14452
3a31b6a
to
0d3b545
Compare
OK, in light of the spec change at whatwg/html#7762, I’ve gone ahead and completely re-worked this patch to instead do the following:
Related BCD change: mdn/browser-compat-data#15599
In the updated patch, I added some language which tries to give that advice. So @hsivonen and @wbamberg, if you could both review the updated patch, I’d appreciate it. |
Fixes #14429. For the navigator.platform article, this change does the following: - Drop the Deprecated_Header macro. - Add admonishments that navigator.platform should be avoided in favor of feature detection. - Relegate mention of (equally-bad) navigator.userAgentData.platform to just being a "See also". - Add an example of the single known good case where using navigator.platform isn’t completely bad. Related BCD change: mdn/browser-compat-data#15599 Related spec change: whatwg/html#7762
0d3b545
to
5d2d85b
Compare
a51835f
to
e0e202c
Compare
@sideshowbarker @hsivonen Feel free to ask for my review when this is ready to land. That way I know you are done and we can abide by our rule that this is not landed by the author of the PR. |
Thanks — will do |
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. I can't actually pick the "Approve" option, because I'm not an official reviewer for this repo.
@teoli2003 Having gotten @hsivonen’s r+ on this, I think it’s ready to merge. I still hope @wbamberg can take a look at it post-merge and if there’s anything he notices that we missed, I’ll be happy to do a follow-up PR |
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.
Just a tiny change on the first line to make it coherent with the whole of MDN.
Co-authored-by: Jean-Yves Perrier <jypenator@gmail.com>
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'm merging. We can do more changes in follow-up PRs if needed.
Thanks, @hsivonen, @sideshowbarker and @wbamberg to have this sorted out! 🎉
|
||
> **Note:** The recommended alternative to this property is {{domxref("NavigatorUAData.platform", "navigator.userAgentData.platform")}}. However, {{domxref("NavigatorUAData.platform", "navigator.userAgentData.platform")}} is not yet supported by some major browsers, and the specification which defines it has not yet been adopted by any standards group (specifically, it is not part of any specification published by the W3C or WHATWG). |
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 using NavigatorUAData.platform
. The user hints are more fully designed and specified - and while they aren't on all platforms, neither is the value of navigator.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.
@sideshowbarker @teoli2003 Does it make sense to remove the info/links to
NavigatorUAData.platform
?
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.
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
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/.
my take is that you would be much better off using
NavigatorUAData.platform
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 using navigator.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.
and while they aren't on all platforms, neither is the value of
navigator.platform
reliable on any platform.
The key big differences are that navigator.platform
is actually implemented in every browser engine (even if its reliability may vary), and navigator.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".
Thanks! |
Fixes #14429. For the
navigator.platform
article, this change does the following:Deprecated_Header
macro.navigator.platform
should be avoided in favor of feature detection.navigator.userAgentData.platform
to just being a See also.navigator.platform
isn’t completely bad.Related BCD change: mdn/browser-compat-data#15599
Previous/now-superseded issue description…
Given
navigator.userAgentData.platform
is currently only supported in Blink, we shouldn’t be strongly “recommending” it; so 4db8611 drops the “recommended” and instead just points outnavigator.userAgentData.platform
as an alternative — while changing the “not yet supported by some major browsers” wording to instead more accurately state it’s “not yet supported by most browsers”.And given that
navigator.platform
is not formally deprecated by the spec, f73b2d9 replaces theDeprecated_Header
macro and its boilerplate text with some more-appropriate alternative pseudo-boilerplate text that’s intentionally broadly worded in such as way as to not be specific to just thenavigator.platform
case but instead worded for the general case where we want to warn web developers to avoid using a particular feature.See also #12017 (comment).