From c240dab85b01399aac2854253b4cf1be0438c0e9 Mon Sep 17 00:00:00 2001 From: Aki Date: Thu, 1 Apr 2021 23:31:12 +0200 Subject: Switched to use Fetch API --- derelict.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/derelict.js b/derelict.js index 0745ccb..515d81a 100644 --- a/derelict.js +++ b/derelict.js @@ -24,13 +24,14 @@ function Wreck(x, y, z) { } function load(callback) { - const xhr = new XMLHttpRequest() - xhr.open("GET", "wreck.svg", true) - xhr.onload = function (e) { - wreck = xhr.responseXML.documentElement - callback() - } - xhr.send(null) + fetch("wreck.svg") + .then(response => response.text()) + .then(text => { + const parser = new window.DOMParser() + const svg = parser.parseFromString(text, "image/svg+xml") + wreck = svg.documentElement + }) + .then(() => callback()) } function init() { -- cgit v1.1