Fix deep-recursion problem with whitespace trimming in menu prefixes
Change-Id: I30428302ca9847d9728035d1a75909ebd05fb93d
diff --git a/dev/js/src/menu.js b/dev/js/src/menu.js
index c3f7fa6..859e109 100644
--- a/dev/js/src/menu.js
+++ b/dev/js/src/menu.js
@@ -4,7 +4,6 @@
* @author Nils Diewald
*/
/*
- * TODO: space is not a valid prefix!
* TODO: Show the slider briefly on move (whenever screen is called).
* TODO: Ignore alt+ and strg+ key strokes.
* TODO: Should scroll to a chosen value after prefixing, if the chosen value is live
diff --git a/dev/js/src/menu/item.js b/dev/js/src/menu/item.js
index 835f69f..812a398 100644
--- a/dev/js/src/menu/item.js
+++ b/dev/js/src/menu/item.js
@@ -179,7 +179,12 @@
// Split prefixes
if (prefixString) {
- var prefixes = prefixString.trim().split(" ");
+
+ // ND:
+ // Doing this in a single line can trigger
+ // a deep-recursion in Firefox 57.01, though I don't know why.
+ prefixString = prefixString.trim();
+ var prefixes = prefixString.split(" ");
var prefix;
var testPos;
@@ -237,43 +242,6 @@
p.removeChild(elem);
};
};
-
- /*
- pos = textlc.indexOf(prefix);
-
- // Matches!
- if (pos >= 0) {
-
- // First element
- if (pos > 0) {
- elem.parentNode.insertBefore(
- document.createTextNode(text.substr(0, pos)),
- elem
- );
- };
-
- // Second element
- var hl = document.createElement("mark");
- hl.appendChild(
- document.createTextNode(text.substr(pos, prefix.length))
- );
- elem.parentNode.insertBefore(hl, elem);
-
- // Third element
- var third = text.substr(pos + prefix.length);
- if (third.length > 0) {
- var thirdE = document.createTextNode(third);
- elem.parentNode.insertBefore(
- thirdE,
- elem
- );
- this._highlight(thirdE, prefix);
- };
-
- var p = elem.parentNode;
- p.removeChild(elem);
- };
- */
}
else {
var children = elem.childNodes;