Bug 1386197 - Show/Hide recently bookmarked menuitems don't exist in the Library window on Mac, handle the case so to avoid exceptions stopping listeners being removed. r?mak
MozReview-Commit-ID: 6zcw2Q7vRYI
--- a/browser/base/content/browser-places.js
+++ b/browser/base/content/browser-places.js
@@ -1504,20 +1504,24 @@ var BookmarkingUI = {
this._recentlyBookmarkedObserver.onItemRemoved = () => {
// Update the menu when a bookmark has been removed.
// The native menubar on Mac doesn't support live update, so this won't
// work there.
this._populateRecentBookmarks(aHeaderItem, aExtraCSSClass);
};
let updatePlacesContextMenu = (shouldHidePrefUI = false) => {
- let prefEnabled = !shouldHidePrefUI && Services.prefs.getBoolPref(this.RECENTLY_BOOKMARKED_PREF);
let showItem = document.getElementById("placesContext_showRecentlyBookmarked");
+ // On Mac the menuitem doesn't exist when we're in the Library window context.
+ if (!showItem) {
+ return;
+ }
let hideItem = document.getElementById("placesContext_hideRecentlyBookmarked");
let separator = document.getElementById("placesContext_recentlyBookmarkedSeparator");
+ let prefEnabled = !shouldHidePrefUI && Services.prefs.getBoolPref(this.RECENTLY_BOOKMARKED_PREF);
showItem.hidden = shouldHidePrefUI || prefEnabled;
hideItem.hidden = shouldHidePrefUI || !prefEnabled;
separator.hidden = shouldHidePrefUI;
if (!shouldHidePrefUI) {
// Move to the bottom of the menu.
separator.parentNode.appendChild(separator);
showItem.parentNode.appendChild(showItem);
hideItem.parentNode.appendChild(hideItem);