fix sprite loader not working

This commit is contained in:
Chrissi2812
2020-07-08 18:39:42 +02:00
parent cc87197c0a
commit ac6ae019e7

View File

@@ -1,10 +1,9 @@
;(function(window, document) {
'use strict';
'use strict';
var isSvg = document.createElementNS && document.createElementNS( 'http://www.w3.org/2000/svg', 'svg' ).createSVGRect;
var localStorage = 'localStorage' in window && window['localStorage'] !== null ? window.localStorage : false;
var isSvg = document.createElementNS && document.createElementNS( 'http://www.w3.org/2000/svg', 'svg' ).createSVGRect;
var localStorage = 'localStorage' in window && window['localStorage'] !== null ? window.localStorage : false;
function svgSpriteInjector(source, opts) {
function svgSpriteInjector(source, opts) {
var file;
opts = opts || {};
@@ -24,9 +23,9 @@
} else {
console.error('svg-sprite-injector require ie9 or greater!');
}
};
};
function injector(filepath, opts) {
function injector(filepath, opts) {
var name = 'injectedSVGSprite' + filepath,
revision = opts.revision,
request;
@@ -51,9 +50,9 @@
}
};
request.send();
}
}
function injectOnLoad(data) {
function injectOnLoad(data) {
if (data) {
if (document.body) {
injectData(data);
@@ -61,20 +60,14 @@
document.addEventListener('DOMContentLoaded', injectData.bind(null, data));
}
}
}
}
function injectData(data) {
function injectData(data) {
var body = document.body;
body.insertAdjacentHTML('afterbegin', data);
if (body.firstChild.tagName === 'svg') {
body.firstChild.style.display = 'none';
}
}
}
if (typeof exports === 'object') {
module.exports = svgSpriteInjector;
} else {
window.svgSpriteInjector = svgSpriteInjector;
}
} (window, document));
export default svgSpriteInjector;