Bug 1136359 - Backout Array.includes and String.includes usage in tab completion code. r=clokep, a=rkent
authoraleth <aleth@instantbird.org>
Wed, 25 Feb 2015 22:00:13 +0100
changeset 25757 4880a53c711bf4a0707ddbe109844f7bfd933783
parent 25756 48557e9e56e0c9217994d692caef1068073f6ef5
child 25758 a62603c7746927f8525fa7f069d19e8f8ef21813
push id1850
push userclokep@gmail.com
push dateWed, 08 Mar 2017 19:29:12 +0000
treeherdercomm-esr52@028df196b2d9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersclokep, rkent
bugs1136359
Bug 1136359 - Backout Array.includes and String.includes usage in tab completion code. r=clokep, a=rkent
im/content/conversation.xml
mail/components/im/content/imconversation.xml
--- a/im/content/conversation.xml
+++ b/im/content/conversation.xml
@@ -561,17 +561,17 @@
               //   "nick1: " -> "nick1"
               let pos = inputBox.selectionStart;
               const suffix = ": ";
               if (pos > suffix.length &&
                   text.substring(pos - suffix.length, pos) == suffix) {
                 let completions = [b for (b of this.buddies.keys())];
                 // Check if the preceding words are a sequence of nick completions.
                 let preceding = text.substring(0, pos - suffix.length).split(", ");
-                if (preceding.every(n => completions.includes(n))) {
+                if (preceding.every(function(n) completions.indexOf(n) != -1)) {
                   let s = preceding.pop();
                   if (preceding.length)
                     s = suffix + s;
                   inputBox.selectionStart -= s.length + suffix.length;
                   this.addString(s);
                   if (this._completions[0].slice(-suffix.length) == suffix) {
                     this._completions =
                       this._completions.map(function(c) c.slice(0, -suffix.length));
@@ -670,21 +670,22 @@
               completions = completions.filter(function(c) c != outgoingNick);
 
               // Check if the preceding words are a sequence of nick completions.
               let wordStart = inputBox.selectionStart - word.length;
               if (wordStart > 2) {
                 let separator = text.substring(wordStart - 2, wordStart);
                 if (separator == ": " || separator == ", ") {
                   let preceding = text.substring(0, wordStart - 2).split(", ");
-                  if (preceding.every(n => completions.includes(n))) {
+                  if (preceding.every(function(n) completions.indexOf(n) != -1)) {
                     secondNick = true;
                     isFirstWord = true;
                     // Remove preceding completions from possible completions.
-                    completions = completions.filter(c => !preceding.includes(c));
+                    completions = completions.filter(function(c)
+                      preceding.indexOf(c) == -1);
                   }
                 }
               }
             }
 
             // Keep only the completions that share |word| as a prefix.
             // Be case insensitive only if |word| is entirely lower case.
             let condition;
@@ -747,17 +748,17 @@
                   this._completions.splice(this._completions.indexOf(c), 1);
                   this._completions.unshift(c);
                 }, this);
               }
 
               // If one of the completions is the sender of the last ping,
               // take it, if it was less than an hour ago.
               if (this._lastPing && this.buddies.has(this._lastPing) &&
-                  this._completions.includes(this._lastPing) &&
+                  this._completions.indexOf(this._lastPing) != -1 &&
                   (Date.now() / 1000 - this._lastPingTime) < 3600) {
                 preferredNick = true;
                 this._completionsIndex = this._completions.indexOf(this._lastPing);
               }
             }
 
             // Display the possible completions in a system message.
             delete this._shouldListCompletionsLater;
--- a/mail/components/im/content/imconversation.xml
+++ b/mail/components/im/content/imconversation.xml
@@ -481,17 +481,17 @@
             //   "nick1: " -> "nick1"
             let pos = inputBox.selectionStart;
             const suffix = ": ";
             if (pos > suffix.length &&
                 text.substring(pos - suffix.length, pos) == suffix) {
               let completions = [b for (b of this.buddies.keys())];
               // Check if the preceding words are a sequence of nick completions.
               let preceding = text.substring(0, pos - suffix.length).split(", ");
-              if (preceding.every(n => completions.includes(n))) {
+              if (preceding.every(function(n) completions.indexOf(n) != -1)) {
                 let s = preceding.pop();
                 if (preceding.length)
                   s = suffix + s;
                 inputBox.selectionStart -= s.length + suffix.length;
                 this.addString(s);
                 if (this._completions[0].slice(-suffix.length) == suffix) {
                   this._completions =
                     this._completions.map(function(c) c.slice(0, -suffix.length));
@@ -592,21 +592,22 @@
             completions = completions.filter(function(c) c != outgoingNick);
 
             // Check if the preceding words are a sequence of nick completions.
             let wordStart = inputBox.selectionStart - word.length;
             if (wordStart > 2) {
               let separator = text.substring(wordStart - 2, wordStart);
               if (separator == ": " || separator == ", ") {
                 let preceding = text.substring(0, wordStart - 2).split(", ");
-                if (preceding.every(n => completions.includes(n))) {
+                if (preceding.every(function(n) completions.indexOf(n) != -1)) {
                   secondNick = true;
                   isFirstWord = true;
                   // Remove preceding completions from possible completions.
-                  completions = completions.filter(c => !preceding.includes(c));
+                  completions = completions.filter(function(c)
+                    preceding.indexOf(c) == -1);
                 }
               }
             }
           }
 
           // Keep only the completions that share |word| as a prefix.
           // Be case insensitive only if |word| is entirely lower case.
           let condition;
@@ -669,17 +670,17 @@
                 this._completions.splice(this._completions.indexOf(c), 1);
                 this._completions.unshift(c);
               }, this);
             }
 
             // If one of the completions is the sender of the last ping,
             // take it, if it was less than an hour ago.
             if (this._lastPing && this.buddies.has(this._lastPing) &&
-                this._completions.includes(this._lastPing) &&
+                this._completions.indexOf(this._lastPing) != -1 &&
                 (Date.now() / 1000 - this._lastPingTime) < 3600) {
               preferredNick = true;
               this._completionsIndex = this._completions.indexOf(this._lastPing);
             }
           }
 
           // Display the possible completions in a system message.
           delete this._shouldListCompletionsLater;