From 484d696df30c38a018023c84c241a506dde5b52e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Mon, 14 Mar 2016 19:40:46 +0100 Subject: [PATCH] Fix #1008: Remove use of ActiveXObject in Http.request() --- src/core/PaperScript.js | 4 +++- src/net/Http.js | 7 +++---- src/svg/SvgImport.js | 3 ++- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/core/PaperScript.js b/src/core/PaperScript.js index f1f90f3c..0d0b569b 100644 --- a/src/core/PaperScript.js +++ b/src/core/PaperScript.js @@ -527,7 +527,9 @@ Base.exports.PaperScript = (function() { // request the source asynchronously and execute as soon as // it is retrieved. Http.request({ - url: src, async: async, + url: src, + async: async, + mimeType: 'text/plain', onLoad: function(code) { execute(code, scope, src); } diff --git a/src/net/Http.js b/src/net/Http.js index eca54360..e5a304af 100644 --- a/src/net/Http.js +++ b/src/net/Http.js @@ -13,12 +13,11 @@ var Http = { request: function(options) { // Code borrowed from Coffee Script and extended: - var ctor = window.ActiveXObject || window.XMLHttpRequest, - xhr = new ctor('Microsoft.XMLHTTP'); + var xhr = new window.XMLHttpRequest(); xhr.open((options.method || 'get').toUpperCase(), options.url, Base.pick(options.async, true)); - if ('overrideMimeType' in xhr) - xhr.overrideMimeType('text/plain'); + if (options.mimeType) + xhr.overrideMimeType(options.mimeType); xhr.onload = function() { var status = xhr.status; if (status === 0 || status === 200) { diff --git a/src/svg/SvgImport.js b/src/svg/SvgImport.js index 09837242..a79df8a2 100644 --- a/src/svg/SvgImport.js +++ b/src/svg/SvgImport.js @@ -684,7 +684,8 @@ new function() { onLoad(node); } else { Http.request({ - url: source, async: true, + url: source, + async: true, onLoad: onLoad, onError: onError });