Web APIs' toJSON() method description is misleading
- Dominant language
- Markdown
- Stars
- 11k
- Forks
- 23.2k
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 331
Description
### MDN URL
https://developer.mozilla.org/en-US/docs/Web/API/DOMRectReadOnly
### What specific section or headline is this issue about?
DOMRect.toJSON
### What information was incorrect, unhelpful, or incomplete?
The text "_Returns a JSON representation of the DOMRectReadOnly object_" for `DOMRect.toJSON` (actually the `toJSON` method of `DOMRectReadOnly`) is misleading.
The method does _not_ return the DOMRect instance as Javascript String Object Notation (so a string), but a plain Object.
### What did you expect to see?
I expect calling `DOMRect.toJSON()` will return a JSON string.
But, trying to use the `DOMRect.toJSON` return value as actual JSON throws a `SyntaxError`.
### Do you have any supporting links, references, or citations?
Posted before in [discourse.mozilla.org](https://discourse.mozilla.org/t/domrect-tojson-is-misleading/143963)
The mentioned text can be found in [https://developer.mozilla.org/en-US/docs/Web/API/DOMRectReadOnly#instance_methods](https://developer.mozilla.org/en-US/docs/Web/API/DOMRectReadOnly#instance_methods)
### Do you have anything more you want to share?
Either the aforementioned _text_, the _method name_ (`toJSON`) or the _method return value_ should be changed imho.
### MDN metadata
Page report details
* Folder: `en-us/web/api/domrectreadonly`
* MDN URL: https://developer.mozilla.org/en-US/docs/Web/API/DOMRectReadOnly
* GitHub URL: https://github.com/mdn/content/blob/main/files/en-us/web/api/domrectreadonly/index.md
* Last commit: https://github.com/mdn/content/commit/9f09d944bca13b61293b4cc93cb52011c6134b0d
* Document last modified: 2024-11-16T01:07:04.000Z
Contributor guide
Assessment
This issue has not been assessed yet.