react-inlinesvg
Advanced tools
Comparing version 0.1.2 to 0.1.3
@@ -1,2 +0,2 @@ | ||
var InlineSVGError, PropTypes, React, Status, XHR, configurationError, createError, delay, httpError, isSupportedEnvironment, me, once, span, supportsInlineSVG, unsupportedBrowserError, | ||
var InlineSVGError, PropTypes, React, Status, configurationError, createError, createXHR, delay, httpError, isSupportedEnvironment, me, once, span, supportsInlineSVG, unsupportedBrowserError, urllite, | ||
__slice = [].slice, | ||
@@ -10,2 +10,4 @@ __hasProp = {}.hasOwnProperty, | ||
urllite = require('urllite/lib/core'); | ||
PropTypes = React.PropTypes; | ||
@@ -100,6 +102,6 @@ | ||
var done, xhr; | ||
xhr = new XHR(); | ||
xhr = createXHR(this.props.src); | ||
done = once(delay((function(_this) { | ||
return function(err) { | ||
xhr.onload = xhr.onerror = xhr.onreadystatechange = null; | ||
xhr.onload = xhr.onerror = xhr.onreadystatechange = xhr.ontimeout = xhr.onprogress = null; | ||
if (err) { | ||
@@ -134,3 +136,7 @@ return _this.fail(err); | ||
}; | ||
xhr.open('GET', this.props.src); | ||
xhr.ontimeout = function() {}; | ||
xhr.onprogress = function() {}; | ||
xhr.open('GET', this.props.src.replace(/[^%]+/g, function(s) { | ||
return encodeURI(s); | ||
})); | ||
return xhr.send(); | ||
@@ -177,11 +183,26 @@ }, | ||
XHR = (function() { | ||
createXHR = function(src) { | ||
var XDR, XHR, a, b, xhr; | ||
if (typeof window === "undefined" || window === null) { | ||
return null; | ||
} | ||
if ((XHR = window.XMLHttpRequest) && 'withCredentials' in new XHR) { | ||
return XHR; | ||
if (XHR = window.XMLHttpRequest) { | ||
xhr = new XHR; | ||
if ('withCredentials' in xhr) { | ||
return xhr; | ||
} | ||
} | ||
return window.XDomainRequest; | ||
})(); | ||
if (XDR = window.XDomainRequest) { | ||
a = urllite(src); | ||
b = urllite(window.location.href); | ||
if (!a.host) { | ||
return xhr; | ||
} | ||
if (a.protocol === b.protocol && a.host === b.host && a.port === b.port) { | ||
return xhr; | ||
} | ||
return new XDR; | ||
} | ||
return xhr; | ||
}; | ||
@@ -200,3 +221,3 @@ delay = function(fn) { | ||
isSupportedEnvironment = once(function() { | ||
return XHR && supportsInlineSVG(); | ||
return ((typeof window !== "undefined" && window !== null ? window.XMLHttpRequest : void 0) || (typeof window !== "undefined" && window !== null ? window.XDomainRequest : void 0)) && supportsInlineSVG(); | ||
}); | ||
@@ -203,0 +224,0 @@ |
{ | ||
"name": "react-inlinesvg", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "An SVG loader for React", | ||
@@ -10,3 +10,4 @@ "main": "./lib/index.js", | ||
"dependencies": { | ||
"once": "~1.3.0" | ||
"once": "~1.3.0", | ||
"urllite": "~0.4.1" | ||
}, | ||
@@ -13,0 +14,0 @@ "devDependencies": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13981
250
3
+ Addedurllite@~0.4.1
+ Addedurllite@0.4.4(transitive)