Skip to content

Commit e3cb3fe

Browse files
committed
deal gracefully with elements that have no computed style available
1 parent 3db47c0 commit e3cb3fe

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

inst/www/shared/shiny.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,13 @@
3434
var x;
3535
if (el.currentStyle)
3636
x = el.currentStyle[styleProp];
37-
else if (window.getComputedStyle)
38-
x = document.defaultView.getComputedStyle(el, null)
39-
.getPropertyValue(styleProp);
37+
else if (window.getComputedStyle) {
38+
// On some browsers, getComputedStyle can return null for elements that
39+
// aren't visible; don't attempt to retrieve style props in this case.
40+
var style = document.defaultView.getComputedStyle(el, null);
41+
if (style)
42+
x = style.getPropertyValue(styleProp);
43+
}
4044
return x;
4145
}
4246

0 commit comments

Comments
 (0)