diff --git a/src/loaders/ImageLoader.js b/src/loaders/ImageLoader.js index 0ae1a878c32d5b4fccb149a6ee7267189c9c9aa0..b323dad589742648d5d854734865f4fbba5a955d 100644 --- a/src/loaders/ImageLoader.js +++ b/src/loaders/ImageLoader.js @@ -48,6 +48,13 @@ Object.assign( ImageLoader.prototype, { loader.setPath( this.path ); loader.setResponseType( 'blob' ); loader.setWithCredentials( this.withCredentials ); + + // By default the FileLoader requests files to be loaded with a MIME + // type of `text/plain`. Using `URL.createObjectURL()` with SVGs that + // have a MIME type of `text/plain` results in an error, so explicitly + // set the SVG MIME type. + if ( /\.svg$/.test( url ) ) loader.setMimeType( 'image/svg+xml' ); + loader.load( url, function ( blob ) { image.src = URL.createObjectURL( blob );