Only apply Turtle update if canvas is present

Fixes CODEOCEAN-FRONTEND-4T
This commit is contained in:
Sebastian Serth
2023-11-17 14:52:02 +01:00
parent ce6470cd72
commit 3d5f55f8ed

View File

@ -81,6 +81,9 @@ function Turtle(unused_pipe_reference, canvas) {
Turtle.prototype.update = function () {
let k, c;
const canvas = this.canvas[0];
if (canvas === undefined) {
return;
}
canvas.width = this.get_width() * devicePixelRatio;
canvas.height = this.get_height() * devicePixelRatio;
canvas.style.width = `${this.get_width()}px`;