Skip to content

Commit

Permalink
Avoid throwing errors when popup container is undefined (#9433) (#9434)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Hamley authored Mar 18, 2020
1 parent 68c6102 commit 251afac
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/ui/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down Expand Up @@ -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);
}
}

/**
Expand All @@ -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);
}
}

/**
Expand All @@ -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() {
Expand Down

0 comments on commit 251afac

Please sign in to comment.