Skip to content

Commit

Permalink
Stop using deperecated Iterator object
Browse files Browse the repository at this point in the history
  • Loading branch information
gifnksm committed Mar 22, 2016
1 parent 543f58b commit e0e19c5
Show file tree
Hide file tree
Showing 28 changed files with 102 additions and 100 deletions.
4 changes: 2 additions & 2 deletions components/keysnail-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ KeySnailLoader.prototype = {

let context = win.KeySnail.modules;

for (let [, module] in Iterator(modules))
for (let module of modules)
loadModule(module, context);
},

Expand All @@ -122,7 +122,7 @@ KeySnailLoader.prototype = {
"password1Container",
"password2Container"];

for (let [, id] in Iterator(ids))
for (let id of ids)
{
let elem = aDocument.getElementById(id);
if (elem && !elem.hidden)
Expand Down
2 changes: 1 addition & 1 deletion content/keysnail.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
_ = modules._;
} catch (x) {}

for (let [, name] in Iterator(moduleObjects))
for (let name of moduleObjects)
this.initModule(name);

// set modules
Expand Down
2 changes: 1 addition & 1 deletion content/modules/ext.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var ext = function () {
}
keyList = keyList.sort();

for (let [, name] in Iterator(keyList))
for (let name of keyList)
extList.push([name, exts[name].description || ""]);

