Skip to content

Commit 49bb2cf

Browse files
committed
autosize: use Lib.isPlotDiv(gd)
1 parent b286469 commit 49bb2cf

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/plots/plots.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,7 @@ plots.plotAutoSize = function plotAutoSize(gd, layout, fullLayout) {
788788
newWidth,
789789
newHeight;
790790

791-
if(typeof gd.emit === 'function') gd.emit('plotly_autosize');
791+
if(Lib.isPlotDiv(gd)) gd.emit('plotly_autosize');
792792

793793
// embedded in an iframe - just take the full iframe size
794794
// if we get to this point, with no aspect ratio restrictions
@@ -806,15 +806,11 @@ plots.plotAutoSize = function plotAutoSize(gd, layout, fullLayout) {
806806
reservedHeight = reservedMargins.bottom + reservedMargins.top,
807807
factor = 1 - 2 * frameMargins;
808808

809-
var gdBB;
810-
try {
811-
gdBB = fullLayout._container.node().getBoundingClientRect();
812-
} catch(err) {
813-
gdBB = {
809+
var gdBB = fullLayout._container && fullLayout._container.node ?
810+
fullLayout._container.node().getBoundingClientRect() : {
814811
width: fullLayout.width,
815812
height: fullLayout.height
816813
};
817-
}
818814

819815
newWidth = Math.round(factor * (gdBB.width - reservedWidth));
820816
newHeight = Math.round(factor * (gdBB.height - reservedHeight));

0 commit comments

Comments
 (0)