content icon indicating copy to clipboard operation
content copied to clipboard

Poor choice of canvas id

Open groda opened this issue 3 weeks ago • 4 comments

MDN URL

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

What specific section or headline is this issue about?

https://developer.mozilla.org/en-US/docs/Web/API/Path2D/Path2D#examples

What information was incorrect, unhelpful, or incomplete?

Using the id "canvas" (as in <canvas id="canvas"></canvas>) might cause some people to create something like <div id="canvas"> and then getting the error getContext is not a function when running

const canvas = document.getElementById("canvas");
const ctx = canvas.getContext("2d");

I guess I was not the only one running into this error since this answer on StackOverflow getContext is not a function also got 103 upvotes

What did you expect to see?

<canvas id="myCanvas">

or

<canvas id="canvasArea"> (so that it's different from w3schools)

Do you have any supporting links, references, or citations?

No response

Do you have anything more you want to share?

No response

groda avatar Nov 27 '25 23:11 groda

Thanks for raising this one. I think that's a good idea, would you like to open a PR to fix it?

bsmth avatar Nov 28 '25 08:11 bsmth

Ok

Benz1993com avatar Dec 06 '25 14:12 Benz1993com

Hi, I’d like to work on this issue. Please assign it to me if it’s still available. Thanks!

FlorinNatha avatar Dec 16 '25 06:12 FlorinNatha

Hi! I’m new to MDN contributions and I’d like to work on this issue. May I take it?

sangaray avatar Dec 16 '25 15:12 sangaray

Hi all, there's already a pull request open to address this:

  • [ ] https://github.com/mdn/content/pull/42159

You can follow along on the progress there, thanks!

bsmth avatar Dec 17 '25 10:12 bsmth

can you assign this issue to me?

hariprabhu571 avatar Dec 19 '25 10:12 hariprabhu571