From 3739904ce94a5bcb31b66b25d66119aa0a074412 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Julien=20Pag=C3=A8s?= <j.parkouss@gmail.com>
Date: Sat, 6 May 2017 09:35:25 +0200
Subject: [PATCH] remove deprecated use of for each ... in

Replaced by for ... of constructions.
---
 contrib/xrev/content/xrev.js                |  8 ++++----
 modules/builtin-commands.js                 |  4 ++--
 modules/casual-spelling.jsx                 |  2 +-
 modules/command-line.js                     |  2 +-
 modules/content-buffer.js                   |  2 +-
 modules/download-manager.js                 |  2 +-
 modules/extensions/noscript.js              |  2 +-
 modules/help.js                             |  6 +++---
 modules/io.js                               |  2 +-
 modules/keymap.js                           |  6 +++---
 modules/media.js                            |  2 +-
 modules/mode-line.js                        |  2 +-
 modules/opensearch.js                       |  4 ++--
 modules/page-modes/google-images.js         |  8 ++++----
 modules/page-modes/google-search-results.js |  4 ++--
 modules/page-modes/reddit.js                |  4 ++--
 modules/page-modes/wikipedia.js             |  2 +-
 modules/page-modes/youtube.js               | 10 +++++-----
 modules/selectively-unstyle.js              |  4 ++--
 modules/spawn-process.js                    |  2 +-
 modules/theme.js                            |  6 +++---
 modules/user-agent-policy.jsx               |  2 +-
 modules/utils.js                            |  8 ++++----
 23 files changed, 47 insertions(+), 47 deletions(-)

diff --git a/contrib/xrev/content/xrev.js b/contrib/xrev/content/xrev.js
index b30c6eb..57ea737 100644
--- a/contrib/xrev/content/xrev.js
+++ b/contrib/xrev/content/xrev.js
@@ -88,7 +88,7 @@ function key_event_handler (event) {
         row.appendChild(cap);
     }
 
-    for each (var k in key_event_props) {
+    for (var k of key_event_props) {
         addcell(get_field(k));
     }
     var charname = '';
@@ -109,7 +109,7 @@ function key_event_handler (event) {
     table.ensureElementIsVisible(row);
     // text output
     dump([get_field(k).toString().pad(' ',11)
-          for each (k in key_event_props)].join(''));
+          for (k of key_event_props)].join(''));
     dumpln(charname);
 }
 window.addEventListener("keydown", key_event_handler, true /* capture */);
@@ -133,11 +133,11 @@ function onload_handler () {
         coldef.appendChild(u);
     }
 
-    for each (var k in headings) {
+    for (var k of headings) {
         addcol(k);
     }
     table.appendChild(head);
     table.appendChild(coldef);
     // text output
-    dumpln([k.pad(' ',11) for each (k in headings)].join(''));
+    dumpln([k.pad(' ',11) for (k of headings)].join(''));
 }
diff --git a/modules/builtin-commands.js b/modules/builtin-commands.js
index 505db53..1334d29 100644
--- a/modules/builtin-commands.js
+++ b/modules/builtin-commands.js
@@ -175,7 +175,7 @@ function define_builtin_commands (prefix, do_command_function, mode) {
             "To toggle whether the mark is active, use `" + prefix + "set-mark'.";
     }
 
