Bug 524661 - Fix places in browser.js that use for each...in to loop over arrays. r=gavin a=beltzner
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -683,18 +683,18 @@ let gGestureSupport = {
const gestureEvents = ["SwipeGesture",
"MagnifyGestureStart", "MagnifyGestureUpdate", "MagnifyGesture",
"RotateGestureStart", "RotateGestureUpdate", "RotateGesture",
"TapGesture", "PressTapGesture"];
let addRemove = aAddListener ? window.addEventListener :
window.removeEventListener;
- for each (let event in gestureEvents)
- addRemove("Moz" + event, this, true);
+ gestureEvents.forEach(function (event) addRemove("Moz" + event, this, true),
+ this);
},
/**
* Dispatch events based on the type of mouse gesture event. For now, make
* sure to stop propagation of every gesture event so that web content cannot
* receive gesture events.
*
* @param aEvent
@@ -874,19 +874,20 @@ let gGestureSupport = {
/**
* Convert the swipe gesture into a browser action based on the direction
*
* @param aEvent
* The swipe event to handle
*/
onSwipe: function GS_onSwipe(aEvent) {
// Figure out which one (and only one) direction was triggered
- for each (let dir in ["UP", "RIGHT", "DOWN", "LEFT"])
+ ["UP", "RIGHT", "DOWN", "LEFT"].forEach(function (dir) {
if (aEvent.direction == aEvent["DIRECTION_" + dir])
return this._doAction(aEvent, ["swipe", dir.toLowerCase()]);
+ }, this);
},
/**
* Get a gesture preference or use a default if it doesn't exist
*
* @param aPref
* Name of the preference to load under the gesture branch
* @param aDef
@@ -2675,31 +2676,31 @@ function FillInHTMLTooltip(tipElement)
.getPropertyValue("direction");
}
tipElement = tipElement.parentNode;
}
var tipNode = document.getElementById("aHTMLTooltip");
tipNode.style.direction = direction;
- for each (var t in [titleText, XLinkTitleText]) {
+ [titleText, XLinkTitleText].forEach(function (t) {
if (t && /\S/.test(t)) {
// Per HTML 4.01 6.2 (CDATA section), literal CRs and tabs should be
// replaced with spaces, and LFs should be removed entirely.
// XXX Bug 322270: We don't preserve the result of entities like ,
// which should result in a line break in the tooltip, because we can't
// distinguish that from a literal character in the source by this point.
t = t.replace(/[\r\t]/g, ' ');
t = t.replace(/\n/g, '');
tipNode.setAttribute("label", t);
retVal = true;
}
- }
+ });
return retVal;
}
var browserDragAndDrop = {
getDragURLFromDataTransfer : function (dt)
{
var types = dt.types;