mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
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:
committed by
Andrey Lushnikov
parent
5d6d3e0a81
commit
1f9b4fb4c8
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user