Skip to content

Commit f218e09

Browse files
committed
Handle case where cssRules are undefined.
It's possible for a stylesheet's cssRules property to be undefined. In that case, break out of the rule aggregating loop. Don't explicitly refer to module.exports.
1 parent d5a8834 commit f218e09

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/lib/plotcss_utils.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ exports.injectStyles = function injectStyles(gd) {
1717
// If the graph div has already been styled, bail
1818
if(gd._plotCSSLoaded) return;
1919

20-
var targetSelectors = module.exports.getAllRuleSelectors(gd._document);
20+
var targetSelectors = exports.getAllRuleSelectors(gd._document);
2121
var targetStyleSheet = null;
2222

2323
if(gd._document.getElementsByTagName('style').length === 0) {
@@ -33,7 +33,7 @@ exports.injectStyles = function injectStyles(gd) {
3333
}
3434

3535
for(var selector in plotcss) {
36-
var fullSelector = module.exports.buildFullSelector(selector);
36+
var fullSelector = exports.buildFullSelector(selector);
3737

3838
// Don't duplicate selectors
3939
if(targetSelectors.indexOf(fullSelector) === -1) {
@@ -68,6 +68,8 @@ exports.getAllRuleSelectors = function getAllRuleSelectors(sourceDocument) {
6868
for(var i = 0; i < sourceDocument.styleSheets.length; i++) {
6969
var styleSheet = sourceDocument.styleSheets[i];
7070

71+
if(!styleSheet.cssRules) continue; // It's possible for rules to be undefined
72+
7173
for(var j = 0; j < styleSheet.cssRules.length; j++) {
7274
var cssRule = styleSheet.cssRules[j];
7375

0 commit comments

Comments
 (0)