-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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.platform #50385
lib: add navigator.platform #50385
Conversation
0667117
to
42b169f
Compare
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.
FWIW, while this is somewhat standardized, even Deno hasn't implemented it, and the top of the MDN page clearly discourages its use:
This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible (..). Be aware that this feature may cease to work at any time.
I suppose this PR is in line with the option to "add more ancient HTML properties" as outlined in #50269 (comment), so if that's the direction the project is going... 🤷
(FWIW, it would also be spec-compliant to return some useless/incorrect value or potentially even an empty string.)
The MDN is not a reliable source regarding the deprecation of those properties. They only mark it as deprecated because they can not mark something as "avoid as best as you can". Also it is not It is not spec compliant to return an empty string. See whatwg/html#7762 Even Typescript considers the deprecation as a bug: See also for more insights: It is part of whatwg testing: |
I did not use the word "deprecation". If the intended meaning is "avoid as best as you can", as you put it, that is precisely what I am referring to. Node.js applications worked just fine without this property for far more than a decade.
You are right, the spec was changed a while ago. Instead, it is spec-compliant to return an incorrect value now... |
I skimmed the referenced links but I can’t find an answer to why MDN wants to discourage it. Reading https://developer.mozilla.org/en-US/docs/Web/API/Navigator/platform it seems like they discourage its use simply because they recommend using feature detection rather than platform detection; is that your guess as well? I think for Node’s case, sure feature detection is always preferable whenever possible but we have plenty of use cases that absolutely need platform detection, such as choosing a particular binary to run. We don’t discourage the use of |
Let’s please ping @nodejs/web-standards for all issues and PRs related to |
Yes, it seems to be very similar to #50385 (comment). In either case, it’s not clear why MDN is intending to discourage the use of this API, other than perhaps because they think feature detection is a better approach in general. Is that your impression or is there some other reason? |
@GeoffreyBooth I think that's the main idea, but the spec also allows browser to return entirely incorrect values for privacy, so developers should not rely on |
Yes, I think so too. Btw. I am willing to add more attributes, but some stuff seems odd, like navigator.appName is always 'Navigator' for compatibility reasons. So should it be also added? So yes, I hope we get to an agreement soon, so that we can finish this object as best as possible. |
I think we can keep adding properties regardless of what other PRs are floating out there. No one has put up a PR to fully delete the global, just to flag it, so even if it gets flagged it should still have whatever properties we think it should have. I’m inclined to add |
Hmm. I consider to work again on this in few hours. creating a new function called getNavigatorPlatform, which expects an optional parameter of shape { platform, arch }, which by default gets process. |
I don’t think this is necessary. Our CI already runs the test suite on every supported platform, so every branch of the Ideally that last assertion, for the miscellaneous Linux platforms, would assert against plain strings but it would be a pain to figure out what all of those should be. You could assert against a temporary string like |
It appears that |
961a62f
to
66e2ffc
Compare
This one I'm genuinely not convinced we should export. As has been pointed out in discussion there are a number of issues with this, not the least of which being that even browsers recommend against relying on it. I note that |
The reason it was implemented was because Next.js relies on the prop when |
Please merge :) |
Or maybe @H4ad ? |
Landed in a450eed |
PR-URL: nodejs#50385 Reviewed-By: Geoffrey Booth <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: James M Snell <[email protected]>
PR-URL: #50385 Reviewed-By: Geoffrey Booth <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: James M Snell <[email protected]>
Notable changes: doc: * add MrJithil to collaborators (Jithil P Ponnan) #50666 * add Ethan-Arrowood as a collaborator (Ethan Arrowood) #50393 esm: * (SEMVER-MINOR) add import.meta.dirname and import.meta.filename (James Sumners) #48740 fs: * add stacktrace to fs/promises (翠 / green) #49849 lib: * (SEMVER-MINOR) add navigator.platform (Aras Abbasi) #50385 stream: * (SEMVER-MINOR) add support for `deflate-raw` format to webstreams compression (Damian Krzeminski) #50097 * use Array for Readable buffer (Robert Nagy) #50341 * optimize creation (Robert Nagy) #50337 test_runner: * adds built in lcov reporter (Phil Nash) #50018 * (SEMVER-MINOR) add Date to the supported mock APIs (Lucas Santos) #48638 test_runner, cli: * (SEMVER-MINOR) add --test-timeout flag (Shubham Pandey) #50443 PR-URL: #50681
Notable changes: doc: * add MrJithil to collaborators (Jithil P Ponnan) #50666 * add Ethan-Arrowood as a collaborator (Ethan Arrowood) #50393 esm: * (SEMVER-MINOR) add import.meta.dirname and import.meta.filename (James Sumners) #48740 fs: * add stacktrace to fs/promises (翠 / green) #49849 lib: * (SEMVER-MINOR) add `--no-experimental-global-navigator` CLI flag (Antoine du Hamel) #50562 * (SEMVER-MINOR) add navigator.language & navigator.languages (Aras Abbasi) #50303 * (SEMVER-MINOR) add navigator.platform (Aras Abbasi) #50385 stream: * (SEMVER-MINOR) add support for `deflate-raw` format to webstreams compression (Damian Krzeminski) #50097 * use Array for Readable buffer (Robert Nagy) #50341 * optimize creation (Robert Nagy) #50337 test_runner: * (SEMVER-MINOR) adds built in lcov reporter (Phil Nash) #50018 * (SEMVER-MINOR) add Date to the supported mock APIs (Lucas Santos) #48638 test_runner, cli: * (SEMVER-MINOR) add --test-timeout flag (Shubham Pandey) #50443 PR-URL: #50681
PR-URL: #50385 Reviewed-By: Geoffrey Booth <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: James M Snell <[email protected]>
Notable changes: doc: * add MrJithil to collaborators (Jithil P Ponnan) #50666 * add Ethan-Arrowood as a collaborator (Ethan Arrowood) #50393 esm: * (SEMVER-MINOR) add import.meta.dirname and import.meta.filename (James Sumners) #48740 fs: * add stacktrace to fs/promises (翠 / green) #49849 lib: * (SEMVER-MINOR) add `--no-experimental-global-navigator` CLI flag (Antoine du Hamel) #50562 * (SEMVER-MINOR) add navigator.language & navigator.languages (Aras Abbasi) #50303 * (SEMVER-MINOR) add navigator.platform (Aras Abbasi) #50385 stream: * (SEMVER-MINOR) add support for `deflate-raw` format to webstreams compression (Damian Krzeminski) #50097 * use Array for Readable buffer (Robert Nagy) #50341 * optimize creation (Robert Nagy) #50337 test_runner: * (SEMVER-MINOR) adds built in lcov reporter (Phil Nash) #50018 * (SEMVER-MINOR) add Date to the supported mock APIs (Lucas Santos) #48638 test_runner, cli: * (SEMVER-MINOR) add --test-timeout flag (Shubham Pandey) #50443 PR-URL: #50681
Notable changes: doc: * add MrJithil to collaborators (Jithil P Ponnan) #50666 * add Ethan-Arrowood as a collaborator (Ethan Arrowood) #50393 esm: * (SEMVER-MINOR) add import.meta.dirname and import.meta.filename (James Sumners) #48740 fs: * add stacktrace to fs/promises (翠 / green) #49849 lib: * (SEMVER-MINOR) add `--no-experimental-global-navigator` CLI flag (Antoine du Hamel) #50562 * (SEMVER-MINOR) add navigator.language & navigator.languages (Aras Abbasi) #50303 * (SEMVER-MINOR) add navigator.platform (Aras Abbasi) #50385 stream: * (SEMVER-MINOR) add support for `deflate-raw` format to webstreams compression (Damian Krzeminski) #50097 * use Array for Readable buffer (Robert Nagy) #50341 * optimize creation (Robert Nagy) #50337 test_runner: * (SEMVER-MINOR) adds built in lcov reporter (Phil Nash) #50018 * (SEMVER-MINOR) add Date to the supported mock APIs (Lucas Santos) #48638 test_runner, cli: * (SEMVER-MINOR) add --test-timeout flag (Shubham Pandey) #50443 PR-URL: #50681
Notable changes: doc: * add MrJithil to collaborators (Jithil P Ponnan) nodejs#50666 * add Ethan-Arrowood as a collaborator (Ethan Arrowood) nodejs#50393 esm: * (SEMVER-MINOR) add import.meta.dirname and import.meta.filename (James Sumners) nodejs#48740 fs: * add stacktrace to fs/promises (翠 / green) nodejs#49849 lib: * (SEMVER-MINOR) add `--no-experimental-global-navigator` CLI flag (Antoine du Hamel) nodejs#50562 * (SEMVER-MINOR) add navigator.language & navigator.languages (Aras Abbasi) nodejs#50303 * (SEMVER-MINOR) add navigator.platform (Aras Abbasi) nodejs#50385 stream: * (SEMVER-MINOR) add support for `deflate-raw` format to webstreams compression (Damian Krzeminski) nodejs#50097 * use Array for Readable buffer (Robert Nagy) nodejs#50341 * optimize creation (Robert Nagy) nodejs#50337 test_runner: * (SEMVER-MINOR) adds built in lcov reporter (Phil Nash) nodejs#50018 * (SEMVER-MINOR) add Date to the supported mock APIs (Lucas Santos) nodejs#48638 test_runner, cli: * (SEMVER-MINOR) add --test-timeout flag (Shubham Pandey) nodejs#50443 PR-URL: nodejs#50681
adds navigator.platform