diff options
author | Aki <please@ignore.pl> | 2021-04-01 23:31:12 +0200 |
---|---|---|
committer | Aki <please@ignore.pl> | 2021-04-01 23:31:12 +0200 |
commit | c240dab85b01399aac2854253b4cf1be0438c0e9 (patch) | |
tree | 0625a4866e9166229108c96611e8534fb91c50a8 | |
parent | d240c455aedcbac2058b5920b4431e4c9529ded9 (diff) | |
download | derelict-prototype-c240dab85b01399aac2854253b4cf1be0438c0e9.zip derelict-prototype-c240dab85b01399aac2854253b4cf1be0438c0e9.tar.gz derelict-prototype-c240dab85b01399aac2854253b4cf1be0438c0e9.tar.bz2 |
Switched to use Fetch API
-rw-r--r-- | derelict.js | 15 |
1 files 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() { |