summaryrefslogtreecommitdiffstats
path: root/platform/web/js
diff options
context:
space:
mode:
authorYuri Sizov <yuris@humnom.net>2023-07-12 15:09:14 +0200
committerYuri Sizov <yuris@humnom.net>2023-07-12 15:09:14 +0200
commit2b47f6715e7df588a30ac665aac60e22c67e62ca (patch)
tree37b650734b0c4810b30108761222befdc93b0c10 /platform/web/js
parentb54d6cf46657dccd5b66cc1661a2ce0a6d99e1d7 (diff)
parent9c5a0c6c102556c229825e053153d02fb7141668 (diff)
downloadredot-engine-2b47f6715e7df588a30ac665aac60e22c67e62ca.tar.gz
Merge pull request #78437 from bruvzg/set_icon
Add error checks and harmonize behavior of the `set_icon` method.
Diffstat (limited to 'platform/web/js')
-rw-r--r--platform/web/js/libs/library_godot_display.js25
1 files changed, 16 insertions, 9 deletions
diff --git a/platform/web/js/libs/library_godot_display.js b/platform/web/js/libs/library_godot_display.js
index ea2a846f90..746f858923 100644
--- a/platform/web/js/libs/library_godot_display.js
+++ b/platform/web/js/libs/library_godot_display.js
@@ -568,16 +568,23 @@ const GodotDisplay = {
godot_js_display_window_icon_set__sig: 'vii',
godot_js_display_window_icon_set: function (p_ptr, p_len) {
let link = document.getElementById('-gd-engine-icon');
- if (link === null) {
- link = document.createElement('link');
- link.rel = 'icon';
- link.id = '-gd-engine-icon';
- document.head.appendChild(link);
- }
const old_icon = GodotDisplay.window_icon;
- const png = new Blob([GodotRuntime.heapSlice(HEAPU8, p_ptr, p_len)], { type: 'image/png' });
- GodotDisplay.window_icon = URL.createObjectURL(png);
- link.href = GodotDisplay.window_icon;
+ if (p_ptr) {
+ if (link === null) {
+ link = document.createElement('link');
+ link.rel = 'icon';
+ link.id = '-gd-engine-icon';
+ document.head.appendChild(link);
+ }
+ const png = new Blob([GodotRuntime.heapSlice(HEAPU8, p_ptr, p_len)], { type: 'image/png' });
+ GodotDisplay.window_icon = URL.createObjectURL(png);
+ link.href = GodotDisplay.window_icon;
+ } else {
+ if (link) {
+ link.remove();
+ }
+ GodotDisplay.window_icon = null;
+ }
if (old_icon) {
URL.revokeObjectURL(old_icon);
}