Skip to content

Commit 9555c0c

Browse files
author
Michael Potter
committed
catch exceptions when trying to read access-restricted css files, and update test case to look for css styling
1 parent 635e5ee commit 9555c0c

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

src/traces/sankey/plot.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,18 @@ function linkHoveredStyle(d, sankey, visitNodes, sankeyLink) {
6868
// Figure out whether the user has provided their own sankey-link-hover style.
6969
var styleExists = false;
7070
for(var i = 0; i < document.styleSheets.length; i++) {
71-
var rules = document.styleSheets[i].cssRules;
72-
for(var j = 0; j < rules.length; j++) {
73-
if(rules[j].selectorText === '.sankey-link-hover') {
74-
styleExists = true;
75-
break;
71+
try {
72+
var rules = document.styleSheets[i].cssRules;
73+
for(var j = 0; j < rules.length; j++) {
74+
if(rules[j].selectorText === '.sankey-link-hover') {
75+
styleExists = true;
76+
break;
77+
}
7678
}
79+
if(styleExists) break;
80+
} catch(e) {
81+
// This particular style sheet cannot be accessed (due to CORS policy)
7782
}
78-
if(styleExists) break;
7983
}
8084

8185
// If not, insert a default one

test/jasmine/tests/sankey_test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,7 +1087,7 @@ describe('sankey tests', function() {
10871087
.filter(function(obj) {
10881088
return obj.link.label === 'stream 1';
10891089
})[0].forEach(function(l) {
1090-
expect(l.style.fillOpacity).toEqual('0.4');
1090+
expect(l.classList.contains('sankey-link-hover')).toBe(true);
10911091
});
10921092
}).then(function() {
10931093
mouseEvent('mouseout', 200, 250);
@@ -1096,7 +1096,7 @@ describe('sankey tests', function() {
10961096
.filter(function(obj) {
10971097
return obj.link.label === 'stream 1';
10981098
})[0].forEach(function(l) {
1099-
expect(l.style.fillOpacity).toEqual('0.2');
1099+
expect(l.classList.contains('sankey-link-hover')).toBe(false);
11001100
});
11011101
})
11021102
.then(done, done.fail);

0 commit comments

Comments
 (0)