Bug 1346797 - Fix calendar eslint issues - Fix mozilla/use-default-preference-values issues. r=MakeMyDay
authoreslint <eslint@bugzilla.kewis.ch>
Sun, 30 Jul 2017 13:28:41 +0200
changeset 29135 1ab10b6c3b56a2ba0f39021d923db1ef21b0761e
parent 29134 b97e6e08645d15f892d3a30341c9d19b6cc2b3f3
child 29136 19af38e2d4b143f9d671a885be48eb0610e521d3
push id2068
push userclokep@gmail.com
push dateMon, 13 Nov 2017 19:02:14 +0000
treeherdercomm-beta@9c7e7ce8672b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMakeMyDay
bugs1346797
Bug 1346797 - Fix calendar eslint issues - Fix mozilla/use-default-preference-values issues. r=MakeMyDay MozReview-Commit-ID: D9KirkOnTdB
calendar/base/content/preferences/categories.js
calendar/base/content/preferences/editCategory.js
--- a/calendar/base/content/preferences/categories.js
+++ b/calendar/base/content/preferences/categories.js
@@ -142,22 +142,18 @@ var gCategoriesPane = {
     },
 
     /**
      * Edits the currently selected category using the edit category dialog.
      */
     editCategory: function() {
         let list = document.getElementById("categorieslist");
         let categoryNameFix = cal.formatStringForCSSRule(gCategoryList[list.selectedIndex]);
-        let currentColor = null;
-        try {
-            currentColor = categoryPrefBranch.getCharPref(categoryNameFix);
-        } catch (ex) {
-            // If the pref doesn't exist, don't bail out here.
-        }
+        let currentColor = categoryPrefBranch.getCharPref(categoryNameFix, "");
+
         let params = {
             title: editTitle,
             category: gCategoryList[list.selectedIndex],
             color: currentColor
         };
         if (list.selectedItem) {
             if (this.mLoadInContent) {
                 gSubDialog.open(this.mCategoryDialog, "resizable=no", params);
@@ -282,23 +278,17 @@ var gCategoriesPane = {
 
     /**
      * Backs up the category name in case the dialog is canceled.
      *
      * @see formatStringForCSSRule
      * @param categoryNameFix     The formatted category name.
      */
     backupData: function(categoryNameFix) {
-        let currentColor;
-        try {
-            currentColor = categoryPrefBranch.getCharPref(categoryNameFix);
-        } catch (ex) {
-            dump("Exception caught in 'backupData': " + ex + "\n");
-            currentColor = "##NEW";
-        }
+        let currentColor = categoryPrefBranch.getCharPref(categoryNameFix, "##NEW");
 
         for (let i = 0; i < parent.backupPrefList.length; i++) {
             if (categoryNameFix == parent.backupPrefList[i].name) {
                 return;
             }
         }
         parent.backupPrefList[parent.backupPrefList.length] =
             { name: categoryNameFix, color: currentColor };
--- a/calendar/base/content/preferences/editCategory.js
+++ b/calendar/base/content/preferences/editCategory.js
@@ -10,17 +10,17 @@ Components.utils.import("resource://cale
 var customColorSelected = false;
 
 /**
  * Load Handler, called when the edit category dialog is loaded
  */
 function editCategoryLoad() {
     let winArg = window.arguments[0];
     let color = winArg.color || cal.hashColor(winArg.category);
-    let hasColor = (winArg.color != null);
+    let hasColor = !!winArg.color;
     document.getElementById("categoryName").value = winArg.category;
     document.getElementById("categoryColor").value = color;
     document.getElementById("useColor").checked = hasColor;
     customColorSelected = hasColor;
     document.title = winArg.title;
 
     toggleColor();
 }