diff --git a/src/plot_api/plot_schema.js b/src/plot_api/plot_schema.js index 03bc35ad760..ee800947036 100644 --- a/src/plot_api/plot_schema.js +++ b/src/plot_api/plot_schema.js @@ -166,10 +166,13 @@ exports.findArrayAttributes = function(trace) { for(var i = 0; i < transforms.length; i++) { var transform = transforms[i]; + var module = transform._module; - stack = ['transforms[' + i + ']']; + if(module) { + stack = ['transforms[' + i + ']']; - exports.crawl(transform._module.attributes, callback, 1); + exports.crawl(module.attributes, callback, 1); + } } } diff --git a/test/jasmine/tests/transform_multi_test.js b/test/jasmine/tests/transform_multi_test.js index 23e0b40a8b5..f10541b8e80 100644 --- a/test/jasmine/tests/transform_multi_test.js +++ b/test/jasmine/tests/transform_multi_test.js @@ -17,6 +17,17 @@ describe('general transforms:', function() { var traceIn, traceOut; + it('passes through empty transforms', function() { + traceIn = { + y: [2, 1, 2], + transforms: [{}] + }; + + traceOut = Plots.supplyTraceDefaults(traceIn, 0, fullLayout); + + expect(traceOut.transforms).toEqual([{}]); + }); + it('supplyTraceDefaults should supply the transform defaults', function() { traceIn = { y: [2, 1, 2], @@ -436,6 +447,26 @@ describe('multiple transforms:', function() { }); +describe('invalid transforms', function() { + var gd; + + beforeEach(function() { + gd = createGraphDiv(); + }); + + afterEach(destroyGraphDiv); + + it('ignores them', function(done) { + Plotly.plot(gd, [{ + y: [1, 2, 3], + transforms: [{}] + }]).then(function() { + expect(gd._fullData[0].transforms.length).toEqual(1); + done(); + }); + }); +}); + describe('multiple traces with transforms:', function() { 'use strict';