Bug 1642522 - Fix "this._attachmentIds.get(...) is undefined" in ext-compose.js. r=mkmelin a=wsmwk
authorGeoff Lankow <geoff@darktrojan.net>
Tue, 02 Jun 2020 12:40:14 +1200
changeset 38431 71067085a23255de547fc7c3d07dce005aa18001
parent 38430 1a0751bf3bb36adeb5f5f1b4da79f0958ffd1323
child 38432 1a47d65e5ec71059976a8a8eef137654e0b6d337
push id2610
push userthunderbird@calypsoblue.org
push dateFri, 05 Jun 2020 01:20:42 +0000
treeherdercomm-beta@8672ba724e87 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmkmelin, wsmwk
bugs1642522
Bug 1642522 - Fix "this._attachmentIds.get(...) is undefined" in ext-compose.js. r=mkmelin a=wsmwk
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) {