Skip to content

Assume that browser has working URL object #19283

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions src/library_browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,6 @@ var LibraryBrowser = {

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

// Support for plugins that can process preloaded files. You can add more of these to
// your app by creating and appending to Module.preloadPlugins.
Expand All @@ -129,7 +124,7 @@ var LibraryBrowser = {
// Safari's Blob can only take an ArrayBuffer
b = new Blob([(new Uint8Array(byteArray)).buffer], { type: Browser.getMimetype(name) });
}
var url = Browser.URLObject.createObjectURL(b);
var url = URL.createObjectURL(b);
#if ASSERTIONS
assert(typeof url == 'string', 'createObjectURL must return a url as a string');
#endif
Expand All @@ -142,7 +137,7 @@ var LibraryBrowser = {
var ctx = canvas.getContext('2d');
ctx.drawImage(img, 0, 0);
preloadedImages[name] = canvas;
Browser.URLObject.revokeObjectURL(url);
URL.revokeObjectURL(url);
if (onload) onload(byteArray);
};
img.onerror = (event) => {
Expand Down Expand Up @@ -172,7 +167,7 @@ var LibraryBrowser = {
if (onerror) onerror();
}
var b = new Blob([byteArray], { type: Browser.getMimetype(name) });
var url = Browser.URLObject.createObjectURL(b); // XXX we never revoke this!
var url = URL.createObjectURL(b); // XXX we never revoke this!
#if ASSERTIONS
assert(typeof url == 'string', 'createObjectURL must return a url as a string');
#endif
Expand Down