Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid throwing errors when popup container is undefined #9433

Merged
merged 1 commit into from
Mar 18, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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