mdn / content

The content behind MDN Web Docs
https://developer.mozilla.org
Other
9.12k stars 22.46k forks source link

Avoiding duplication/confusion between Location+WorkerLocation and Navigator+WorkerNavigator #6856

Open foolip opened 3 years ago

foolip commented 3 years ago

https://github.com/mdn/browser-compat-data/issues/9125 is a long discussion about the peculiar cases of Location+WorkerLocation and Navigator+WorkerNavigator, which are the only APIs on the web platform where distinct interfaces are used to represent the "same" thing in window and worker contexts.

For example, navigator.userAgent is available in both window and worker contexts, but navigator itself is a different kind of object. (This difference rarely matters in practice.)

BCD will follow the structure of specs/implementations, but on MDN there's duplication that might be possible to avoid. These pairs of pages and their subpages should be considered for merging or cross-linking:

For location it's probably best to keep them separate since the worker variant is read-only. But navigator it's hard to see the usefulness of splits like this: https://developer.mozilla.org/en-US/docs/Web/API/Navigator/languages https://developer.mozilla.org/en-US/docs/Web/API/WorkerNavigator/languages https://developer.mozilla.org/en-US/docs/Web/API/Navigator/locks https://developer.mozilla.org/en-US/docs/Web/API/WorkerNavigator/locks

teoli2003 commented 3 years ago

Also, I think as titles (not slugs), as well as links we should use navigator.xyz (with a lowercase)

foolip commented 3 years ago

I agree with that, but it is a policy which is tricky to draw the line for. history, performance are other case where it's probably a good idea and uncomplicated, but how about:

teoli2003 commented 3 years ago

console is probably a good idea too. (I wasn't suggesting to do this for all cases)

foolip commented 3 years ago

For console there is no debate, the actual name of the namespace is lowercase "console", not "Console". I'd like to see this changed in BCD and MDN :) It's just a little bit awkward as noted in https://console.spec.whatwg.org/#console-namespace the naming is for historical reasons, and will forever be an odd one out unless another mishap occurs.

Elchi3 commented 2 years ago

Not sure if it is useful for the cases discussed here but a while ago we introduced "global" pages:

https://developer.mozilla.org/en-US/docs/Web/API/fetch https://developer.mozilla.org/en-US/docs/Web/API/crypto_property

In BCD, they are stored here. https://github.com/mdn/browser-compat-data/tree/main/api/_globals (See the mdn_urls in the files for a full list of such global pages)

Maybe the same could be done with the remaining properties this issue discusses.