Skip to content

Commit e3cced2

Browse files
committed
Fix JS error
1 parent 288643a commit e3cced2

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/animationsController.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,9 +265,15 @@ module.exports = class AnimationsController {
265265
*/
266266
updatePegmanAnimation_(options) {
267267
var rect = document.getElementById(utils.getPegmanElementId(`${options.type}ClipRect`, options.pegmanId));
268+
if (!rect) {
269+
return;
270+
}
268271
rect.setAttribute('x', options.col * this.maze.SQUARE_SIZE + 1 + this.maze.PEGMAN_X_OFFSET);
269272
rect.setAttribute('y', getPegmanYForRow(this.maze.skin, options.row, this.maze.SQUARE_SIZE));
270273
var img = document.getElementById(utils.getPegmanElementId(options.type, options.pegmanId));
274+
if (!img) {
275+
return;
276+
}
271277
var x = this.maze.SQUARE_SIZE * options.col -
272278
options.direction * this.maze.PEGMAN_WIDTH + 1 + this.maze.PEGMAN_X_OFFSET;
273279
img.setAttribute('x', x);

0 commit comments

Comments
 (0)