diff --git a/svgxuse.js b/svgxuse.js index fae014b..cd0ae58 100644 --- a/svgxuse.js +++ b/svgxuse.js @@ -2,7 +2,7 @@ * @copyright Copyright (c) 2016 IcoMoon.io * @license Licensed under MIT license * See https://github.com/Keyamoon/svgxuse - * @version 1.1.22 + * @version 1.1.23 */ /*jslint browser: true */ /*global XDomainRequest, MutationObserver, window */ @@ -50,16 +50,22 @@ // In IE 9, cross origin requests can only be sent using XDomainRequest. // XDomainRequest would fail if CORS headers are not set. // Therefore, XDomainRequest should only be used with cross origin requests. - function getOrigin(href) { - var a = document.createElement('a'); - a.href = href; - return a.protocol + a.hostname; + function getOrigin(loc) { + var a; + if (loc.protocol !== undefined) { + a = loc; + } else { + a = document.createElement('a'); + a.href = loc; + } + return a.protocol.replace(/:/g, '') + a.host; } var Request; - var origin = location.protocol + location.hostname; + var origin; var origin2; if (window.XMLHttpRequest) { Request = new XMLHttpRequest(); + origin = getOrigin(location); origin2 = getOrigin(url); if (Request.withCredentials === undefined && origin2 !== '' && origin2 !== origin) { Request = XDomainRequest || undefined; diff --git a/svgxuse.min.js b/svgxuse.min.js index a5485f1..4ad1877 100644 --- a/svgxuse.min.js +++ b/svgxuse.min.js @@ -2,10 +2,10 @@ * @copyright Copyright (c) 2016 IcoMoon.io * @license Licensed under MIT license * See https://github.com/Keyamoon/svgxuse - * @version 1.1.22 + * @version 1.1.23 */ -(function(){if(window&&window.addEventListener){var c=Object.create(null),m,q,d=function(){clearTimeout(q);q=setTimeout(m,100)},n=function(){},t=function(){var e;window.addEventListener("resize",d,!1);window.addEventListener("orientationchange",d,!1);window.MutationObserver?(e=new MutationObserver(d),e.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!0}),n=function(){try{e.disconnect(),window.removeEventListener("resize",d,!1),window.removeEventListener("orientationchange",d, -!1)}catch(c){}}):(document.documentElement.addEventListener("DOMSubtreeModified",d,!1),n=function(){document.documentElement.removeEventListener("DOMSubtreeModified",d,!1);window.removeEventListener("resize",d,!1);window.removeEventListener("orientationchange",d,!1)})},u=function(e){var c,d=location.protocol+location.hostname;if(window.XMLHttpRequest){c=new XMLHttpRequest;var l=document.createElement("a");l.href=e;e=l.protocol+l.hostname;c=void 0===c.withCredentials&&""!==e&&e!==d?XDomainRequest|| -void 0:XMLHttpRequest}return c};m=function(){function e(){--p;0===p&&(n(),t())}function d(a){return function(){!0!==c[a.base]&&a.useEl.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href","#"+a.hash)}}function m(a){return function(){var c=document.body,b=document.createElement("x");a.onload=null;b.innerHTML=a.responseText;if(b=b.getElementsByTagName("svg")[0])b.setAttribute("aria-hidden","true"),b.style.position="absolute",b.style.width=0,b.style.height=0,b.style.overflow="hidden",c.insertBefore(b, -c.firstChild);e()}}function l(a){return function(){a.onerror=null;a.ontimeout=null;e()}}var a,f,g,h,p=0,b,k;n();k=document.getElementsByTagName("use");for(h=0;h