Skip to content

Commit

Permalink
Fix: catch error when fails to compile vega-lite to vega
Browse files Browse the repository at this point in the history
Reset render when new view is created.
  • Loading branch information
eterna2 committed Nov 6, 2017
1 parent 73a6bf9 commit 80dc43a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions vega-element.html
Original file line number Diff line number Diff line change
Expand Up @@ -701,10 +701,12 @@
resolve(spec);
} catch (error) {
this.dispatchEvent(new CustomEvent('error', {detail: error}));
console.warn(error);
reject(error);
}
});
}).catch(error=>{
this.dispatchEvent(new CustomEvent('error', {detail: error}));
console.warn(error);
});
}

Expand Down Expand Up @@ -850,12 +852,14 @@
*/
_computeView(runtime, headless) {
if (!this._vegaReady || !runtime || !this._connected) return;
if (this.view) this.view.finalize();
var logLevel = vega[logLevel] || vega.None;
var view = new vega.View(runtime, {
logLevel,
renderer: this.renderer
}).initialize(headless ? null : this.$.vegaElement);

// reset render when new view is created
this.rendered = false;
// dispatch ready
this.dispatchEvent(new CustomEvent('view-ready', {detail: view}));

Expand Down

0 comments on commit 80dc43a

Please sign in to comment.