Bug 1578982 - Fix category colour display if category name contains space; r=pmorris
authorGeoff Lankow <geoff@darktrojan.net>
Mon, 16 Sep 2019 14:55:33 +1200
changeset 79008 944c4a8f2b236ad6afe3423fcc3fc0c711fc669b
parent 79007 23362b85a4faf30a1fcebddf9a220a52ac69ab84
child 79009 315a09d57f1b8ab47495af5a80c19f8fafe11813
push id9335
push usermozilla@jorgk.com
push dateThu, 19 Sep 2019 10:56:46 +0000
treeherdertry-comm-central@ec7a23f9bcfd [default view] [failures only]
reviewerspmorris
bugs1578982
Bug 1578982 - Fix category colour display if category name contains space; r=pmorris
calendar/base/modules/utils/calViewUtils.jsm
--- a/calendar/base/modules/utils/calViewUtils.jsm
+++ b/calendar/base/modules/utils/calViewUtils.jsm
@@ -389,24 +389,26 @@ calview.colorTracker = {
   },
   _removeCalendarFromDocument(aDocument, aCalendar) {
     let cssSafeId = calview.formatStringForCSSRule(aCalendar.id);
     let style = aDocument.documentElement.style;
     style.removeProperty(`--calendar-${cssSafeId}-backcolor`);
     style.removeProperty(`--calendar-${cssSafeId}-forecolor`);
   },
   _addCategoryToDocument(aDocument, aCategoryName) {
+    // aCategoryName should already be formatted for CSS, because that's
+    // what is stored in the prefs, and this function is only called with
+    // arguments that come from the prefs.
     if (/[^\w-]/.test(aCategoryName)) {
       return;
     }
 
-    let cssSafeName = calview.formatStringForCSSRule(aCategoryName);
     let style = aDocument.documentElement.style;
     let color = this.categoryBranch.getStringPref(aCategoryName, "transparent");
-    style.setProperty(`--category-${cssSafeName}-color`, color);
+    style.setProperty(`--category-${aCategoryName}-color`, color);
   },
   _addAllCategoriesToDocument(aDocument) {
     for (let categoryName of this.categoryBranch.getChildList("")) {
       this._addCategoryToDocument(aDocument, categoryName);
     }
   },
 
   // calICalendarManagerObserver methods