return extList;
Expand Down
2 changes: 1 addition & 1 deletion content/modules/hook.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ var hook = {
if (!hook)
return;

for (let [i, action] in Iterator(hook)) {
for (let [i, action] of util.keyValues(hook)) {
try {
action(arg);
} catch (x) {
Expand Down
10 changes: 5 additions & 5 deletions content/modules/key.js
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,8 @@ var key = {

this.passAllKeys = true;

for (let [, keyStr] in Iterator(aKeys)) {
for (let [, type] in Iterator(aType)) {
for (let keyStr of aKeys) {
for (let type of aType) {
util.message("feed " + keyStr);
let event = this.stringToKeyEvent(keyStr, true, type, true);
// event.ksNoHandle becomes undefined while propagating
Expand Down Expand Up @@ -1049,7 +1049,7 @@ var key = {
var aTarget = this.keyMapHolder[aTargetKeyMapName];
var aDestination = this.keyMapHolder[aDestinationKeyMapName];

for (let [property, value] in Iterator(aTarget))
for (let [property, value] of util.keyValues(aTarget))
aDestination[property] = value;
},

Expand Down Expand Up @@ -1104,7 +1104,7 @@ var key = {
if (!(aKeyMapName instanceof Array))
aKeyMapName = [aKeyMapName];

for (let [, keyMapName] in Iterator(aKeyMapName))
for (let keyMapName of aKeyMapName)
{
var addTo = this.keyMapHolder[keyMapName];

Expand Down Expand Up @@ -1348,7 +1348,7 @@ var key = {
if (!aKeySequence)
aKeySequence = [];

for (let [keyStr, cont] in Iterator(aKeyMap))
for (let [keyStr, cont] of util.keyValues(aKeyMap))
{
switch (typeof cont)
{
Expand Down
2 changes: 1 addition & 1 deletion content/modules/macro.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ var macro = {
var len = aEvents.length;
var sleepTime = this.sleepTime;

for (let [, event] in Iterator(aEvents))
for (let event of aEvents)
{
if (event.keyCode === KeyEvent.DOM_VK_TAB)
{
Expand Down
4 changes: 2 additions & 2 deletions content/modules/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var plugins = {
setupOptions: function (prefix, defaults, pluginInfo) {
let options = {};

for (let [name, { preset, description, type, hidden }] in Iterator(defaults)) {
for (let [name, { preset, description, type, hidden }] of util.keyValues(defaults)) {
let fullName = prefix + "." + name;

// XXX: bind values
Expand Down Expand Up @@ -107,7 +107,7 @@ var plugins = {
getInstalledPlugins: function () {
let pluginList = {};

for (let [pluginPath, pluginContext] in Iterator(plugins.context)) {
for (let [pluginPath, pluginContext] of util.keyValues(plugins.context)) {
let isDisabled = userscript.isDisabledPlugin(pluginPath);
let isNotCompatible = pluginContext.__ksNotCompatible__;

Expand Down
40 changes: 20 additions & 20 deletions content/modules/prompt.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,19 +164,19 @@ var prompt = function () {
function $E(aName, aAttributes) {
let elem = document.createElement(aName);

for (let [k, v] in Iterator(aAttributes))
for (let [k, v] of util.keyValues(aAttributes))
elem.setAttribute(k, v);

return elem;
}

function implant(a, b) {
for (let [k, v] in Iterator(b))
for (let [k, v] of util.keyValues(b))
a[k] = v;
}

function implantAll(a, b) {
for (let k in util.getAllPropertyNames(b)) {
for (let k of util.getAllPropertyNames(b)) {
try {
a[k] = b[k];
} catch (_) {}
Expand All @@ -193,10 +193,10 @@ var prompt = function () {
var newObject = {};
var key;

for (let [key, value] in Iterator(a))
for (let [key, value] of util.keyValues(a))
newObject[key] = value;

for (let [key, value] in Iterator(b))
for (let [key, value] of util.keyValues(b))
newObject[key] = value;

return newObject;
Expand All @@ -210,7 +210,7 @@ var prompt = function () {

function getActualCols(aCols) {
if (gFlags)
for (let [, flag] in Iterator(gFlags))
for (let flag of gFlags)
if (flag & (HIDDEN | ICON)) aCols--;
return aCols;
}
Expand Down Expand Up @@ -259,7 +259,7 @@ var prompt = function () {
function setColumns(aColumn) {
if (gFlags)
{
for (let [, flag] in Iterator(gFlags))
for (let flag of gFlags)
{
if (flag & (HIDDEN | ICON))
aColumn--;
Expand Down Expand Up @@ -726,7 +726,7 @@ var prompt = function () {
var found = {};
var uniqStr = "";

for (let [, c] in Iterator(str))
for (let c of str)
{
if (found[c])
continue;
Expand All @@ -749,7 +749,7 @@ var prompt = function () {

var continuousMode = false;

for (let [, opt] in Iterator(uniq(opts)))
for (let opt of uniq(opts))
{
switch (opt)
{
Expand Down Expand Up @@ -1016,7 +1016,7 @@ var prompt = function () {
if (typeof aActions === "function")
aActions = [[aActions, "Default callback"]];

for (let [i, action] in Iterator(aActions))
for (let [i, action] of util.keyValues(aActions))
{
var item = document.createElement("menuitem");
item.setAttribute("label", action[1]);
Expand Down Expand Up @@ -1047,7 +1047,7 @@ var prompt = function () {
);

function stick(keymap) {
for (let [k, a] in Iterator(keymap))
for (let [k, a] of util.keyValues(keymap))
{
let act = a.split(",")[0];
let desc = actionDescriptionMap[act] || "";
Expand Down Expand Up @@ -1091,7 +1091,7 @@ var prompt = function () {
var list = [];

// create action list and local command
for (let [i, action] in Iterator(aActions))
for (let [i, action] of util.keyValues(aActions))
{
let index = i + 1;
list.push([action[0], index.toString() + ". " + action[1]]);
Expand Down Expand Up @@ -1456,7 +1456,7 @@ var prompt = function () {
let buffer = [];
let escapeIt = false;

for (let [, c] in Iterator(str))
for (let c of str)
{
if (!escapeIt && c === escapeChar)
escapeIt = true;
Expand Down Expand Up @@ -1734,7 +1734,7 @@ var prompt = function () {
collection : null
};

for (let [, cmpltr] in Iterator(completers))
for (let cmpltr of completers)
{
let tmpCc = cmpltr(currentText, text) || {collection : null};
let collection = tmpCc.collection;
Expand All @@ -1749,7 +1749,7 @@ var prompt = function () {

let max = -1;

for (let [, c] in Iterator(collections))
for (let c of collections)
{
let first = c[0];

Expand Down Expand Up @@ -1964,12 +1964,12 @@ var prompt = function () {
"watch" : undefined
};

for (let k in Iterator(objectPrototype, true))
for (let k of Object.keys(objectPrototype))
objectPrototype[k] = Object[k];

let functionPrototype = {__proto__ : objectPrototype};

for (let [, k] in Iterator(["apply", "call", "toSource", "toString", "valueOf"]))
for (let k of ["apply", "call", "toSource", "toString", "valueOf"])
functionPrototype[k] = Function[k];

let globalObjects = {
Expand All @@ -1994,11 +1994,11 @@ var prompt = function () {
URIError : []
};

for (let [objName, keys] in Iterator(globalObjects))
for (let [objName, keys] of util.keyValues(globalObjects))
{
globalObjects[objName] = {};

for ([, k] in Iterator(keys))
for (k of keys)
{
globalObjects[objName][k] = global[objName][k];
}
Expand Down Expand Up @@ -2826,7 +2826,7 @@ var prompt = function () {
hook.removeHook('KeySnailInitialized', onInitialized);
let displayHelpKey = [];

for (let [k, act] in Iterator(actionKeys.selector))
for (let [k, act] of util.keyValues(actionKeys.selector))
{
if (act === "prompt-display-keymap-help")
displayHelpKey.push(k);
Expand Down
4 changes: 2 additions & 2 deletions content/modules/shell.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ var shell =
* @param {} b
*/
function implant(a, b) {
for (let [k, v] in Iterator(a))
for (let [k, v] of util.keyValues(a))
b[k] = v;

return b;
Expand Down Expand Up @@ -480,7 +480,7 @@ var shell =
// if user input
// "h" <TAB>
// returned item is will be "hoge".
for ([name, cmd] in Iterator(commands))
for (let [name, cmd] of util.keyValues(commands))
{
if (name.indexOf(left) === 0)
{
Expand Down
12 changes: 6 additions & 6 deletions content/modules/userscript.js
Original file line number Diff line number Diff line change
Expand Up @@ -777,15 +777,15 @@ var userscript = {
main: "chrome://browser/content/browser.xul"
};

for (let [, entry] in Iterator(includeURIs))
for (let entry of includeURIs)
{
uri = replacePair[entry] || entry;

if (uri != documentURI)
return false;
}

for (let [, entry] in Iterator(excludeURIs))
for (let entry of excludeURIs)
{
uri = replacePair[entry] || entry;

Expand Down Expand Up @@ -1320,7 +1320,7 @@ var userscript = {

var maxLen = Math.max.apply(null, [for (str of keys) str.length]);

for (let [, key] in Iterator(keys))
for (let key of keys)
{
var setting = settings[key] || "undefined";
var padding = Math.max(maxLen - key.length, 0) + 2;
Expand All @@ -1335,7 +1335,7 @@ var userscript = {
return;
}

for (let [, setting] in Iterator(aScheme.hooks))
for (let setting of aScheme.hooks)
{
let [name, body] = setting;
if (!name || !body)
Expand Down Expand Up @@ -1376,7 +1376,7 @@ var userscript = {
function getFunction(aCommand) {
if (typeof aCommand === "string")
{
for (let [, commands] in Iterator(builtin))
for (let commands of util.values(builtin))
{
if (commands[aCommand])
return commands[aCommand][0].toString();
Expand Down Expand Up @@ -1420,7 +1420,7 @@ var userscript = {

var settings = aScheme.keybindings[mode];

for (let [, setting] in Iterator(settings))
for (let setting of settings)
{
if (!setting)
continue;
Expand Down
Loading

0 comments on commit e0e19c5

Please sign in to comment.