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

Add HTMLBaseElement.href docs #31464

Merged
merged 10 commits into from
Jul 12, 2024
Merged

Conversation

teoli2003
Copy link
Member

This adds the missing HTMLBaseElement.href page.

Part of the project to document all interoperable features (mdn/discussions#476)

@teoli2003 teoli2003 requested a review from a team as a code owner January 2, 2024 11:03
@teoli2003 teoli2003 requested review from Elchi3 and removed request for a team January 2, 2024 11:03
@github-actions github-actions bot added the Content:WebAPI Web API docs label Jan 2, 2024
Copy link
Contributor

github-actions bot commented Jan 2, 2024

Preview URLs

(comment last updated: 2024-07-12 00:52:24)

Co-authored-by: skyclouds2001 <95597335+skyclouds2001@users.noreply.github.com>

{{APIRef("HTML DOM")}}

The **`href`** property of the {{domxref("HTMLBaseElement")}} interface contains a string that is the URL to use as the base for relative URLs, like links pointing to a fragment in the document (`<a href="#example">`).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like "like" here, because it tends to be an ambiguous word. "such as" would be better. But I'm not sure whether we need this clause at all. Better would be to make "relative links" link to a proper explanation: https://developer.mozilla.org/en-US/docs/Learn/HTML/Introduction_to_HTML/Creating_hyperlinks#absolute_versus_relative_urls might do, although I wonder if this would be a suitable glossary topic, or if we could extend https://developer.mozilla.org/en-US/docs/Glossary/URL to cover it.

files/en-us/web/api/htmlbaseelement/href/index.md Outdated Show resolved Hide resolved
files/en-us/web/api/htmlbaseelement/href/index.md Outdated Show resolved Hide resolved
files/en-us/web/api/htmlbaseelement/href/index.md Outdated Show resolved Hide resolved
```js
const base = document.getElementsByTag("base")[0];
console.log(base.href); // 'https://developer.mozilla.org/example'
```
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also show the result if there is no href attribute?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there can only be one base element in a page, so we can't include two in a single example; opting to not include and target-only <base> example.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could have two examples. I'd have done that, except that this violates CSP and I get an error for that case.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I think is OK without both. The expected behaviour is stated.

@wbamberg wbamberg added the awaiting response Awaiting for author to address review/feedback label Mar 28, 2024
@github-actions github-actions bot added the size/s [PR only] 6-50 LoC changed label Jun 27, 2024
estelle and others added 2 commits July 9, 2024 23:43
Co-authored-by: wbamberg <will@bootbonnet.ca>
Co-authored-by: wbamberg <will@bootbonnet.ca>
Copy link
Member

@estelle estelle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

edits per review

files/en-us/web/api/htmlbaseelement/href/index.md Outdated Show resolved Hide resolved
files/en-us/web/api/htmlbaseelement/href/index.md Outdated Show resolved Hide resolved
```js
const base = document.getElementsByTag("base")[0];
console.log(base.href); // 'https://developer.mozilla.org/example'
```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there can only be one base element in a page, so we can't include two in a single example; opting to not include and target-only <base> example.

files/en-us/web/api/htmlbaseelement/href/index.md Outdated Show resolved Hide resolved
@estelle estelle requested a review from wbamberg July 10, 2024 06:48
@estelle
Copy link
Member

estelle commented Jul 10, 2024

@wbamberg when you have a chance, a re-review would be great.

@github-actions github-actions bot added size/m [PR only] 51-500 LoC changed and removed size/s [PR only] 6-50 LoC changed labels Jul 12, 2024
Copy link
Collaborator

@hamishwillee hamishwillee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've made the example into a live example. Merging as this is now IMO sufficient (and Will is on holiday).

@hamishwillee hamishwillee merged commit 3eed3a7 into mdn:main Jul 12, 2024
8 checks passed
evelinabe pushed a commit to evelinabe/mdn-content that referenced this pull request Jul 12, 2024
* Add HTMLBaseElement.href docs

* Update files/en-us/web/api/htmlbaseelement/href/index.md

Co-authored-by: skyclouds2001 <95597335+skyclouds2001@users.noreply.github.com>

* Update files/en-us/web/api/htmlbaseelement/href/index.md

* Update files/en-us/web/api/htmlbaseelement/href/index.md

Co-authored-by: wbamberg <will@bootbonnet.ca>

* Update files/en-us/web/api/htmlbaseelement/href/index.md

Co-authored-by: wbamberg <will@bootbonnet.ca>

* Apply suggestions from code review

* Apply suggestions from code review

* Make example into live example

* Update files/en-us/web/api/htmlbaseelement/href/index.md

---------

Co-authored-by: skyclouds2001 <95597335+skyclouds2001@users.noreply.github.com>
Co-authored-by: Estelle Weyl <estelle@weyl.org>
Co-authored-by: Estelle Weyl <estelle@openwebdocs.org>
Co-authored-by: wbamberg <will@bootbonnet.ca>
Co-authored-by: Hamish Willee <hamishwillee@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting response Awaiting for author to address review/feedback Content:WebAPI Web API docs size/m [PR only] 51-500 LoC changed
5 participants