Bug 1642522 - Fix "this._attachmentIds.get(...) is undefined" in ext-compose.js. r=mkmelin
authorGeoff Lankow <geoff@darktrojan.net>
Tue, 02 Jun 2020 12:40:14 +1200
changeset 29755 eac3756825dabeae24134186b731d22039529f43
parent 29754 90acb84d2bf6a56773ba7e88a1aa74d3157669c2
child 29756 f00e8c7891ad452137199920c59020d121844069
push id17517
push usergeoff@darktrojan.net
push dateWed, 03 Jun 2020 05:06:57 +0000
treeherdercomm-central@cf52a9080e3f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmkmelin
bugs1642522
Bug 1642522 - Fix "this._attachmentIds.get(...) is undefined" in ext-compose.js. r=mkmelin
mail/components/extensions/parent/ext-compose.js
--- a/mail/components/extensions/parent/ext-compose.js
+++ b/mail/components/extensions/parent/ext-compose.js
@@ -318,19 +318,21 @@ var composeAttachmentTracker = {
     return this._attachments.get(id);
   },
 
   hasAttachment(id) {
     return this._attachments.has(id);
   },
 
   forgetAttachment(attachment) {
-    let id = this._attachmentIds.get(attachment).id;
-    this._attachmentIds.delete(attachment);
+    // This is called on all attachments when the window closes, whether the
+    // attachments have been assigned IDs or not.
+    let id = this._attachmentIds.get(attachment)?.id;
     if (id) {
+      this._attachmentIds.delete(attachment);
       this._attachments.delete(id);
     }
   },
 
   forgetAttachments(window) {
     if (window.location.href == COMPOSE_WINDOW_URI) {
       let bucket = window.document.getElementById("attachmentBucket");
       for (let item of bucket.itemChildren) {