Add a renderer class property.
This allows the checkRenderer function to return the preferred name of
the renderer, rather than the passed alias.
MODIFY
src/canvas/canvasRenderer.js
src/canvas/canvasRenderer.js
@@ -46,7 +46,7 @@ var canvasRenderer = function (arg) {
* @returns {string} 'canvas'.
*/
this.api = function () {
- return 'canvas';
+ return canvasRenderer.apiname;
};
/**
@@ -149,6 +149,7 @@ var canvasRenderer = function (arg) {
return this;
};
+canvasRenderer.apiname = 'canvas';
inherit(canvasRenderer, renderer);

MODIFY
src/registry.js
src/registry.js
@@ -94,7 +94,7 @@ util.checkRenderer = function (name, noFallback) {
if (renderers.hasOwnProperty(name)) {
var ren = renderers[name];
if (!ren.supported || ren.supported()) {
- return name;
+ return ren.apiname || name;
}
if (!ren.fallback || noFallback) {
return false;

MODIFY
src/svg/svgRenderer.js
src/svg/svgRenderer.js
@@ -415,7 +415,7 @@ var svgRenderer = function (arg) {
* @returns {string} 'svg'.
*/
this.api = function () {
- return 'svg';
+ return svgRenderer.apiname;
};
/**
@@ -660,6 +660,7 @@ var svgRenderer = function (arg) {
this._init(arg);
return this;
};
+svgRenderer.apiname = 'svg';
inherit(svgRenderer, renderer);

MODIFY
src/vtkjs/vtkjsRenderer.js
src/vtkjs/vtkjsRenderer.js
@@ -55,7 +55,7 @@ var vtkjsRenderer = function (arg) {
* @returns {string} `vtkjs`.
*/
this.api = function () {
- return 'vtkjs';
+ return vtkjsRenderer.apiname;
};
/**
@@ -163,6 +163,7 @@ var vtkjsRenderer = function (arg) {
return this;
};
+vtkjsRenderer.apiname = 'vtkjs';
inherit(vtkjsRenderer, renderer);

MODIFY
src/webgl/webglRenderer.js
src/webgl/webglRenderer.js
@@ -53,7 +53,7 @@ var webglRenderer = function (arg) {
* @returns {string} `webgl`.
*/
this.api = function () {
- return 'webgl';
+ return webglRenderer.apiname;
};
/**
@@ -296,6 +296,7 @@ var webglRenderer = function (arg) {
return this;
};
+webglRenderer.apiname = 'webgl';
inherit(webglRenderer, renderer);

MODIFY
tests/cases/renderers.js
tests/cases/renderers.js
@@ -64,6 +64,8 @@ describe('renderers', function () {
expect(geo.checkRenderer(null)).toBe(null);
expect(geo.checkRenderer('svg')).toBe('svg');
+ // check that an alias resolves to the preferred name
+ expect(geo.checkRenderer('d3')).toBe('svg');
sinon.stub(geo.svg.renderer, 'supported').returns(false);
expect(geo.checkRenderer('svg')).toBe(null);
@@ -85,6 +87,8 @@ describe('renderers', function () {
mockWebglRenderer();
expect(geo.checkRenderer('webgl')).toBe('webgl');
+ // check that an alias resolves to the preferred name
+ expect(geo.checkRenderer('vgl')).toBe('webgl');
restoreWebglRenderer();
expect(geo.checkRenderer('unknown')).toBe(false);

Add a renderer class property.

This allows the checkRenderer function to return the preferred name of
the renderer, rather than the passed alias.