-
Notifications
You must be signed in to change notification settings - Fork 0
/
load-svg-file.umd.min.js
2 lines (2 loc) · 1.07 KB
/
load-svg-file.umd.min.js
1
2
/*! load-svg-file v1.0.1 | (c) MIT @ Richard Szakacs, richardszkcs@gmail.com, www.richardszkcs.com */
"use strict";!function(e,n){"function"==typeof define&&define.amd?define([],n):"object"==typeof module&&module.exports?module.exports=n():e.loadSvgFile=n()}("undefined"!=typeof self?self:void 0,function(){return function(t,e,r){var n=typeof t;if(!t||"string"!==n)throw n="string"!==n?n:"empty "+n,new Error('The url must be a non-empty string, got: "'+n+'".');t.lastIndexOf(".svg")!==t.length-4&&(t+=".svg");var i=e||{};n=typeof e,e&&"object"===n?i=e:"function"===n&&(i={},r=e);var s=void 0,d=void 0,l=void 0;Promise&&(s=new Promise(function(e,n){d=e,l=n}));var f=new XMLHttpRequest;return f.onloadend=f.onerror=function(){if(200===f.status){var e=document.createElement("div");e.innerHTML=f.response;var n="string"==typeof i.class?i.class:"";0<n.length&&(e.className=n),("boolean"!=typeof i.hide||i.hide)&&(e.style.display="none"),document.body.appendChild(e),r?r():s&&d()}else{var o=new Error('Cannot load SVG file: "'+t+'".');r?r(o):s&&l(o)}},f.open("get",t,!0),f.send(null),s||null}});