[Pkg-mozext-commits] [tabmixplus] 106/147: Follow up bug 1334831 - add an eslint rule to report usage of .parentNode.removeChild when .remove() could be used instead

David Prévot taffit at moszumanska.debian.org
Sat Aug 5 15:27:42 UTC 2017


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

taffit pushed a commit to branch master
in repository tabmixplus.

commit acd756a084f66efbb633ea9a26d7cba15d5fff8a
Author: onemen <tabmix.onemen at gmail.com>
Date:   Tue Jan 31 10:58:19 2017 +0200

    Follow up bug 1334831 - add an eslint rule to report usage of .parentNode.removeChild when .remove() could be used instead
---
 .eslintrc.js                                           | 1 +
 chrome/content/click/click.js                          | 9 +++++----
 chrome/content/flst/lasttab.js                         | 5 +++--
 chrome/content/preferences/preferences.js              | 2 +-
 chrome/content/preferences/shortcuts.xml               | 5 +++--
 chrome/content/preferences/subdialogs/pref-filetype.js | 4 ++--
 chrome/content/session/session.js                      | 2 +-
 modules/AutoReload.jsm                                 | 5 +++--
 modules/Shortcuts.jsm                                  | 2 +-
 9 files changed, 20 insertions(+), 15 deletions(-)

