Bug 1578982 - Fix category colour display if category name contains space; r+a=pmorris
authorGeoff Lankow <geoff@darktrojan.net>
Mon, 16 Sep 2019 14:55:33 +1200
changeset 79093 f402ca19bdad242060bb2e2b204b6df2580b0a2c
parent 79092 86d616d69a43ea9fa50e30dce0196517f966e7ec
child 79094 8548767c8a99cdbaf234e6bd20fe4e9545aea1f7
push id9345
push userkaie@kuix.de
push dateFri, 20 Sep 2019 05:14:40 +0000
treeherdertry-comm-central@b9101c33b5e5 [default view] [failures only]
bugs1578982
Bug 1578982 - Fix category colour display if category name contains space; r+a=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