mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
fix(JSHandle.toString): clearer description for primitives (#993)
This patch: - updates JSHandle.toString to make a nicer description for primitives - excludes JSHandle.toString from documentation to avoid its abuse References #382
This commit is contained in:
@@ -184,7 +184,7 @@ class JSHandle {
|
||||
const type = this._remoteObject.subtype || this._remoteObject.type;
|
||||
return 'JSHandle@' + type;
|
||||
}
|
||||
return helper.valueFromRemoteObject(this._remoteObject) + '';
|
||||
return 'JSHandle:' + helper.valueFromRemoteObject(this._remoteObject);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
11
lib/Page.js
11
lib/Page.js
@@ -330,8 +330,15 @@ class Page extends EventEmitter {
|
||||
return;
|
||||
}
|
||||
const values = event.args.map(arg => this._frameManager.createJSHandle(event.executionContextId, arg));
|
||||
const text = values.join(' ');
|
||||
const message = new ConsoleMessage(event.type, text, values);
|
||||
const textTokens = [];
|
||||
for (let i = 0; i < event.args.length; ++i) {
|
||||
const remoteObject = event.args[i];
|
||||
if (remoteObject.objectId)
|
||||
textTokens.push(values[i].toString());
|
||||
else
|
||||
textTokens.push(helper.valueFromRemoteObject(remoteObject));
|
||||
}
|
||||
const message = new ConsoleMessage(event.type, textTokens.join(' '), values);
|
||||
this.emit(Page.Events.Console, message);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user