[Pkg-mozext-commits] [adblock-plus-element-hiding-helper] 02/10: Issue 2259 - Removed non-standard JavaScript code

David Prévot taffit at moszumanska.debian.org
Fri Jan 22 01:02:30 UTC 2016


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to tag pre-hg-git-0.8
in repository adblock-plus-element-hiding-helper.

commit 62097d9e515bfdbb50994ec49180124b701e1991
Author: Sebastian Noack <sebastian at adblockplus.org>
Date:   Wed Apr 1 17:16:13 2015 +0200

    Issue 2259 - Removed non-standard JavaScript code
---
 chrome/content/composer.js | 18 +++++++-----------
 lib/aardvark.js            |  8 ++++----
 lib/inspectorObserver.js   |  3 +--
 lib/main.js                | 12 +++---------
 lib/windowWrapper.js       |  4 ++--
 5 files changed, 17 insertions(+), 28 deletions(-)

diff --git a/chrome/content/composer.js b/chrome/content/composer.js
index 498ba56..d8a45f7 100644
--- a/chrome/content/composer.js
+++ b/chrome/content/composer.js
@@ -101,11 +101,10 @@ function createPropertyProxy(obj, orig, key) {
     };
   }
   else {
-    obj.__defineGetter__(key, function() {
-      return orig[key];
-    });
-    obj.__defineSetter__(key, function(value) {
-      orig[key] = value;
+    Object.defineProperty(obj, key, {
+      get: () => orig[key],
+      set: value => { orig[key] = value; },
+      enumerable: true
     });
   }
 }
@@ -249,12 +248,9 @@ function updateExpression()
             expression += "#" + escapeName(attr.selected).replace(/^([^a-zA-Z\\])/, escapeChar).replace(/\\(\s)$/, escapeChar);
           else if (attr.name == "class" && /\S/.test(attr.selected))
           {
-            let knownClasses = {};
-            for each (let cls in attr.value.split(/\s+/))
-              knownClasses[cls] = true;
-
-            let classes = attr.selected.split(/\s+/).filter(function(cls) cls != "");
-            if (classes.every(function(cls) knownClasses.hasOwnProperty(cls)))
+            let knownClasses = new Set(attr.value.split(/\s+/));
+            let classes = attr.selected.split(/\s+/).filter(cls => cls != "");
+            if (classes.every(cls => knownClasses.has(cls)))
               expression += "." + classes.map(escapeName).join(".");
             else
               useFallback = true;
diff --git a/lib/aardvark.js b/lib/aardvark.js
index c36e33c..899ba2a 100644
--- a/lib/aardvark.js
+++ b/lib/aardvark.js
@@ -7,7 +7,7 @@
 let {Prefs} = require("prefs");
 
 // Make sure to stop selection when we are uninstalled
-onShutdown.add(function() Aardvark.quit());
+onShutdown.add(() => Aardvark.quit());
 
 // To be replaced when selection starts
 function E(id) {return null;}
@@ -60,7 +60,7 @@ let Aardvark = exports.Aardvark =
 
     this.window = wrapper.window;
     this.browser = wrapper.browser;
-    E = function(id) wrapper.E(id);
+    E = id => wrapper.E(id);
 
     this.browser.addEventListener("click", this.onMouseClick, true);
     this.browser.addEventListener("DOMMouseScroll", this.onMouseScroll, true);
@@ -563,7 +563,7 @@ let Aardvark = exports.Aardvark =
     this.commentElem = null;
     this.lockedAnchor = null;
     this.boxElem = null;
-    E = function(id) null;
+    E = id => null;
     return false;
   },
 
@@ -752,5 +752,5 @@ let Aardvark = exports.Aardvark =
 
 // Makes sure event handlers like Aardvark.onKeyPress always have the correct
 // this pointer set.
-for each (let method in ["onMouseClick", "onMouseScroll", "onKeyPress", "onPageHide", "onMouseMove", "onAfterPaint", "quit"])
+for (let method of ["onMouseClick", "onMouseScroll", "onKeyPress", "onPageHide", "onMouseMove", "onAfterPaint", "quit"])
   Aardvark[method] = Aardvark[method].bind(Aardvark);
diff --git a/lib/inspectorObserver.js b/lib/inspectorObserver.js
index e2a72bc..31b9fe1 100644
--- a/lib/inspectorObserver.js
+++ b/lib/inspectorObserver.js
@@ -32,8 +32,7 @@ let InspectorObserver =
     let stringBundle = Services.strings.createBundle("chrome://elemhidehelper/locale/global.properties?" + Math.random());
     let result = stringBundle.GetStringFromName("inspector.button.tooltiptext");
 
-    delete this.inspectorButtonTooltip;
-    this.__defineGetter__("inspectorButtonTooltip", function() result);
+    Object.defineProperty(this, "inspectorButtonTooltip", {value: result, enumerable: true});
     return this.inspectorButtonTooltip;
   },
 
