-
Notifications
You must be signed in to change notification settings - Fork 29.1k
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
lib: add navigator legacy attributes #50521
Conversation
Review requested:
|
I think “legacy” is a better name for these than “dummy.” They’re basically harmless, kept around to avoid breaking very old scripts; though I wonder how many such scripts anyone would actually likely try to run in Node.
navigator.userAgent
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36'
navigator.appVersion
'5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36' |
To be honest the appVersion was the most dubios attribute of them all. It is not clear what the "version" is actually. What does the version 5.0 refer to? You use Google Chrome v118.0.0 but it says version 5.0? In the spec it says use version "4.0" or the correct version. But it seems to me that version 5.0 refers to the supported html version, which is html5. But we dont have html support anyway. So I just added the trail, which is basically the same as userAgent. wdyt |
If you’re following the spec for Sure let’s land these, but maybe open an issue to discuss what remaining |
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 wonder if it is a good idea to bloat the documentation with all these properties that are standardized and that nobody should use.
This property is kept only for compatibility purposes.
Do we have any empirical data about this? It looks like none of the other server runtimes implemented these properties.
<!-- YAML | ||
added: REPLACEME | ||
--> | ||
|
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.
> Stability: 3 - Legacy. | |
<!-- YAML | ||
added: REPLACEME | ||
--> | ||
|
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.
> Stability: 3 - Legacy. | |
<!-- YAML | ||
added: REPLACEME | ||
--> | ||
|
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.
> Stability: 3 - Legacy. | |
<!-- YAML | ||
added: REPLACEME | ||
--> | ||
|
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.
> Stability: 3 - Legacy. | |
<!-- YAML | ||
added: REPLACEME | ||
--> | ||
|
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.
> Stability: 3 - Legacy. | |
<!-- YAML | ||
added: REPLACEME | ||
--> | ||
|
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.
> Stability: 3 - Legacy. | |
<!-- YAML | ||
added: REPLACEME | ||
--> | ||
|
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.
> Stability: 3 - Legacy. | |
Filed wintercg/proposal-common-minimum-api#61 to discuss the inclusion of legacy attributes. (Note: Node.js didn't declare itself to be a WinterCG runtime at the moment so this is not a blocker) |
@tniessen The overall API is defined as experimental so we I think we shouldn’t declare individual properties as legacy until at least the overall API is stable. We could mention that their use is discouraged in general, but generally try to avoid repeating what MDN covers. |
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.
These properties have no purpose being in node, even for compatibility reasons. Plus, having them as part of navigator -- a global -- unflagged & not marked as legacy encourages their use.
To be honest, i am not like this PR would be the shining part of my CV :D. I just provided this PR for the sake of completeness. And if we decide that it is a bad idea, then we can just close it. Regarding the documentation i agree. I just followed the usual pattern. Because of the remarks i think we can simplify it and put it into a paragraph and a list the attributes in a two column table, with key and value. |
We’re unlikely to ever implement all of the Why don’t you open an issue where we can discuss what, if any, other |
I get what you say. But it helps to see the actual code and what the shape of it will be. If we discuss it abstract we see maybe the issues in the final PR. So it is better to see, what we actually talking about. Also tbh. I dont see it as wasted effort. It helps me to orientate better in the nodejs codebase and improving my skills ;). |
Sure, whatever you want. I know for myself I find it frustrating to invest time into a PR that never lands. Looking at https://developer.mozilla.org/en-US/docs/Web/API/Navigator, the APIs that I would be most interested in are:
|
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 really have to question adding these. They are not implemented by other non-browser runtimes so will not benefit interop and they really serve no purpose otherwise. Just because we added navigator
it doesn't mean we have to support everything that exists in the browser navigator
object.
@GeoffreyBooth |
It doesn’t really matter either way. We can always reopen. I think what would tip the scale toward wanting to land this is if any of these APIs were actually used by some library for some purpose, where it helps compatibility for Node to support them. Like if there’s some realistic client-side library that can’t run in Node without these but could run with these, then there’s a clear reason why adding them is beneficial. But absent at least one such example, it seems like we’re adding maintenance burden for no benefit. |
I agree ;) |
This PR adds the "dummy" attributes to the navigator instance, like navigator.product or navigator.appName.
I know this PR will get alot of heat and I am just providing this just for the sake of completeness and for discussion.