Only return height and width for Turtle if canvas is present
Fixes CODEOCEAN-FRONTEND-4P
This commit is contained in:
@ -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;
|
||||||
|
Reference in New Issue
Block a user