Bug 1407164 - Fix strict warnings in Bookmarks.jsm relating to undefined property source - don't delete item properties too soon. r?mak draft
authorMark Banner <standard8@mozilla.com>
Tue, 10 Oct 2017 09:13:19 +0100
changeset 677140 b3dd217bc891ab4a6353810c0fc0874279ec0940
parent 677139 4494c218fe4d16f1413d74b37b7fa178111951be
child 735134 d72f98af93976e8cc44df0b4f9bd5c1a23b4b14a
push id83711
push userbmo:standard8@mozilla.com
push dateTue, 10 Oct 2017 08:14:26 +0000
reviewersmak
bugs1407164
milestone58.0a1
Bug 1407164 - Fix strict warnings in Bookmarks.jsm relating to undefined property source - don't delete item properties too soon. r?mak MozReview-Commit-ID: AJJRSHYqPch
toolkit/components/places/Bookmarks.jsm
--- a/toolkit/components/places/Bookmarks.jsm
+++ b/toolkit/components/places/Bookmarks.jsm
@@ -473,24 +473,24 @@ var Bookmarks = Object.freeze({
           parentId = itemIdMap.get(item.parentGuid);
         }
 
         notify(observers, "onItemAdded", [ itemId, parentId, item.index,
                                            item.type, uri, item.title,
                                            PlacesUtils.toPRTime(item.dateAdded), item.guid,
                                            item.parentGuid, item.source ],
                                          { isTagging: false });
-        // Remove non-enumerable properties.
-        delete item.source;
-
         // Note, annotations for livemark data are deleted from insertInfo
         // within appendInsertionInfoForInfoArray, so we won't be duplicating
         // the insertions here.
         await handleBookmarkItemSpecialData(itemId, item);
 
+        // Remove non-enumerable properties.
+        delete item.source;
+
         insertInfos[i] = Object.assign({}, item);
       }
       return insertInfos;
     })();
   },
 
   /**
    * Updates a bookmark-item.
@@ -1543,17 +1543,17 @@ async function handleBookmarkItemSpecial
         source: item.source
       });
     } catch (ex) {
       Cu.reportError(`Failed to insert keywords: ${ex}`);
     }
   }
   if ("tags" in item) {
     try {
-      PlacesUtils.tagging.tagURI(NetUtil.newURI(item.url), item.tags, item._source);
+      PlacesUtils.tagging.tagURI(NetUtil.newURI(item.url), item.tags, item.source);
     } catch (ex) {
       // Invalid tag child, skip it.
       Cu.reportError(`Unable to set tags "${item.tags.join(", ")}" for ${item.url}: ${ex}`);
     }
   }
   if ("charset" in item && item.charset) {
     await PlacesUtils.setCharsetForURI(NetUtil.newURI(item.url), item.charset);
   }