mdn / content

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

deleteFromDocument deletes more than just text #34943

Closed John-Page closed 4 days ago

John-Page commented 1 month ago

MDN URL

https://developer.mozilla.org/en-US/docs/Web/API/Selection/deleteFromDocument

What specific section or headline is this issue about?

First paragraph

What information was incorrect, unhelpful, or incomplete?

It says the method deletes the text in the selection This implies (to me anyway) that it deleted the text nodes or perhaps empties them out. In my tests it actually deletes everything in the selection. I have a div full of text, embedded divs., images etc. If I select the whole thing and call deleteFromDocument(), the embedded divs imgs etc are completely removed. (That's good - that's what was hoping).

What did you expect to see?

Clarity on what is actually removed.

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 * Folder: `en-us/web/api/selection/deletefromdocument` * MDN URL: https://developer.mozilla.org/en-US/docs/Web/API/Selection/deleteFromDocument * GitHub URL: https://github.com/mdn/content/blob/main/files/en-us/web/api/selection/deletefromdocument/index.md * Last commit: https://github.com/mdn/content/commit/f2f9346c0c0e9f6676f2df9f1850933e274401de * Document last modified: 2023-04-08T06:00:31.000Z
Josh-Cena commented 1 month ago

This method just calls https://developer.mozilla.org/en-US/docs/Web/API/Range/deleteContents, and I agree both methods' pages are very thin. They should mention what exactly gets deleted.