Modernize ES for-loops and remove problematic for-in loops
This slightly modifies the behaviour of errors (see init.js)
Change-Id: I1aab691d5b7e8167b6213378bdd9139c133202cd
diff --git a/dev/js/src/panel/match.js b/dev/js/src/panel/match.js
index c901cee..a6c50db 100644
--- a/dev/js/src/panel/match.js
+++ b/dev/js/src/panel/match.js
@@ -87,9 +87,7 @@
if (matchButtons) {
// Add all matchbuttons in order
- for (i in matchButtons) {
- a.add.apply(a, matchButtons[i]);
- }
+ matchButtons.forEach(m => a.add.apply(a, m));
};
};
@@ -142,13 +140,8 @@
var spans = match.getSpans();
var rels = match.getRels();
- var i;
- for (i in spans) {
- treeLayers.push(spans[i]);
- };
- for (i in rels) {
- treeLayers.push(rels[i]);
- };
+ spans.forEach(i => treeLayers.push(i));
+ rels.forEach(i => treeLayers.push(i));
// Get spans
treeLayers = treeLayers.sort(
diff --git a/dev/js/src/panel/query.js b/dev/js/src/panel/query.js
index f0f1920..7f66f9f 100644
--- a/dev/js/src/panel/query.js
+++ b/dev/js/src/panel/query.js
@@ -27,9 +27,7 @@
var queryButtons = KorAP.Plugin.buttonGroup("query");
// Add all matchbuttons in order
- for (i in queryButtons) {
- a.add.apply(a, queryButtons[i]);
- };
+ queryButtons.forEach(i => a.add.apply(a, i));
KorAP.Plugin.clearButtonGroup("query")
};
diff --git a/dev/js/src/panel/result.js b/dev/js/src/panel/result.js
index d221081..3c5dc31 100644
--- a/dev/js/src/panel/result.js
+++ b/dev/js/src/panel/result.js
@@ -30,9 +30,7 @@
var resultButtons = KorAP.Plugin.buttonGroup("result");
// Add all result buttons in order
- for (i in resultButtons) {
- this.actions.add.apply(this.actions, resultButtons[i]);
- };
+ resultButtons.forEach(i => this.actions.add.apply(this.actions, i));
KorAP.Plugin.clearButtonGroup("result");
};