Skip to content

Commit 5aee123

Browse files
authored
Assume that browser has working URL object (#19283)
Perhaps 10 years ago there was possibility that the URL object didn't exist, but today we don't support such browsers See https://caniuse.com/url. This is a followup to #19277 which did the same for the Blob constructor.
1 parent b72453c commit 5aee123

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

src/library_browser.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,6 @@ var LibraryBrowser = {
105105

106106
if (Browser.initted) return;
107107
Browser.initted = true;
108-
Browser.URLObject = typeof window != "undefined" ? (window.URL ? window.URL : window.webkitURL) : undefined;
109-
if (!Module.noImageDecoding && typeof Browser.URLObject == 'undefined') {
110-
err("warning: Browser does not support creating object URLs. Built-in browser image decoding will not be available.");
111-
Module.noImageDecoding = true;
112-
}
113108

114109
// Support for plugins that can process preloaded files. You can add more of these to
115110
// your app by creating and appending to Module.preloadPlugins.
@@ -129,7 +124,7 @@ var LibraryBrowser = {
129124
// Safari's Blob can only take an ArrayBuffer
130125
b = new Blob([(new Uint8Array(byteArray)).buffer], { type: Browser.getMimetype(name) });
131126
}
132-
var url = Browser.URLObject.createObjectURL(b);
127+
var url = URL.createObjectURL(b);
133128
#if ASSERTIONS
134129
assert(typeof url == 'string', 'createObjectURL must return a url as a string');
135130
#endif
@@ -142,7 +137,7 @@ var LibraryBrowser = {
142137
var ctx = canvas.getContext('2d');
143138
ctx.drawImage(img, 0, 0);
144139
preloadedImages[name] = canvas;
145-
Browser.URLObject.revokeObjectURL(url);
140+
URL.revokeObjectURL(url);
146141
if (onload) onload(byteArray);
147142
};
148143
img.onerror = (event) => {
@@ -172,7 +167,7 @@ var LibraryBrowser = {
172167
if (onerror) onerror();
173168
}
174169
var b = new Blob([byteArray], { type: Browser.getMimetype(name) });
175-
var url = Browser.URLObject.createObjectURL(b); // XXX we never revoke this!
170+
var url = URL.createObjectURL(b); // XXX we never revoke this!
176171
#if ASSERTIONS
177172
assert(typeof url == 'string', 'createObjectURL must return a url as a string');
178173
#endif

0 commit comments

Comments
 (0)