From 804dfc2197e3d1c3c2b4e11d8c0a303a9f2b15bf Mon Sep 17 00:00:00 2001 From: Mark MacKay Date: Tue, 29 Dec 2015 02:17:17 -0600 Subject: [PATCH] filesaver doesn't work for Safari, so better feature detection is needed --- editor/src/browser.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/editor/src/browser.js b/editor/src/browser.js index 4b5330e..888cc04 100644 --- a/editor/src/browser.js +++ b/editor/src/browser.js @@ -127,7 +127,22 @@ var supportsNativeSVGTransformLists_ = (function() { return rxform.getItem(0) == t1; })(); -var supportsBlobs = !!new Blob; +var supportsBlobs_ = (function() { + if (typeof Blob != 'function') return false; + // check if download is supported + var svg = new Blob( + [""], + {type: "image/svg+xml;charset=utf-8"} + ); + var img = new Image(); + var support = false; + img.onload = function() { svgedit.browser.supportsBlobs = function() {return true} }; + img.onerror = function() { svgedit.browser.supportsBlobs = function() {return false} }; + img.src = URL.createObjectURL(svg); + return false; +})(); + + // Public API @@ -150,7 +165,7 @@ svgedit.browser.supportsEditableText = function() { return supportsEditableText_ svgedit.browser.supportsGoodDecimals = function() { return supportsGoodDecimals_; } svgedit.browser.supportsNonScalingStroke = function() { return supportsNonScalingStroke_; } svgedit.browser.supportsNativeTransformLists = function() { return supportsNativeSVGTransformLists_; } -svgedit.browser.supportsBlobs = function() {return supportsBlobs; } +svgedit.browser.supportsBlobs = function() {return supportsBlobs_; } } })();