Skip to content

Commit

Permalink
catch exceptions when trying to read access-restricted css files, and…
Browse files Browse the repository at this point in the history
… update test case to look for css styling
  • Loading branch information
Michael Potter committed Jan 12, 2024
1 parent 635e5ee commit 9555c0c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
16 changes: 10 additions & 6 deletions src/traces/sankey/plot.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,18 @@ function linkHoveredStyle(d, sankey, visitNodes, sankeyLink) {
// Figure out whether the user has provided their own sankey-link-hover style.
var styleExists = false;
for(var i = 0; i < document.styleSheets.length; i++) {
var rules = document.styleSheets[i].cssRules;
for(var j = 0; j < rules.length; j++) {
if(rules[j].selectorText === '.sankey-link-hover') {
styleExists = true;
break;
try {
var rules = document.styleSheets[i].cssRules;
for(var j = 0; j < rules.length; j++) {
if(rules[j].selectorText === '.sankey-link-hover') {
styleExists = true;
break;
}
}
if(styleExists) break;
} catch(e) {
// This particular style sheet cannot be accessed (due to CORS policy)
}
if(styleExists) break;
}

// If not, insert a default one
Expand Down
4 changes: 2 additions & 2 deletions test/jasmine/tests/sankey_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1087,7 +1087,7 @@ describe('sankey tests', function() {
.filter(function(obj) {
return obj.link.label === 'stream 1';
})[0].forEach(function(l) {
expect(l.style.fillOpacity).toEqual('0.4');
expect(l.classList.contains('sankey-link-hover')).toBe(true);
});
}).then(function() {
mouseEvent('mouseout', 200, 250);
Expand All @@ -1096,7 +1096,7 @@ describe('sankey tests', function() {
.filter(function(obj) {
return obj.link.label === 'stream 1';
})[0].forEach(function(l) {
expect(l.style.fillOpacity).toEqual('0.2');
expect(l.classList.contains('sankey-link-hover')).toBe(false);
});
})
.then(done, done.fail);
Expand Down

0 comments on commit 9555c0c

Please sign in to comment.