summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2021-04-01 23:31:12 +0200
committerAki <please@ignore.pl>2021-04-01 23:31:12 +0200
commitc240dab85b01399aac2854253b4cf1be0438c0e9 (patch)
tree0625a4866e9166229108c96611e8534fb91c50a8
parentd240c455aedcbac2058b5920b4431e4c9529ded9 (diff)
downloadderelict-prototype-c240dab85b01399aac2854253b4cf1be0438c0e9.zip
derelict-prototype-c240dab85b01399aac2854253b4cf1be0438c0e9.tar.gz
derelict-prototype-c240dab85b01399aac2854253b4cf1be0438c0e9.tar.bz2
Switched to use Fetch API
-rw-r--r--derelict.js15
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() {