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

api.Element.replaceWith - Misleading details and prototype #21497

Open
WebReflection opened this issue Oct 11, 2022 · 5 comments
Open

api.Element.replaceWith - Misleading details and prototype #21497

WebReflection opened this issue Oct 11, 2022 · 5 comments

Comments

@WebReflection
Copy link
Contributor

What type of issue is this?

Other

What information was incorrect, unhelpful, or incomplete?

As you correctly link to the standard, replaceWith is a ChildNode mixin and not an Element method.

That means that even text nodes or comments can use replaceWith while not being instanceof Element.

This is rather a misleading link in MDN, but also changing it would kinda rot such misleading information, so something must change though, as the info is everything but reliable or accurate.

What browsers does this problem apply to, if applicable?

No response

What did you expect to see?

At least a link to ChildNode mixin, but also nothing strictly related to Element prototype.

Did you test this? If so, how?

document.createComment('').replaceWith ; // function
document.createComment('') instanceof Element; // false

Can you link to any release notes, bugs, pull requests, or MDN pages related to this?

https://dom.spec.whatwg.org/#interface-childnode

Do you have anything more you want to share?

No response

MDN URL

https://developer.mozilla.org/en-US/docs/Web/API/Element/replaceWith

MDN metadata

MDN page report details
  • Query: api.Element.replaceWith
  • Report started: 2022-10-11T19:41:59.573Z
@WebReflection WebReflection changed the title api.Element.replaceWith - <SUMMARIZE THE PROBLEM> api.Element.replaceWith - Misleading details and prototype Oct 11, 2022
@queengooborg
Copy link
Collaborator

What are you expecting to see instead of what is currently written? Are you looking to see pages created for "Node.replaceWith" and "Comment.replaceWith"?

A while back, we had stripped out all mixins from MDN and merged their members into the interfaces that use them, as documenting them separately caused more reader confusion and was much harder to properly maintain the BCD for.

@queengooborg queengooborg transferred this issue from mdn/browser-compat-data Oct 12, 2022
@github-actions github-actions bot added needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. Content:WebAPI Web API docs labels Oct 12, 2022
@sideshowbarker sideshowbarker added needs info Needs more information to review or act on. and removed needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. labels Oct 12, 2022
@WebReflection
Copy link
Contributor Author

@queengooborg I am expecting to see a mention about being available on CharacterData too so that anyone landing on Element, as that's what most developers use as reference, would instantly recognize the method usable with text and comments too. The page is already there so maybe this is an easy improvement? Thanks.

@sideshowbarker sideshowbarker removed the needs info Needs more information to review or act on. label Oct 12, 2022
@pygy
Copy link
Contributor

pygy commented Jan 29, 2024

As far as I can tell, the ChildNode mixin is mixed into Node, not Element. That's why it also applies to TextNode and Comment

I think that .after(), .before(), .remove() and .replaceWith() should thus be moved to Node.

@WebReflection
Copy link
Contributor Author

@pygy that's fair but to me a bit misleading because even attributes are nodes but that mixin doesn't apply ... so, technically speaking, I think the mixin related page should be the best for everyone, but surely Element only, as it is, feels really off the MDN purpose itself, as it's quite misleading.

@pygy
Copy link
Contributor

pygy commented Jan 29, 2024

Oh, indeed, I had missed the CharacterData entry.

Conceptually, ChildNode could be defined as an abstract interface like CharacterData, (snuck as a Node child in the inheritance hierarchy).

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

No branches or pull requests

5 participants