diff --git a/lib/main.js b/lib/main.js
index c46480e..e8ca127 100644
--- a/lib/main.js
+++ b/lib/main.js
@@ -15,13 +15,7 @@ Prefs.migrate("extensions.adblockplus.ehh-selectelement_key", "selectelement_key
 Prefs.migrate("extensions.adblockplus.ehh.showhelp", "showhelp");
 
 // Window types to attach to
-let knownWindowTypes =
-{
-  "navigator:browser": true,
-  "mail:3pane": true,
-  "mail:messageWindow": true,
-  __proto__: null
-};
+let knownWindowTypes = new Set(["navigator:browser", "mail:3pane", "mail:messageWindow"]);
 
 // Use random marker class
 let elementMarkerClass = null;
@@ -48,7 +42,7 @@ request.addEventListener("load", function(event)
   let styleService = Cc["@mozilla.org/content/style-sheet-service;1"].getService(Ci.nsIStyleSheetService);
   let styleURI = Services.io.newURI("data:text/css," + encodeURIComponent(data), null, null);
   styleService.loadAndRegisterSheet(styleURI, Ci.nsIStyleSheetService.USER_SHEET);
-  onShutdown.add(function() styleService.unregisterSheet(styleURI, Ci.nsIStyleSheetService.USER_SHEET));
+  onShutdown.add(() => styleService.unregisterSheet(styleURI, Ci.nsIStyleSheetService.USER_SHEET));
 }, false);
 request.send(null);
 
@@ -68,7 +62,7 @@ request.addEventListener("load", function(event)
     applyToWindow: function(window)
     {
       let type = window.document.documentElement.getAttribute("windowtype");
-      if (!(type in knownWindowTypes) || window._ehhWrapper)
+      if (!knownWindowTypes.has(type) || window._ehhWrapper)
         return;
 
       window.document.documentElement.appendChild(overlay.cloneNode(true));
diff --git a/lib/windowWrapper.js b/lib/windowWrapper.js
index 7157a91..06bc124 100644
--- a/lib/windowWrapper.js
+++ b/lib/windowWrapper.js
@@ -16,7 +16,7 @@ function getMenuItem()
   let stringBundle = Services.strings.createBundle("chrome://elemhidehelper/locale/global.properties?" + Math.random());
   let result = [stringBundle.GetStringFromName("selectelement.label"), stringBundle.GetStringFromName("stopselection.label")];
 
-  getMenuItem = function() result;
+  getMenuItem = () => result;
   return getMenuItem();
 }
 
@@ -68,7 +68,7 @@ WindowWrapper.prototype =
   E: function(id)
   {
     let doc = this.window.document;
-    this.E = function(id) doc.getElementById(id);
+    this.E = id => doc.getElementById(id);
     return this.E(id);
   },
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/adblock-plus-element-hiding-helper.git



More information about the Pkg-mozext-commits mailing list