rustwasm / book

The Rust and WebAssembly Book
https://rustwasm.github.io/docs/book/
MIT License
1.75k stars 211 forks source link

Canvas example needs HTML Canvas element #285

Open misaim opened 1 year ago

misaim commented 1 year ago

Where in the docs did you come across this? https://rustwasm.github.io/docs/wasm-bindgen/examples/2d-canvas.html

Describe what about it does not make sense Currently this documentation doesn't include a custom html file. This raises a confusing Uncaught (in promise) RuntimeError: unreachable executed error message on loading of the compiled .wasm file.

Note that I'm using --target web (although no-modules has the same problem) - I am unsure if using all the fancy bundle tools generates html with a canvas element by default.

How could we improve it? Include a html file. Can be as basic as possible, with a dedicated canvas element (id of "canvas") e.g: <canvas id="canvas" width="150" height="150"></canvas> ...Taken from the hosted example.