-    for each (let c_temp in builtin_commands) {
+    for (let c_temp of builtin_commands) {
         let c = c_temp;
         if (c.is_move_select_pair) {
             interactive(prefix + c.command, get_move_select_doc_string(c), function (I) {
@@ -207,7 +207,7 @@ function define_builtin_commands (prefix, do_command_function, mode) {
                     });
     }
 
-    for each (let c_temp in builtin_commands_with_count) {
+    for (let c_temp of builtin_commands_with_count) {
         let c = c_temp;
         if (c.is_reverse_pair) {
             if (c[0].is_move_select_pair) {
diff --git a/modules/casual-spelling.jsx b/modules/casual-spelling.jsx
index 96a030f..53852ac 100644
--- a/modules/casual-spelling.jsx
+++ b/modules/casual-spelling.jsx
@@ -22,7 +22,7 @@ such as accented letters and ligatures.
 function table_entry_features (entry) {
     var ret = { ligatures: false, multiples: false };
     if (typeof entry == "object") {
-        for each (var t in entry) {
+        for (var t of entry) {
             if (typeof t == "string" && t.length > 1)
                 ret.ligatures = true;
             else if (typeof t == "object") {
diff --git a/modules/command-line.js b/modules/command-line.js
index ba3a926..e2f241e 100644
--- a/modules/command-line.js
+++ b/modules/command-line.js
@@ -159,7 +159,7 @@ function handle_command_line (cmdline) {
             let load_mods = new RegExp("^(" + get_pref("conkeror.loadModules") + ")$");
             try {
                 let branch = preferences.getBranch("conkeror.load.");
-                for each (let m in branch.getChildList("", {})) {
+                for (let m of branch.getChildList("", {})) {
                     let val;
                     try {
                         val = branch.getIntPref(m);
diff --git a/modules/content-buffer.js b/modules/content-buffer.js
index 8687595..7f4870a 100644
--- a/modules/content-buffer.js
+++ b/modules/content-buffer.js
@@ -736,7 +736,7 @@ function page_mode_update (buffer) {
         conkeror[p].disable(buffer);
     }
     var uri = buffer.current_uri;
-    for each (var name in active_page_modes) {
+    for (var name of active_page_modes) {
         var m = conkeror[name];
         m.test.some(
             function (test) {
diff --git a/modules/download-manager.js b/modules/download-manager.js
index f66d736..66116d0 100644
--- a/modules/download-manager.js
+++ b/modules/download-manager.js
@@ -467,7 +467,7 @@ if (!use_downloads_jsm) {
                     } else
                         ids.push(id);
                 }
-                for each (let i in ids) {
+                for (let i of ids) {
                     dumpln("deleting download: " + i);
                     let d = id_to_download_info[i];
                     d.removed = true;
diff --git a/modules/extensions/noscript.js b/modules/extensions/noscript.js
index 57e35ac..c566b0a 100644
--- a/modules/extensions/noscript.js
+++ b/modules/extensions/noscript.js
@@ -49,7 +49,7 @@ function setObjectVisibility (document, callback) {
         className: ns.hideObjClassName
     };
     var objects = null;
-    for each (var tag in tags) {
+    for (var tag of tags) {
         var local_objects = document.getElementsByTagName(tag);
         var count = local_objects.count;
         if (count) {
diff --git a/modules/help.js b/modules/help.js
index 69675fb..e1ad4e7 100644
--- a/modules/help.js
+++ b/modules/help.js
@@ -168,7 +168,7 @@ describe_bindings_buffer.prototype = {
 
         var list_by_keymap = {};
         var keymap_list = [];
-        for each (let x in list) {
+        for (let x of list) {
             let name = x.bound_in || "";
             let km;
             if (name in list_by_keymap)
@@ -197,9 +197,9 @@ describe_bindings_buffer.prototype = {
 
         d.body.setAttribute("class", "help-list");
 
-        for each (let km in keymap_list) {
+        for (let km of keymap_list) {
             g.text(km.name, g.element("h1", d.body));
-            for each (let cat in km.category_list) {
+            for (let cat of km.category_list) {
                 if (cat.name != "")
                     g.text(cat.name, g.element("h2", d.body));
 
diff --git a/modules/io.js b/modules/io.js
index a58a3d8..d96097c 100644
--- a/modules/io.js
+++ b/modules/io.js
@@ -220,7 +220,7 @@ function string_input_stream(data) {
 function mime_input_stream(stream, headers) {
     var mime_stream = Cc["@mozilla.org/network/mime-input-stream;1"].createInstance(Ci.nsIMIMEInputStream);
     if (headers) {
-        for each (let [name,value] in headers) {
+        for (let [name,value] of headers) {
             mime_stream.addHeader(name,value);
         }
     }
diff --git a/modules/keymap.js b/modules/keymap.js
index ba4eb45..813d8c3 100644
--- a/modules/keymap.js
+++ b/modules/keymap.js
@@ -93,7 +93,7 @@ if (get_os() == 'Darwin') {
 
 function format_key_combo (event) {
     var combo = '';
-    for each (var M in modifier_order) {
+    for (var M of modifier_order) {
         if (modifiers[M].in_event_p(event) ||
             (event.sticky_modifiers &&
              event.sticky_modifiers.indexOf(M) != -1))
@@ -330,14 +330,14 @@ function for_each_key_binding (keymaps, callback) {
             return;
         in_keymaps.push(keymap);
         var binding;
-        for each (binding in keymap.bindings) {
+        for (binding of keymap.bindings) {
             binding_sequence.push(binding);
             callback(binding_sequence);
             if (binding.keymap)
                 helper(binding.keymap);
             binding_sequence.pop();
         }
-        for each (binding in keymap.predicate_bindings) {
+        for (binding of keymap.predicate_bindings) {
             binding_sequence.push(binding);
             callback(binding_sequence);
             if (binding.keymap)
diff --git a/modules/media.js b/modules/media.js
index 6e3539e..818c998 100644
--- a/modules/media.js
+++ b/modules/media.js
@@ -29,7 +29,7 @@ function media_scrape_default (buffer, results) {
         let base_uri = frame.document.documentURIObject;
 
         var uris = {};
-        for each (let x in matches) {
+        for (let x of matches) {
             let str = x;
             try {
                 let uri_obj = make_uri(str, null, base_uri);
diff --git a/modules/mode-line.js b/modules/mode-line.js
index ad0314f..858a37d 100644
--- a/modules/mode-line.js
+++ b/modules/mode-line.js
@@ -120,7 +120,7 @@ text_widget.prototype = {
     update: function () {},
 
     destroy: function () {
-        for each (let i in this.window_hooks) {
+        for (let i of this.window_hooks) {
             remove_hook.call(this.window, i[0], i[1]);
         }
     },
diff --git a/modules/opensearch.js b/modules/opensearch.js
index aa2cc52..7034a78 100644
--- a/modules/opensearch.js
+++ b/modules/opensearch.js
@@ -258,7 +258,7 @@ opensearch_url.prototype = {
 
 function opensearch_parse (node) {
     var eng = new opensearch_description();
-    for each (let child in node.childNodes) {
+    for (let child of node.childNodes) {
         switch (child.localName) {
         case "ShortName":
             eng.name = child.textContent;
@@ -272,7 +272,7 @@ function opensearch_parse (node) {
                 let method = child.getAttribute("method") || "GET";
                 let template = child.getAttribute("template");
                 let engine_url = new opensearch_url(type, method, template);
-                for each (let p in child.childNodes) {
+                for (let p of child.childNodes) {
                     if (p.localName == "Param") {
                         let name = p.getAttribute("name");
                         let value = p.getAttribute("value");
diff --git a/modules/page-modes/google-images.js b/modules/page-modes/google-images.js
index 98e1e25..77b2327 100644
--- a/modules/page-modes/google-images.js
+++ b/modules/page-modes/google-images.js
@@ -63,20 +63,20 @@ define_browser_object_class("google-images-imgurl", null,
 define_page_mode("google-images-mode",
     build_url_regexp($domain = /(.*\.)?google/, $path = "images"),
     function enable (buffer) {
-        for each (var c in google_images_imgrefurl_commands) {
+        for (var c of google_images_imgrefurl_commands) {
             buffer.default_browser_object_classes[c] =
                 browser_object_google_images_imgrefurl;
         }
-        for each (var c in google_images_imgurl_commands) {
+        for (var c of google_images_imgurl_commands) {
             buffer.default_browser_object_classes[c] =
                 browser_object_google_images_imgurl;
         }
     },
     function disable (buffer) {
-        for each (var c in google_images_imgrefurl_commands) {
+        for (var c of google_images_imgrefurl_commands) {
             delete buffer.default_browser_object_classes[c];
         }
-        for each (var c in google_images_imgurl_commands) {
+        for (var c of google_images_imgurl_commands) {
             delete buffer.default_browser_object_classes[c];
         }
     },
diff --git a/modules/page-modes/google-search-results.js b/modules/page-modes/google-search-results.js
index b3510c9..fbbf445 100644
--- a/modules/page-modes/google-search-results.js
+++ b/modules/page-modes/google-search-results.js
@@ -68,14 +68,14 @@ define_page_mode("google-search-results-mode",
                      $tlds = ["com", "com.au", "co.uk", "de", "dk", "es",
                               "fr", "it", "no", "se", "uk"]),
     function enable (buffer) {
-        for each (var c in google_search_results_link_commands) {
+        for (var c of google_search_results_link_commands) {
             buffer.default_browser_object_classes[c] =
                 browser_object_google_search_results_links;
         }
         buffer.content_modalities.push(google_search_results_modality);
     },
     function disable (buffer) {
-        for each (var c in google_search_results_link_commands) {
+        for (var c of google_search_results_link_commands) {
             delete buffer.default_browser_object_classes[c];
         }
         var i = buffer.content_modalities.indexOf(google_search_results_modality);
diff --git a/modules/page-modes/reddit.js b/modules/page-modes/reddit.js
index 1578f6d..f7017e1 100644
--- a/modules/page-modes/reddit.js
+++ b/modules/page-modes/reddit.js
@@ -516,14 +516,14 @@ var reddit_modality = {
 define_page_mode("reddit-mode",
     build_url_regexp($domain = /([a-zA-Z0-9\-]*\.)*reddit/),
     function enable (buffer) {
-        for each (var c in reddit_link_commands) {
+        for (var c of reddit_link_commands) {
             buffer.default_browser_object_classes[c] =
                 browser_object_reddit_current;
         }
         buffer.content_modalities.push(reddit_modality);
     },
     function disable (buffer) {
-        for each (var c in reddit_link_commands) {
+        for (var c of reddit_link_commands) {
             delete buffer.default_browser_object_classes[c];
         }
         var i = buffer.content_modalities.indexOf(reddit_modality);
diff --git a/modules/page-modes/wikipedia.js b/modules/page-modes/wikipedia.js
index 0dbe28f..5dd0dc4 100644
--- a/modules/page-modes/wikipedia.js
+++ b/modules/page-modes/wikipedia.js
@@ -80,7 +80,7 @@ function define_wikipedia_webjumps() {
         var prefixes = object_keys(wikipedia_versions);
     else
         prefixes = Array.slice(arguments);
-    for each (let i in prefixes) {
+    for (let i of prefixes) {
         var rest = wikipedia_versions[i];
         var name = string_format(wikipedia_webjumps_format, {s: i});
         define_webjump(name, "http://" + i + ".wikipedia.org/wiki/" + rest.search);
diff --git a/modules/page-modes/youtube.js b/modules/page-modes/youtube.js
index 2aad607..ab8fd85 100644
--- a/modules/page-modes/youtube.js
+++ b/modules/page-modes/youtube.js
@@ -22,7 +22,7 @@ function regexp_exec (regexp, string, group) {
 function youtube_parse_video_info (info) {
     var sp = info.split("&");
     var res = {};
-    for each (var kv in sp) {
+    for (var kv of sp) {
         let [k, v] = kv.split("=");
         res[k] = decodeURIComponent(v);
     }
@@ -33,9 +33,9 @@ function youtube_parse_video_info (info) {
     var url_encoded_fmt_stream_map =
         res.url_encoded_fmt_stream_map.split(",");
     var data = [];
-    for each (var chunk in url_encoded_fmt_stream_map) {
+    for (var chunk of url_encoded_fmt_stream_map) {
         var d = {};
-        for each (kv in chunk.split("&")) {
+        for (kv of chunk.split("&")) {
             let [k, v] = kv.split("=");
             d[k] = decodeURIComponent(v);
         }
@@ -45,7 +45,7 @@ function youtube_parse_video_info (info) {
 }
 
 function youtube_get_video_info (url, id, t) {
-    for each (var el in ["profilepage", "detailpage"]) {
+    for (var el of ["profilepage", "detailpage"]) {
         var video_info_url =
             "http://www.youtube.com/get_video_info?&video_id="+
             encodeURIComponent(id)+"&el="+el+"&ps=default&eurl="+
@@ -65,7 +65,7 @@ function youtube_scrape_text (results, frame, url, id, text) {
     if (! t)
         yield co_return();
     var info = yield youtube_get_video_info(url, id, t);
-    for each (var d in info) {
+    for (var d of info) {
         var extension = mime_service.getPrimaryExtension(
             d.type, regexp_exec(/\/([^;]+)/, d.type, 1));
         results.push(load_spec({
diff --git a/modules/selectively-unstyle.js b/modules/selectively-unstyle.js
index a38219e..be129bc 100644
--- a/modules/selectively-unstyle.js
+++ b/modules/selectively-unstyle.js
@@ -15,10 +15,10 @@ define_variable('selectively_unstyle_alist', [],
 
 function selectively_unstyle (buffer) {
     var uri = buffer.current_uri.spec;
-    for each (let entry in selectively_unstyle_alist) {
+    for (let entry of selectively_unstyle_alist) {
         if (entry[0](uri)) {
             let func = entry[1];
-            for each (var sheet in buffer.document.styleSheets) {
+            for (var sheet of buffer.document.styleSheets) {
                 func(sheet);
             }
         }
diff --git a/modules/spawn-process.js b/modules/spawn-process.js
index 7bf5d7d..41d2303 100644
--- a/modules/spawn-process.js
+++ b/modules/spawn-process.js
@@ -324,7 +324,7 @@ function spawn_process (program_name, args, working_dir,
                     }
                 }
             }
-            for each (let f in registered_transports) {
+            for (let f of registered_transports) {
                 input_stream_async_wait(f.input, handler, false /* wait for closure */);
                 output_stream_async_wait(f.output, handler, false /* wait for closure */);
             }
diff --git a/modules/theme.js b/modules/theme.js
index 99c3456..8662ea3 100644
--- a/modules/theme.js
+++ b/modules/theme.js
@@ -44,7 +44,7 @@
     var theme_find = function theme_find (name) {
         if (loaded_themes[name])
             return loaded_themes[name];
-        for each (var path in theme_load_paths) {
+        for (var path of theme_load_paths) {
             var url;
             if (path instanceof Ci.nsIURI) {
                 url = path.spec;
@@ -72,7 +72,7 @@
     var theme_load = function theme_load (name) {
         var th = theme_find(name);
         if (! th) throw new Error("theme "+name+" not found.");
-        for each (var cssfile in th.sheets) {
+        for (var cssfile of th.sheets) {
             let module = theme_cssfile_module(cssfile);
             if (! themes[module]) {
                 themes[module] = {};
@@ -92,7 +92,7 @@
 
     var theme_unload = function theme_unload (name) {
         var th = theme_find(name);
-        for each (var cssfile in th.sheets) {
+        for (var cssfile of th.sheets) {
             let module = theme_cssfile_module(cssfile);
             themes[module][cssfile] =
                 themes[module][cssfile].filter(function (x) { return x !== th; });
diff --git a/modules/user-agent-policy.jsx b/modules/user-agent-policy.jsx
index e5727be..8e75187 100644
--- a/modules/user-agent-policy.jsx
+++ b/modules/user-agent-policy.jsx
@@ -43,7 +43,7 @@ function http_request_hook_function (channel) {
     try {
         var host = uri.host;
     } catch (e) {}
-    outer: for each (let p in policies) {
+    outer: for (let p of policies) {
         if (host && p.byhost[host]) {
             var user_agent = p.user_agent;
             break;
diff --git a/modules/utils.js b/modules/utils.js
index d666543..c5c4298 100644
--- a/modules/utils.js
+++ b/modules/utils.js
@@ -227,7 +227,7 @@ function create_info_panel (window, panel_class, row_arr) {
     var rows = g.element("rows", grid);
     var row;
 
-    for each (let [row_class, row_label, row_value] in row_arr) {
+    for (let [row_class, row_label, row_value] of row_arr) {
         row = g.element("row", rows, "class", row_class);
         g.element("label", row,
                   "value", row_label,
@@ -267,7 +267,7 @@ function read_from_clipboard (which_clipboard) {
     var trans = Cc["@mozilla.org/widget/transferable;1"]
         .createInstance(Ci.nsITransferable);
 
-    for each (let flavor in flavors) {
+    for (let flavor of flavors) {
         trans.addDataFlavor(flavor);
     }
     clipboard.getData(trans, which_clipboard);
@@ -304,7 +304,7 @@ function read_from_x_primary_selection () {
 
 
 function predicate_alist_match (alist, key) {
-    for each (let i in alist) {
+    for (let i of alist) {
         if (i[0] instanceof RegExp) {
             if (i[0].exec(key))
                 return i[1];
@@ -467,7 +467,7 @@ function send_http_request (lspec) {
     req.open(method, load_spec_uri_string(lspec), true, arguments.$user, arguments.$password);
     req.channel.notificationCallbacks = xml_http_request_load_listener;
 
-    for each (let [name,value] in arguments.$headers) {
+    for (let [name,value] of arguments.$headers) {
         req.setRequestHeader(name, value);
     }
 
-- 
2.12.2

