Use rest parameters
This commit is contained in:
parent
e05804848f
commit
8889c29866
14 changed files with 88 additions and 143 deletions
|
@ -9,7 +9,7 @@ const Menu = require('electron').Menu;
|
|||
const binding = process.atomBinding('web_contents');
|
||||
const debuggerBinding = process.atomBinding('debugger');
|
||||
|
||||
let slice = [].slice;
|
||||
let slice = [].slice;
|
||||
let nextId = 0;
|
||||
|
||||
let getNextId = function() {
|
||||
|
@ -74,13 +74,11 @@ let wrapWebContents = function(webContents) {
|
|||
webContents.setMaxListeners(0);
|
||||
|
||||
// WebContents::send(channel, args..)
|
||||
webContents.send = function() {
|
||||
var args = 2 <= arguments.length ? slice.call(arguments, 1) : [];
|
||||
var channel = arguments[0];
|
||||
webContents.send = function(channel, ...args) {
|
||||
if (channel == null) {
|
||||
throw new Error('Missing required channel argument');
|
||||
}
|
||||
return this._send(channel, slice.call(args));
|
||||
return this._send(channel, args);
|
||||
};
|
||||
|
||||
// The navigation controller.
|
||||
|
@ -99,8 +97,7 @@ let wrapWebContents = function(webContents) {
|
|||
|
||||
// Mapping webFrame methods.
|
||||
for (let method of webFrameMethods) {
|
||||
webContents[method] = function() {
|
||||
let args = Array.prototype.slice.call(arguments);
|
||||
webContents[method] = function(...args) {
|
||||
this.send('ELECTRON_INTERNAL_RENDERER_WEB_FRAME_METHOD', method, args);
|
||||
};
|
||||
}
|
||||
|
@ -152,30 +149,26 @@ let wrapWebContents = function(webContents) {
|
|||
});
|
||||
|
||||
// This error occurs when host could not be found.
|
||||
webContents.on('did-fail-provisional-load', function() {
|
||||
var args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
|
||||
|
||||
webContents.on('did-fail-provisional-load', function(...args) {
|
||||
// Calling loadURL during this event might cause crash, so delay the event
|
||||
// until next tick.
|
||||
setImmediate(() => {
|
||||
this.emit.apply(this, ['did-fail-load'].concat(slice.call(args)));
|
||||
this.emit.apply(this, ['did-fail-load'].concat(args));
|
||||
});
|
||||
});
|
||||
|
||||
// Delays the page-title-updated event to next tick.
|
||||
webContents.on('-page-title-updated', function() {
|
||||
var args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
|
||||
webContents.on('-page-title-updated', function(...args) {
|
||||
setImmediate(() => {
|
||||
this.emit.apply(this, ['page-title-updated'].concat(slice.call(args)));
|
||||
this.emit.apply(this, ['page-title-updated'].concat(args));
|
||||
});
|
||||
});
|
||||
|
||||
// Deprecated.
|
||||
deprecate.rename(webContents, 'loadUrl', 'loadURL');
|
||||
deprecate.rename(webContents, 'getUrl', 'getURL');
|
||||
deprecate.event(webContents, 'page-title-set', 'page-title-updated', function() {
|
||||
var args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
|
||||
return this.emit.apply(this, ['page-title-set'].concat(slice.call(args)));
|
||||
deprecate.event(webContents, 'page-title-set', 'page-title-updated', function(...args) {
|
||||
return this.emit.apply(this, ['page-title-set'].concat(args));
|
||||
});
|
||||
return webContents.printToPDF = function(options, callback) {
|
||||
var printingSetting;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue