Change let into const (#457)

This patch:
- changes `let` into `const` throughout codebase
- adds eslint check to prefer const over let
This commit is contained in:
Eric Bidelman
2017-08-21 16:39:04 -07:00
committed by Andrey Lushnikov
parent 5d6d3e0a81
commit 1f9b4fb4c8
37 changed files with 495 additions and 494 deletions

View File

@@ -61,8 +61,8 @@ class FrameManager extends EventEmitter {
if (this._frames.has(frameId))
return;
console.assert(parentFrameId);
let parentFrame = this._frames.get(parentFrameId);
let frame = new Frame(this._client, this._mouse, parentFrame, frameId);
const parentFrame = this._frames.get(parentFrameId);
const frame = new Frame(this._client, this._mouse, parentFrame, frameId);
this._frames.set(frame._id, frame);
this.emit(FrameManager.Events.FrameAttached, frame);
}
@@ -77,7 +77,7 @@ class FrameManager extends EventEmitter {
// Detach all child frames first.
if (frame) {
for (let child of frame.childFrames())
for (const child of frame.childFrames())
this._removeFramesRecursively(child);
}
@@ -105,7 +105,7 @@ class FrameManager extends EventEmitter {
* @param {string} frameId
*/
_onFrameDetached(frameId) {
let frame = this._frames.get(frameId);
const frame = this._frames.get(frameId);
if (frame)
this._removeFramesRecursively(frame);
}
@@ -116,7 +116,7 @@ class FrameManager extends EventEmitter {
if (!frame)
return;
frame._defaultContextId = context.id;
for (let waitTask of frame._waitTasks)
for (const waitTask of frame._waitTasks)
waitTask.rerun();
}
@@ -124,7 +124,7 @@ class FrameManager extends EventEmitter {
* @param {!Frame} frame
*/
_removeFramesRecursively(frame) {
for (let child of frame.childFrames())
for (const child of frame.childFrames())
this._removeFramesRecursively(child);
frame._detach();
this._frames.delete(frame._id);
@@ -179,7 +179,7 @@ class Frame {
* @return {!Promise<(!Object|undefined)>}
*/
async evaluate(pageFunction, ...args) {
let remoteObject = await this._rawEvaluate(pageFunction, ...args);
const remoteObject = await this._rawEvaluate(pageFunction, ...args);
return await helper.serializeRemoteObject(this._client, remoteObject);
}
@@ -188,7 +188,7 @@ class Frame {
* @return {!Promise<?ElementHandle>}
*/
async $(selector) {
let remoteObject = await this._rawEvaluate(selector => document.querySelector(selector), selector);
const remoteObject = await this._rawEvaluate(selector => document.querySelector(selector), selector);
if (remoteObject.subtype === 'node')
return new ElementHandle(this._client, remoteObject, this._mouse);
helper.releaseObject(this._client, remoteObject);
@@ -201,9 +201,9 @@ class Frame {
* @return {!Promise<(!Object|undefined)>}
*/
async _rawEvaluate(pageFunction, ...args) {
let expression = helper.evaluationString(pageFunction, ...args);
const expression = helper.evaluationString(pageFunction, ...args);
const contextId = this._defaultContextId;
let { exceptionDetails, result: remoteObject } = await this._client.send('Runtime.evaluate', { expression, contextId, returnByValue: false, awaitPromise: true});
const { exceptionDetails, result: remoteObject } = await this._client.send('Runtime.evaluate', { expression, contextId, returnByValue: false, awaitPromise: true});
if (exceptionDetails)
throw new Error('Evaluation failed: ' + helper.getExceptionMessage(exceptionDetails));
return remoteObject;
@@ -270,9 +270,9 @@ class Frame {
* @param {string} url
*/
function addScriptTag(url) {
let script = document.createElement('script');
const script = document.createElement('script');
script.src = url;
let promise = new Promise(x => script.onload = x);
const promise = new Promise(x => script.onload = x);
document.head.appendChild(script);
return promise;
}
@@ -349,7 +349,7 @@ class Frame {
}
_detach() {
for (let waitTask of this._waitTasks)
for (const waitTask of this._waitTasks)
waitTask.terminate(new Error('waitForSelector failed: frame got detached.'));
this._detached = true;
if (this._parentFrame)