Fix #1008: Remove use of ActiveXObject in Http.request()

This commit is contained in:
Jürg Lehni 2016-03-14 19:40:46 +01:00
parent da7d0d8f75
commit 484d696df3
3 changed files with 8 additions and 6 deletions

View file

@ -527,7 +527,9 @@ Base.exports.PaperScript = (function() {
// request the source asynchronously and execute as soon as // request the source asynchronously and execute as soon as
// it is retrieved. // it is retrieved.
Http.request({ Http.request({
url: src, async: async, url: src,
async: async,
mimeType: 'text/plain',
onLoad: function(code) { onLoad: function(code) {
execute(code, scope, src); execute(code, scope, src);
} }

View file

@ -13,12 +13,11 @@
var Http = { var Http = {
request: function(options) { request: function(options) {
// Code borrowed from Coffee Script and extended: // Code borrowed from Coffee Script and extended:
var ctor = window.ActiveXObject || window.XMLHttpRequest, var xhr = new window.XMLHttpRequest();
xhr = new ctor('Microsoft.XMLHTTP');
xhr.open((options.method || 'get').toUpperCase(), options.url, xhr.open((options.method || 'get').toUpperCase(), options.url,
Base.pick(options.async, true)); Base.pick(options.async, true));
if ('overrideMimeType' in xhr) if (options.mimeType)
xhr.overrideMimeType('text/plain'); xhr.overrideMimeType(options.mimeType);
xhr.onload = function() { xhr.onload = function() {
var status = xhr.status; var status = xhr.status;
if (status === 0 || status === 200) { if (status === 0 || status === 200) {

View file

@ -684,7 +684,8 @@ new function() {
onLoad(node); onLoad(node);
} else { } else {
Http.request({ Http.request({
url: source, async: true, url: source,
async: true,
onLoad: onLoad, onLoad: onLoad,
onError: onError onError: onError
}); });