Skip to content

Commit

Permalink
Node Background Image: Data URI images won't load on Safari cytoscape…
Browse files Browse the repository at this point in the history
…#1582

crossOrigin not set if data uri specified
  • Loading branch information
maxkfranz committed Oct 29, 2016
1 parent 5a3550d commit 55b670e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/extensions/renderer/base/images.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,15 @@ BRp.getCachedImage = function( url, onLoad ){

var image = cache.image = new Image(); // eslint-disable-line no-undef
image.addEventListener('load', onLoad);
image.crossOrigin = 'Anonymous'; // prevent tainted canvas

// #1582 safari doesn't load data uris with crossOrigin properly
// https://bugs.webkit.org/show_bug.cgi?id=123978
var dataUriPrefix = 'data:';
var isDataUri = url.substring( 0, dataUriPrefix.length ).toLowerCase() === dataUriPrefix;
if( !isDataUri ){
image.crossOrigin = 'Anonymous'; // prevent tainted canvas
}

image.src = url;

return image;
Expand Down

0 comments on commit 55b670e

Please sign in to comment.