From 6e75b0a3d9e02573a12f75ca630a907c473b5454 Mon Sep 17 00:00:00 2001 From: Ryan Hamley Date: Wed, 18 Mar 2020 11:40:36 -0700 Subject: [PATCH] Avoid throwing errors when popup container is undefined (#9433) --- src/ui/popup.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/ui/popup.js b/src/ui/popup.js index ac48b592fab..a18f6b36405 100644 --- a/src/ui/popup.js +++ b/src/ui/popup.js @@ -309,7 +309,7 @@ export default class Popup extends Evented { * @returns {string} The maximum width of the popup. */ getMaxWidth() { - return this._container.style.maxWidth; + return this._container && this._container.style.maxWidth; } /** @@ -356,7 +356,9 @@ export default class Popup extends Evented { * popup.addClassName('some-class') */ addClassName(className: string) { - this._container.classList.add(className); + if (this._container) { + this._container.classList.add(className); + } } /** @@ -369,7 +371,9 @@ export default class Popup extends Evented { * popup.removeClassName('some-class') */ removeClassName(className: string) { - this._container.classList.remove(className); + if (this._container) { + this._container.classList.remove(className); + } } /** @@ -384,7 +388,9 @@ export default class Popup extends Evented { * popup.toggleClassName('toggleClass') */ toggleClassName(className: string) { - return this._container.classList.toggle(className); + if (this._container) { + return this._container.classList.toggle(className); + } } _createContent() {