Skip to content

Commit

Permalink
Merge pull request #611 from finos/view-backport
Browse files Browse the repository at this point in the history
Make "view" attribute of `<perspective-viewer>` backwards compatible
  • Loading branch information
texodus authored Jun 6, 2019
2 parents e7cd48f + d12d7e2 commit c6306eb
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions packages/perspective-viewer/src/js/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,22 @@ class PerspectiveViewer extends ActionElement {
* @fires PerspectiveViewer#perspective-config-update
*/
set view(v) {
this._vis_selector.value = this.getAttribute("view");
this._set_row_styles();
this._set_column_defaults();
this.dispatchEvent(new Event("perspective-config-update"));
const plugin_names = Object.keys(renderers.getInstance());
let plugin = this.getAttribute("view");
if (plugin_names.indexOf(plugin) === -1) {
const guess_plugin = plugin_names.find(x => x.indexOf(plugin) > -1);
if (guess_plugin) {
console.warn(`Unknown plugin "${plugin}", using "${guess_plugin}"`);
this.setAttribute("view", guess_plugin);
} else {
console.error(`Unknown plugin "${plugin}"`);
}
} else {
this._vis_selector.value = plugin;
this._set_row_styles();
this._set_column_defaults();
this.dispatchEvent(new Event("perspective-config-update"));
}
}

/**
Expand Down

0 comments on commit c6306eb

Please sign in to comment.