Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6021c43

Browse files
committed
autosize: use Lib.isPlotDiv
1 parent bc1a970 commit 6021c43

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/plots/plots.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -794,7 +794,9 @@ plots.plotAutoSize = function plotAutoSize(gd, layout, fullLayout) {
794794
newWidth,
795795
newHeight;
796796

797-
if(Lib.isPlotDiv(gd)) gd.emit('plotly_autosize');
797+
var isPlotDiv = Lib.isPlotDiv(gd);
798+
799+
if(isPlotDiv) gd.emit('plotly_autosize');
798800

799801
// embedded in an iframe - just take the full iframe size
800802
// if we get to this point, with no aspect ratio restrictions
@@ -826,12 +828,8 @@ plots.plotAutoSize = function plotAutoSize(gd, layout, fullLayout) {
826828
// provide height and width for the container div,
827829
// specify size in layout, or take the defaults,
828830
// but don't enforce any ratio restrictions
829-
var computedStyle;
830-
try {
831-
computedStyle = window.getComputedStyle(gd);
832-
} catch(err) {
833-
computedStyle = {};
834-
}
831+
var computedStyle = isPlotDiv ? window.getComputedStyle(gd) : {};
832+
835833
newWidth = parseFloat(computedStyle.width) || fullLayout.width;
836834
newHeight = parseFloat(computedStyle.height) || fullLayout.height;
837835
}

0 commit comments

Comments
 (0)