summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-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() {