From 682f7c15702702bfb81850f4dbec3d179e9f7923 Mon Sep 17 00:00:00 2001 From: ryanhamley Date: Wed, 18 Mar 2020 11:26:20 -0700 Subject: [PATCH] Avoid throwing errors when popup container is undefined --- 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() {