Bug 1556192 - Check attachment bucket target in onDragOver and onDrop before using .matches. r=jorgk
authorGeoff Lankow <geoff@darktrojan.net>
Wed, 05 Jun 2019 09:12:00 +0200
changeset 35772 cc7e364a250430cfb4ceddf7bbc0d240c7f3f136
parent 35771 b12420c26104dd203307856e5086cb3139493c89
child 35773 5116ce5bc260ce3aa7cc7c975eca2149bc14c8c6
push id392
push userclokep@gmail.com
push dateMon, 02 Sep 2019 20:17:19 +0000
reviewersjorgk
bugs1556192
Bug 1556192 - Check attachment bucket target in onDragOver and onDrop before using .matches. r=jorgk
mail/components/compose/content/MsgComposeCommands.js
--- a/mail/components/compose/content/MsgComposeCommands.js
+++ b/mail/components/compose/content/MsgComposeCommands.js
@@ -5817,17 +5817,18 @@ var envelopeDragObserver = {
       let selItems = attachmentsSelectionGetSortedArray();
       // Keep track of the item we had focused originally. Deselect it though,
       // since listbox gets confused if you move its focused item around.
       let focus = bucket.currentItem;
       bucket.currentItem = null;
 
       // Moving possibly non-coherent multiple selections around correctly
       // is much more complex than one might think...
-      if (target.matches("richlistitem.attachmentItem") || target == "afterLastItem") {
+      if ((target.matches && target.matches("richlistitem.attachmentItem")) ||
+          target == "afterLastItem") {
         // Drop before targetItem in the list, or after last item.
         let blockItems = [];
         let targetItem;
         for (let item of selItems) {
           blockItems.push(item);
           if (target == "afterLastItem") {
             // Original target is the end of the list; append all items there.
             bucket.appendChild(item);
@@ -5984,17 +5985,18 @@ var envelopeDragObserver = {
     let bucket = document.getElementById("attachmentBucket");
     let dragSourceNode = aDragSession.sourceNode;
     if (dragSourceNode && dragSourceNode.parentNode == bucket) {
       // If we're dragging from the attachment bucket onto itself, we need to
       // show a drop marker.
 
       let target = this._adjustDropTarget(aEvent);
 
-      if (target && (target.matches("richlistitem.attachmentItem") || target == "afterLastItem")) {
+      if ((target.matches && target.matches("richlistitem.attachmentItem")) ||
+          target == "afterLastItem") {
         // Adjusted target is an attachment list item; show dropmarker.
         this._showDropMarker(target);
       } else {
         // target == "none", target is not a listItem, or no target:
         // Indicate that we can't drop here.
         this._hideDropMarker();
         aEvent.dataTransfer.dropEffect = "none";
       }