diff --git a/.eslintrc.js b/.eslintrc.js
index c80cff0..9288fc3 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -14,6 +14,7 @@ module.exports = {
   },
 
   "rules": {
+    "tabmix/avoid-removeChild": 2,
     "tabmix/balanced-listeners": 2,
     "tabmix/import-globals": 2,
     "tabmix/no-single-arg-cu-import": 2,
diff --git a/chrome/content/click/click.js b/chrome/content/click/click.js
index 7fe9447..d9ce1f8 100644
--- a/chrome/content/click/click.js
+++ b/chrome/content/click/click.js
@@ -915,7 +915,7 @@ var TabmixAllTabs = {
         break;
       menuItem.removeEventListener("command", TMP_ClosedTabs);
       menuItem.removeEventListener("click", TMP_ClosedTabs);
-      popup.removeChild(menuItem);
+      menuItem.remove();
     }
 
     if (!aCloseTabsPopup) {
@@ -1057,8 +1057,9 @@ var TabmixAllTabs = {
 
   _tabOnTabClose: function TMP__tabOnTabClose(aEvent) {
     var menuItem = aEvent.target.mCorrespondingMenuitem;
-    if (menuItem && menuItem.parentNode)
-      menuItem.parentNode.removeChild(menuItem);
+    if (menuItem) {
+      menuItem.remove();
+    }
   },
 
   _tabsListOncommand: function TMP__tabsListOncommand(aEvent) {
@@ -1083,7 +1084,7 @@ var TabmixAllTabs = {
       if ("tab" in menuItem) {
         menuItem.tab.mCorrespondingMenuitem = null;
       }
-      popup.removeChild(menuItem);
+      menuItem.remove();
     }
 
     var item = popup.parentNode;
diff --git a/chrome/content/flst/lasttab.js b/chrome/content/flst/lasttab.js
index 828766c..2727dc6 100644
--- a/chrome/content/flst/lasttab.js
+++ b/chrome/content/flst/lasttab.js
@@ -330,8 +330,9 @@ var TMP_LastTab = {
     if (!this.SuppressTabListReset) {
       var tablist = this.TabList;
 
-      while (tablist.childNodes.length > 0)
-        tablist.removeChild(tablist.childNodes[0]);
+      while (tablist.childNodes.length > 0) {
+        tablist.firstChild.remove();
+      }
 
       this.TabListLock = false;
       this.TabIndex = 0;
diff --git a/chrome/content/preferences/preferences.js b/chrome/content/preferences/preferences.js
index 519ba23..30096bd 100644
--- a/chrome/content/preferences/preferences.js
+++ b/chrome/content/preferences/preferences.js
@@ -181,7 +181,7 @@ var gPrefWindow = {
     // override preferences getter before we remove the preference
     if (child.localName == "preference")
       Object.defineProperty(child, "preferences", {value: child.parentNode});
-    child.parentNode.removeChild(child);
+    child.remove();
   },
 
   initBroadcasters(paneID) {
diff --git a/chrome/content/preferences/shortcuts.xml b/chrome/content/preferences/shortcuts.xml
index b0dadf6..b5dffc5 100644
--- a/chrome/content/preferences/shortcuts.xml
+++ b/chrome/content/preferences/shortcuts.xml
@@ -98,8 +98,9 @@
           var shortcut = !this.disabled && getFormattedKey(this.key);
           var usedKey = shortcut && getKeysForShortcut(shortcut, this.keyid);
           var box = this.notificationbox;
-          while (box.hasChildNodes())
-            box.removeChild(box.firstChild);
+          while (box.hasChildNodes()) {
+            box.firstChild.remove();
+          }
           if (usedKey) {
             let msg = (box.getAttribute("inuse") + ":\n" + usedKey).split("\n");
             for (let i = 0, l = msg.length; i < l; i++) {
diff --git a/chrome/content/preferences/subdialogs/pref-filetype.js b/chrome/content/preferences/subdialogs/pref-filetype.js
index e493e5a..d35e2e2 100644
--- a/chrome/content/preferences/subdialogs/pref-filetype.js
+++ b/chrome/content/preferences/subdialogs/pref-filetype.js
@@ -17,7 +17,7 @@ function Init() {
 function FillData() {
   // remove all the item from the list
   while (list.hasChildNodes()) {
-    list.removeChild(list.lastChild);
+    list.lastChild.remove();
   }
 
   var data, items, item;
@@ -125,7 +125,7 @@ function Del() {
     SelectItemAt(index == list.getRowCount() - 1 ? index - 1 : index + 1, true);
   else
     entry.value = null;
-  list.removeChild(item);
+  item.remove();
 }
 
 function Restore() {
diff --git a/chrome/content/session/session.js b/chrome/content/session/session.js
index c1ea289..5c0e4aa 100644
--- a/chrome/content/session/session.js
+++ b/chrome/content/session/session.js
@@ -1863,7 +1863,7 @@ TabmixSessionManager = {
           break;
       } else if (destroy) {
         i--;
-        menu.removeChild(item);
+        item.remove();
       } else if (item.id.indexOf("-startSeparator") != -1) destroy = true;
     }
     return endSeparator;
diff --git a/modules/AutoReload.jsm b/modules/AutoReload.jsm
index 49f6720..b8ef2e4 100644
--- a/modules/AutoReload.jsm
+++ b/modules/AutoReload.jsm
@@ -77,8 +77,9 @@ this.AutoReload = {
   updateCustomList(aPopup) {
     let start = aPopup.getElementsByAttribute("anonid", "start_custom_list")[0];
     let end = aPopup.getElementsByAttribute("anonid", "end_custom_list")[0];
-    while (start.nextSibling && start.nextSibling != end)
-      aPopup.removeChild(start.nextSibling);
+    while (start.nextSibling && start.nextSibling != end) {
+      start.nextSibling.remove();
+    }
 
     // get the custom list and validate its values
     function getList() {
diff --git a/modules/Shortcuts.jsm b/modules/Shortcuts.jsm
index a3f031d..e9db052 100644
--- a/modules/Shortcuts.jsm
+++ b/modules/Shortcuts.jsm
@@ -85,7 +85,7 @@ this.Shortcuts = {
       for (let att of box.attributes) {
         labels[att.name] = att.value;
       }
-      container.removeChild(box);
+      box.remove();
     }
     labels.togglePinTab =
       $("context_pinTab").getAttribute("label") + "/" +

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/tabmixplus.git



More information about the Pkg-mozext-commits mailing list