Bug 1499489 - handle CompactTheme.styleSheet getter when trying to set its value. r=arai
authoraceman <acelists@atlas.sk>
Wed, 17 Oct 2018 14:17:00 +0200
changeset 33396 6482582d97bf02583e76259899771454a1606645
parent 33395 ba6de8f2e729d721f36b8379eaf3bbabb96fd982
child 33397 a312c7cf1c0e033c261b8e6e97e4b2de476a158e
push id387
push userclokep@gmail.com
push dateMon, 10 Dec 2018 21:30:47 +0000
reviewersarai
bugs1499489
Bug 1499489 - handle CompactTheme.styleSheet getter when trying to set its value. r=arai
mail/base/content/mail-compacttheme.js
--- a/mail/base/content/mail-compacttheme.js
+++ b/mail/base/content/mail-compacttheme.js
@@ -2,16 +2,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /**
  * Enables compacttheme.css when needed.
  */
 var CompactTheme = {
   get styleSheet() {
+    // Change getter into a read/write property.
     delete this.styleSheet;
     for (let styleSheet of document.styleSheets) {
       if (styleSheet.href == "chrome://messenger/skin/compacttheme.css") {
         this.styleSheet = styleSheet;
         break;
       }
     }
     return this.styleSheet;
@@ -58,11 +59,14 @@ var CompactTheme = {
       this.styleSheet.disabled = false;
     } else if (!enabled && wasEnabled) {
       this.styleSheet.disabled = true;
     }
   },
 
   uninit() {
     Services.obs.removeObserver(this, "lightweight-theme-styling-update");
+    // If the getter still exists, remove it.
+    if (Object.getOwnPropertyDescriptor(this, "styleSheet").get)
+      delete this.styleSheet;
     this.styleSheet = null;
   }
 };