diff --git a/src/components/colorbar/draw.js b/src/components/colorbar/draw.js index 1cb4a8e68a4..81de94620f3 100644 --- a/src/components/colorbar/draw.js +++ b/src/components/colorbar/draw.js @@ -397,6 +397,7 @@ function drawColorBar(g, opts, gd) { var fills = g.select('.' + cn.cbfills) .selectAll('rect.' + cn.cbfill) + .attr('style', '') .data(fillLevels); fills.enter().append('rect') .classed(cn.cbfill, true) diff --git a/test/jasmine/tests/colorbar_test.js b/test/jasmine/tests/colorbar_test.js index 0405651fad9..fca097ee5fa 100644 --- a/test/jasmine/tests/colorbar_test.js +++ b/test/jasmine/tests/colorbar_test.js @@ -524,5 +524,42 @@ describe('Test colorbar:', function() { .catch(failTest) .then(done); }); + + it('creates the same colorbars attributes in newPlot and react', function(done) { + function getCBFillAttributes() { + var attrs = []; + var colorbars = d3.select(gd).selectAll('.colorbar'); + colorbars.selectAll('.cbfill').each(function() { + var attrsForElem = {}; + for(var i = 0; i < this.attributes.length; i++) { + var attr = this.attributes.item(i); + attrsForElem[attr.name] = attr.value; + } + attrs.push(attrsForElem); + }); + return attrs; + } + + var z = [[1, 10], [100, 1000]]; + + var expectedAttrs; + var actualAttrs; + + Plotly.newPlot(gd, [{type: 'contour', z: z}]) + .then(function() { + expectedAttrs = getCBFillAttributes(); + + return Plotly.newPlot(gd, [{type: 'heatmap', z: z}]) + .then(function() { + return Plotly.react(gd, [{type: 'contour', z: z}]); + }); + }) + .then(function() { + actualAttrs = getCBFillAttributes(); + expect(actualAttrs).toEqual(expectedAttrs); + }) + .catch(failTest) + .then(done); + }); }); });