Skip to content
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

Location: port property incorrectly documented #35732

Closed
rotu opened this issue Sep 4, 2024 · 4 comments · Fixed by #36105
Closed

Location: port property incorrectly documented #35732

rotu opened this issue Sep 4, 2024 · 4 comments · Fixed by #36105
Labels
Content:WebAPI Web API docs help wanted If you know something about this topic, we would love your help!

Comments

@rotu
Copy link
Contributor

rotu commented Sep 4, 2024

MDN URL

https://developer.mozilla.org/en-US/docs/Web/API/Location/port

What specific section or headline is this issue about?

Example and description

What information was incorrect, unhelpful, or incomplete?

Example and description are incorrect according to Firefox, Chrome, and Safari.

Description:

The port property of the Location interface is a string containing the port number of the URL. If the URL does not contain an explicit port number, it will be set to ''.

Example:

// Let's an <a id="myAnchor" href="https://developer.mozilla.org:443/en-US/docs/Location.port"> element be in the document
const anchor = document.getElementByID("myAnchor");
const result = anchor.port; // Returns:'443'
let a = document.createElement("a");
a.href = 'https://developer.mozilla.org:443/en-US/docs/Location.port';
console.log(a.port) // prints ""

What did you expect to see?

Port seems to be null if the url has the default port for the protocol, not just if it's unset.

If the example was correct, it should probably have an indication of WHEN it changed.

Do you have any supporting links, references, or citations?

No response

Do you have anything more you want to share?

No response

MDN metadata

Page report details
@rotu rotu added the needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. label Sep 4, 2024
@github-actions github-actions bot added the Content:WebAPI Web API docs label Sep 4, 2024
@Josh-Cena Josh-Cena added help wanted If you know something about this topic, we would love your help! and removed needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. labels Sep 4, 2024
@Josh-Cena
Copy link
Member

We should add the same info as https://developer.mozilla.org/en-US/docs/Web/API/URL/port.

@rotu
Copy link
Contributor Author

rotu commented Sep 4, 2024

Even that could use rewording.

The port property of the URL interface is a string containing the port number of the URL.

Maybe instead something like "The port property is a string which is either "" or the port number of the URL."

A URL object normalizes it to "" if the same as the per-protocol default. But I'm not sure if that means the Location object must do the same.

@skyclouds2001
Copy link
Contributor

skyclouds2001 commented Sep 29, 2024

And another issue is that the example is explaining HTMLAnchorElement.port, not Location.port

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:WebAPI Web API docs help wanted If you know something about this topic, we would love your help!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants