Issue with "Node.nodeName": JS example making assignment to constant
MDN URL: https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeName
What information was incorrect, unhelpful, or incomplete?
In the example, the first line of the script is something like this:
const node = document.getElementsByTagName("body")[0].firstChild;
But it shouldn't be const, it should be var since later there is an assignment inside the while loop.
Specific section or headline?
Example.
What did you expect to see?
var node = document.getElementsByTagName("body")[0].firstChild;
Did you test this? If so, how?
The Firefox console showed Uncaught TypeError: invalid assignment to const 'node' when visiting the page.
MDN Content page report details
- Folder:
en-us/web/api/node/nodename - MDN URL: https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeName
- GitHub URL: https://github.com/mdn/content/blob/main/files/en-us/web/api/node/nodename/index.md
- Last commit: https://github.com/mdn/content/commit/422c1e46f09bb860015396fbecb6ef4c27cb8004
- Document last modified: 2021-11-08T14:59:08.000Z
Also, please correct the HTML, especially the svg tag which is not closed properly.
Also, please correct the HTML, especially the
svgtag which is not closed properly.
Corrected in https://github.com/mdn/content/pull/11291/commits/6fa2011dbab3f7559fe65d95fbaa79a0406e53e0
Thanks @FongWan for posting, and others for your fixes!