Skip to content

Commit

Permalink
Bug 1355056 - replace (function(args) { /* do stuff using this */ }).…
Browse files Browse the repository at this point in the history
…bind(this) with arrow functions, r=jaws.
  • Loading branch information
fqueze committed Apr 26, 2017
1 parent 4d7b007 commit 4b1556a
Show file tree
Hide file tree
Showing 137 changed files with 767 additions and 790 deletions.
4 changes: 2 additions & 2 deletions accessible/tests/mochitest/events/test_mutation.html
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@
{
this.txt = null;
this.eventSeq = [
new invokerChecker(EVENT_HIDE, function() { return this.txt; }.bind(this))
new invokerChecker(EVENT_HIDE, () => { return this.txt; })
];

this.invoke = function hideNDestroyDoc_invoke()
Expand All @@ -405,7 +405,7 @@
{
this.target = null;
this.eventSeq = [
new invokerChecker(EVENT_HIDE, function() { return this.target; }.bind(this))
new invokerChecker(EVENT_HIDE, () => { return this.target; })
];

this.invoke = function hideHideNDestroyDoc_invoke()
Expand Down
4 changes: 2 additions & 2 deletions addon-sdk/source/lib/sdk/simple-storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,12 @@ JsonStore.prototype = {
// Finally, write.
let stream = file.open(this.filename, "w");
try {
stream.writeAsync(JSON.stringify(this.root), function writeAsync(err) {
stream.writeAsync(JSON.stringify(this.root), err => {
if (err)
console.error("Error writing simple storage file: " + this.filename);
else if (this.onWrite)
this.onWrite(this);
}.bind(this));
});
}
catch (err) {
// writeAsync closes the stream after it's done, so only close on error.
Expand Down
16 changes: 8 additions & 8 deletions browser/base/content/browser-fullZoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,10 @@ var FullZoom = {
let token = this._getBrowserToken(browser);
this._cps2.getByDomainAndName(browser.currentURI.spec, this.name, ctxt, {
handleResult() { hasPref = true; },
handleCompletion: function() {
handleCompletion: () => {
if (!hasPref && token.isCurrent)
this._applyPrefToZoom(undefined, browser);
}.bind(this)
}
});
},

Expand Down Expand Up @@ -224,14 +224,14 @@ var FullZoom = {
let token = this._getBrowserToken(browser);
this._cps2.getByDomainAndName(aURI.spec, this.name, ctxt, {
handleResult(resultPref) { value = resultPref.value; },
handleCompletion: function() {
handleCompletion: () => {
if (!token.isCurrent) {
this._notifyOnLocationChange(browser);
return;
}
this._applyPrefToZoom(value, browser,
this._notifyOnLocationChange.bind(this, browser));
}.bind(this)
}
});
},

Expand Down Expand Up @@ -364,9 +364,9 @@ var FullZoom = {
this._cps2.set(browser.currentURI.spec, this.name,
ZoomManager.getZoomForBrowser(browser),
this._loadContextFromBrowser(browser), {
handleCompletion: function() {
handleCompletion: () => {
this._isNextContentPrefChangeInternal = true;
}.bind(this),
},
});
},

Expand All @@ -381,9 +381,9 @@ var FullZoom = {
return;
let ctxt = this._loadContextFromBrowser(browser);
this._cps2.removeByDomainAndName(browser.currentURI.spec, this.name, ctxt, {
handleCompletion: function() {
handleCompletion: () => {
this._isNextContentPrefChangeInternal = true;
}.bind(this),
},
});
},

Expand Down
4 changes: 2 additions & 2 deletions browser/base/content/browser-places.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ var StarUI = {
this._overlayLoading = true;
document.loadOverlay(
"chrome://browser/content/places/editBookmarkOverlay.xul",
(function(aSubject, aTopic, aData) {
(aSubject, aTopic, aData) => {
// Move the header (star, title, button) into the grid,
// so that it aligns nicely with the other items (bug 484022).
let header = this._element("editBookmarkPanelHeader");
Expand All @@ -250,7 +250,7 @@ var StarUI = {
this._overlayLoading = false;
this._overlayLoaded = true;
this._doShowEditBookmarkPanel(aNode, aAnchorElement, aPosition);
}).bind(this)
}
);
}),

Expand Down
4 changes: 2 additions & 2 deletions browser/base/content/browser-thumbnails.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,10 @@ var gBrowserThumbnails = {
else
aBrowser.addEventListener("scroll", this, true);

let timeout = setTimeout(function() {
let timeout = setTimeout(() => {
this._clearTimeout(aBrowser);
this._capture(aBrowser);
}.bind(this), this._captureDelayMS);
}, this._captureDelayMS);

this._timeouts.set(aBrowser, timeout);
},
Expand Down
4 changes: 2 additions & 2 deletions browser/base/content/newtab/undo.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@ var gUndoDialog = {
* Undo all blocked sites.
*/
_undoAll: function UndoDialog_undoAll() {
NewTabUtils.undoAll(function() {
NewTabUtils.undoAll(() => {
gUpdater.updateGrid();
this.hide();
}.bind(this));
});
}
};

Expand Down
4 changes: 2 additions & 2 deletions browser/base/content/sync/aboutSyncTabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ var RemoteTabViewer = {
},

_generateCloudSyncTabList() {
let updateTabList = function(remoteTabs) {
let updateTabList = remoteTabs => {
let list = this._tabsList;

for (let client of remoteTabs) {
Expand All @@ -270,7 +270,7 @@ var RemoteTabViewer = {
list.appendChild(tabEnt);
}
}
}.bind(this);
};

return CloudSync().tabs.getRemoteTabs()
.then(updateTabList, Promise.reject.bind(Promise));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,10 +327,10 @@ WindowListener.prototype = {

// wait for trasition to fullscreen on OSX Lion later
if (isOSX) {
setTimeout(function() {
setTimeout(() => {
domwindow.close();
executeSoon(this.callBack_onFinalize);
}.bind(this), 3000);
}, 3000);
} else {
domwindow.close();
executeSoon(this.callBack_onFinalize);
Expand Down
4 changes: 2 additions & 2 deletions browser/components/customizableui/CustomizableUI.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -4386,7 +4386,7 @@ OverflowableToolbar.prototype = {

_hideTimeoutId: null,
_showWithTimeout() {
this.show().then(function() {
this.show().then(() => {
let window = this._toolbar.ownerGlobal;
if (this._hideTimeoutId) {
window.clearTimeout(this._hideTimeoutId);
Expand All @@ -4396,7 +4396,7 @@ OverflowableToolbar.prototype = {
this._panel.hidePopup();
}
}, OVERFLOW_PANEL_HIDE_DELAY_MS);
}.bind(this));
});
},
};

Expand Down
56 changes: 28 additions & 28 deletions browser/components/customizableui/CustomizableWidgets.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -699,53 +699,53 @@ const CustomizableWidgets = [
updateCombinedWidgetStyle(node, this.currentArea, true);

let listener = {
onWidgetAdded: function(aWidgetId, aArea, aPosition) {
onWidgetAdded: (aWidgetId, aArea, aPosition) => {
if (aWidgetId != this.id)
return;

updateCombinedWidgetStyle(node, aArea, true);
}.bind(this),
},

onWidgetRemoved: function(aWidgetId, aPrevArea) {
onWidgetRemoved: (aWidgetId, aPrevArea) => {
if (aWidgetId != this.id)
return;

// When a widget is demoted to the palette ('removed'), it's visual
// style should change.
updateCombinedWidgetStyle(node, null, true);
}.bind(this),
},

onWidgetReset: function(aWidgetNode) {
onWidgetReset: aWidgetNode => {
if (aWidgetNode != node)
return;
updateCombinedWidgetStyle(node, this.currentArea, true);
}.bind(this),
},

onWidgetUndoMove: function(aWidgetNode) {
onWidgetUndoMove: aWidgetNode => {
if (aWidgetNode != node)
return;
updateCombinedWidgetStyle(node, this.currentArea, true);
}.bind(this),
},

onWidgetMoved: function(aWidgetId, aArea) {
onWidgetMoved: (aWidgetId, aArea) => {
if (aWidgetId != this.id)
return;
updateCombinedWidgetStyle(node, aArea, true);
}.bind(this),
},

onWidgetInstanceRemoved: function(aWidgetId, aDoc) {
onWidgetInstanceRemoved: (aWidgetId, aDoc) => {
if (aWidgetId != this.id || aDoc != aDocument)
return;

CustomizableUI.removeListener(listener);
}.bind(this),
},

onWidgetDrag: function(aWidgetId, aArea) {
onWidgetDrag: (aWidgetId, aArea) => {
if (aWidgetId != this.id)
return;
aArea = aArea || this.currentArea;
updateCombinedWidgetStyle(node, aArea, true);
}.bind(this)
}
};
CustomizableUI.addListener(listener);

Expand Down Expand Up @@ -798,50 +798,50 @@ const CustomizableWidgets = [
updateCombinedWidgetStyle(node, this.currentArea);

let listener = {
onWidgetAdded: function(aWidgetId, aArea, aPosition) {
onWidgetAdded: (aWidgetId, aArea, aPosition) => {
if (aWidgetId != this.id)
return;
updateCombinedWidgetStyle(node, aArea);
}.bind(this),
},

onWidgetRemoved: function(aWidgetId, aPrevArea) {
onWidgetRemoved: (aWidgetId, aPrevArea) => {
if (aWidgetId != this.id)
return;
// When a widget is demoted to the palette ('removed'), it's visual
// style should change.
updateCombinedWidgetStyle(node);
}.bind(this),
},

onWidgetReset: function(aWidgetNode) {
onWidgetReset: aWidgetNode => {
if (aWidgetNode != node)
return;
updateCombinedWidgetStyle(node, this.currentArea);
}.bind(this),
},

onWidgetUndoMove: function(aWidgetNode) {
onWidgetUndoMove: aWidgetNode => {
if (aWidgetNode != node)
return;
updateCombinedWidgetStyle(node, this.currentArea);
}.bind(this),
},

onWidgetMoved: function(aWidgetId, aArea) {
onWidgetMoved: (aWidgetId, aArea) => {
if (aWidgetId != this.id)
return;
updateCombinedWidgetStyle(node, aArea);
}.bind(this),
},

onWidgetInstanceRemoved: function(aWidgetId, aDoc) {
onWidgetInstanceRemoved: (aWidgetId, aDoc) => {
if (aWidgetId != this.id || aDoc != aDocument)
return;
CustomizableUI.removeListener(listener);
}.bind(this),
},

onWidgetDrag: function(aWidgetId, aArea) {
onWidgetDrag: (aWidgetId, aArea) => {
if (aWidgetId != this.id)
return;
aArea = aArea || this.currentArea;
updateCombinedWidgetStyle(node, aArea);
}.bind(this)
}
};
CustomizableUI.addListener(listener);

Expand Down
16 changes: 8 additions & 8 deletions browser/components/customizableui/CustomizeMode.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -385,14 +385,14 @@ CustomizeMode.prototype = {
if (!this._wantToBeInCustomizeMode) {
this.exit();
}
}.bind(this)).then(null, function(e) {
}.bind(this)).then(null, e => {
log.error("Error entering customize mode", e);
// We should ensure this has been called, and calling it again doesn't hurt:
window.PanelUI.endBatchUpdate();
this._handler.isEnteringCustomizeMode = false;
// Exit customize mode to ensure proper clean-up when entering failed.
this.exit();
}.bind(this));
});
},

exit() {
Expand Down Expand Up @@ -542,12 +542,12 @@ CustomizeMode.prototype = {
if (this._wantToBeInCustomizeMode) {
this.enter();
}
}.bind(this)).then(null, function(e) {
}.bind(this)).then(null, e => {
log.error("Error exiting customize mode", e);
// We should ensure this has been called, and calling it again doesn't hurt:
window.PanelUI.endBatchUpdate();
this._handler.isExitingCustomizeMode = false;
}.bind(this));
});
},

/**
Expand Down Expand Up @@ -1320,7 +1320,7 @@ CustomizeMode.prototype = {
panel.hidePopup();
};

AddonManager.getAddonByID(DEFAULT_THEME_ID, function(aDefaultTheme) {
AddonManager.getAddonByID(DEFAULT_THEME_ID, aDefaultTheme => {
let doc = this.window.document;

function buildToolbarButton(aTheme) {
Expand Down Expand Up @@ -1403,7 +1403,7 @@ CustomizeMode.prototype = {
}
let hideRecommendedLabel = (footer.previousSibling == recommendedLabel);
recommendedLabel.hidden = hideRecommendedLabel;
}.bind(this));
});
},

_clearLWThemesMenu(panel) {
Expand Down Expand Up @@ -1563,7 +1563,7 @@ CustomizeMode.prototype = {

// Hack needed so that the dragimage will still show the
// item as it appeared before it was hidden.
this._initializeDragAfterMove = function() {
this._initializeDragAfterMove = () => {
// For automated tests, we sometimes start exiting customization mode
// before this fires, which leaves us with placeholders inserted after
// we've exited. So we need to check that we are indeed customizing.
Expand All @@ -1581,7 +1581,7 @@ CustomizeMode.prototype = {
}
this._initializeDragAfterMove = null;
this.window.clearTimeout(this._dragInitializeTimeout);
}.bind(this);
};
this._dragInitializeTimeout = this.window.setTimeout(this._initializeDragAfterMove, 0);
},

Expand Down
4 changes: 2 additions & 2 deletions browser/components/feeds/FeedWriter.js
Original file line number Diff line number Diff line change
Expand Up @@ -965,13 +965,13 @@ FeedWriter.prototype = {
// Show the file picker before subscribing if the
// choose application menuitem was chosen using the keyboard
if (selectedItem.id == "chooseApplicationMenuItem") {
this._chooseClientApp(function(aResult) {
this._chooseClientApp(aResult => {
if (aResult) {
selectedItem =
this._handlersList.selectedOptions[0];
subscribeCallback();
}
}.bind(this));
});
} else {
subscribeCallback();
}
Expand Down
Loading

0 comments on commit 4b1556a

Please sign in to comment.