content icon indicating copy to clipboard operation
content copied to clipboard

Issue with "Node.nodeName": JS example making assignment to constant

Open FongWan opened this issue 4 years ago • 3 comments

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

FongWan avatar Dec 18 '21 02:12 FongWan

Also, please correct the HTML, especially the svg tag which is not closed properly.

jackdeguest avatar Dec 19 '21 13:12 jackdeguest

Also, please correct the HTML, especially the svg tag which is not closed properly.

Corrected in https://github.com/mdn/content/pull/11291/commits/6fa2011dbab3f7559fe65d95fbaa79a0406e53e0

AnilSeervi avatar Dec 20 '21 03:12 AnilSeervi

Thanks @FongWan for posting, and others for your fixes!

hamishwillee avatar Dec 20 '21 04:12 hamishwillee