You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Unless I'm missing something, the callback is called only if the image is successfully loaded. If an error occurs, it is logged to the console, but there is no explicit error either thrown or returned.
I think it should call the callback with a null object.
I believe this is also happening on the API Image.fromURL.
The text was updated successfully, but these errors were encountered:
/**
* Takes url corresponding to an SVG document, and parses it into a set of fabric objects. Note that SVG is fetched via XMLHttpRequest, so it needs to conform to SOP (Same Origin Policy)
* @memberOf fabric
* @param {String} url
* @param {Function} callback
* @param {Function} [reviver] Method for further parsing of SVG elements, called after each fabric object created.
*/
loadSVGFromURL: function(url, callback, reviver) {
url = url.replace(/^\n\s*/, '').trim();
svgCache.has(url, function (hasUrl) {
if (hasUrl) {
svgCache.get(url, function (value) {
var enlivedRecord = _enlivenCachedObject(value);
callback(enlivedRecord.objects, enlivedRecord.options);
});
}
else {
new fabric.util.request(url, {
method: 'get',
onComplete: onComplete
});
}
});
function onComplete(r) {
var xml = r.responseXML;
if (xml && !xml.documentElement && fabric.window.ActiveXObject && r.responseText) {
xml = new ActiveXObject('Microsoft.XMLDOM');
xml.async = 'false';
//IE chokes on DOCTYPE
xml.loadXML(r.responseText.replace(/<!DOCTYPE[\s\S]*?(\[[\s\S]*\])*?>/i, ''));
}
if (!xml || !xml.documentElement) {
- return;+ callback && callback(null);
}
fabric.parseSVGDocument(xml.documentElement, function (results, options) {
svgCache.set(url, {
objects: fabric.util.array.invoke(results, 'toObject'),
options: options
});
+ callback && callback(results, options);- callback(results, options);
}, reviver);
}
},
If you mean something like this i can make a pr.
The callback is called with null on failure like on the image.fromURL api.
Just think if we should check r.status != 200 and redirects....?
Unless I'm missing something, the callback is called only if the image is successfully loaded. If an error occurs, it is logged to the console, but there is no explicit error either thrown or returned.
I think it should call the callback with a null object.
I believe this is also happening on the API Image.fromURL.
The text was updated successfully, but these errors were encountered: