Only return height and width for Turtle if canvas is present

Fixes CODEOCEAN-FRONTEND-4P
This commit is contained in:
Sebastian Serth
2023-11-17 14:58:24 +01:00
parent 3d5f55f8ed
commit e03e67a1a5

View File

@ -142,6 +142,9 @@ Turtle.prototype.update = function () {
Turtle.prototype.get_width = function () { Turtle.prototype.get_width = function () {
if (width === undefined) { if (width === undefined) {
if (this.canvas === undefined || this.canvas[0] === undefined) {
return;
}
width = this.canvas[0].width; width = this.canvas[0].width;
} }
return width; return width;
@ -149,6 +152,9 @@ Turtle.prototype.get_width = function () {
Turtle.prototype.get_height = function () { Turtle.prototype.get_height = function () {
if (height === undefined) { if (height === undefined) {
if (this.canvas === undefined || this.canvas[0] === undefined) {
return;
}
height = this.canvas[0].height; height = this.canvas[0].height;
} }
return height; return height;