Skip to content

Commit

Permalink
Don't crash the app if the error box is not present
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Duberstein committed Nov 5, 2019
1 parent de04821 commit d9a8fdb
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions modules/jupyter-widget/src/widget.js
Expand Up @@ -70,15 +70,15 @@ export class DeckGLView extends DOMWidgetView {
container.style.height = height;
container.style.position = 'relative';

const mapboxApiKey = this.model.get('mapbox_key');
const jsonInput = JSON.parse(this.model.get('json_input'));
const tooltip = this.model.get('tooltip');

if (this.model.get('js_warning')) {
const errorBox = addErrorBox();
container.append(errorBox);
}

const mapboxApiKey = this.model.get('mapbox_key');
const jsonInput = JSON.parse(this.model.get('json_input'));
const tooltip = this.model.get('tooltip');

loadCss(MAPBOX_CSS_URL);
initDeck({
mapboxApiKey,
Expand All @@ -102,6 +102,7 @@ export class DeckGLView extends DOMWidgetView {

render() {
super.render();

this.model.on('change:json_input', this.valueChanged.bind(this), this);
}

Expand Down Expand Up @@ -135,7 +136,7 @@ export class DeckGLView extends DOMWidgetView {

handleWarning(warningMessage) {
const errorBox = this.el.getElementsByClassName(ERROR_BOX_CLASSNAME)[0];
if (this.model.get('js_warning')) {
if (this.model.get('js_warning') && errorBox) {
errorBox.innerText = warningMessage;
}
}
Expand Down

0 comments on commit d9a8fdb

Please sign in to comment.