| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
There was a problem hiding this comment.
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.)
Sorry, something went wrong.
|
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: |
Sorry, something went wrong.
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... |
Sorry, something went wrong.
|
Can someome please retrigger macos build? The build error should be independent from this PR. |
Sorry, something went wrong.
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 process.platform, after all. So I think it would be good for us to add this, to give developers a cross-runtime way of doing platform detection. |
Sorry, something went wrong.
|
Let’s please ping @nodejs/web-standards for all issues and PRs related to navigator. |
Sorry, something went wrong.
|
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? |
Sorry, something went wrong.
@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 navigator.platform in any case. |
Sorry, something went wrong.
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. |
Sorry, something went wrong.
|
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 platform and really any other property that makes even remote sense, because it’s better to have a property exist than not, for code that might break when checking for it and assuming its existence. |
Sorry, something went wrong.
Sorry, something went wrong.
|
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. |
Sorry, something went wrong.
Sorry, something went wrong.
I don’t think this is necessary. Our CI already runs the test suite on every supported platform, so every branch of the if is already getting checked, albeit not in the same run. 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 ‘TODO’ and I can run CI and you can look at the CI output on each failing platform to see what the string could be for that platform, and then we can put that in here. I’m not sure it’s worth the effort though. |
Sorry, something went wrong.
|
It appears that platform is also a valid part of the spec. |
Sorry, something went wrong.
|
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 bun implements it but deno doesn't. That said, a quick code search on github shows 66k JS files using this for various purposes so perhaps it is worthwhile? @Uzlopak ... can you expand a bit on the use case you have in mind for this? |
Sorry, something went wrong.
|
The reason it was implemented was because Next.js relies on the prop when Navigator is available globally. |
Sorry, something went wrong.
Sorry, something went wrong.
|
Please merge :) |
Sorry, something went wrong.
PR-URL: #50385 Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: James M Snell <jasnell@gmail.com>
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 <webadmin@geoffreybooth.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: James M Snell <jasnell@gmail.com>
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
| Back | FazBrowse Home | New Git URL |
adds navigator.platform