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

dataset is also available on SVGElement #22352

Open
Joozty opened this issue Nov 16, 2022 · 3 comments
Open

dataset is also available on SVGElement #22352

Joozty opened this issue Nov 16, 2022 · 3 comments
Labels

Comments

@Joozty
Copy link
Contributor

Joozty commented Nov 16, 2022

MDN URL

https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/dataset

What specific section or headline is this issue about?

No response

What information was incorrect, unhelpful, or incomplete?

The documentation states that the dataset is only available on HTMLElement which seems to be wrong. According to the spec, it is defined on Element

What did you expect to see?

Element.dataset in the heading instead of HTMLElement.dataset

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

https://html.spec.whatwg.org/multipage/dom.html#dom-dataset-dev

const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg')
svg.dataset
// returns DOMStringMap {}
svg instanceof HTMLElement
// returns false
svg instanceof Element
// returns true

Do you have anything more you want to share?

No response

@github-actions github-actions bot added the needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. label Nov 16, 2022
@sideshowbarker sideshowbarker added the Content:WebAPI Web API docs label Nov 17, 2022
@sideshowbarker
Copy link
Collaborator

Yeah, an element created with a http://www.w3.org/2000/svg namespace is never going to be an HTMLElement.

But if you instead do:

const p = document.createElement("p")
e instanceof HTMLElement
// returns true

And the https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/dataset page documents the dataset property of the HTMLElement object.

The documentation states that the dataset is only available on HTMLElement

https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/dataset doesn’t say it’s only available on HTMLElement — instead it just documents that it’s available on HTMLElement, period.

which seems to be wrong. According to the spec, it is defined on Element

https://html.spec.whatwg.org/multipage/dom.html#elements-in-the-dom:dom-dataset documents is as being a member of the HTMLOrSVGElement mixin, and at https://html.spec.whatwg.org/multipage/dom.html#elements-in-the-dom:htmlorsvgelement, the spec documents that the HTMLElement object includes the HTMLOrSVGElement mixin.

https://developer.mozilla.org/en-US/docs/Web/API/SVGElement documents that the SVGElement object has a dataset property.

I guess what’s misleading here is that if you follow the SVGElement.dataset link on that https://developer.mozilla.org/en-US/docs/Web/API/SVGElement, it takes you to the https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/dataset page — and I guess that’s less than ideal, but it’s somewhat a consequence of the fact that we don’t document mixins as such in MDN.

@sideshowbarker sideshowbarker removed the needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. label Nov 17, 2022
@wbamberg
Copy link
Collaborator

wbamberg commented Dec 3, 2022

I guess what’s misleading here is that if you follow the SVGElement.dataset link on that https://developer.mozilla.org/en-US/docs/Web/API/SVGElement, it takes you to the https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/dataset page — and I guess that’s less than ideal, but it’s somewhat a consequence of the fact that we don’t document mixins as such in MDN.

Yes, this bit is surely just wrong. It's a redirect:

/en-US/docs/Web/API/SVGElement/dataset	/en-US/docs/Web/API/HTMLElement/dataset

Given that we don't document mixins, we have to document the features they contain separately on the interfaces they inherit from. So the best thing to do would be to write a page at https://developer.mozilla.org/en-US/docs/Web/API/SVGElement/dataset, and change that link to point to it.

@Josh-Cena Josh-Cena changed the title dataset is defined on Element not HTMLElement dataset is also available on SVGElement Jan 9, 2023
@Josh-Cena Josh-Cena added the document not written Missing document page label Jan 9, 2023
@Josh-Cena
Copy link
Member

Cross linking #6519

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants