From f894da13b076668d5f4ee4bc2cfbd53e391d760e Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 1 Dec 2016 17:29:51 -0800 Subject: [PATCH] Pass args array instead of arguments object --- lib/renderer/api/remote.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/renderer/api/remote.js b/lib/renderer/api/remote.js index be0b71af6d9e..c3c8e3b89cd1 100644 --- a/lib/renderer/api/remote.js +++ b/lib/renderer/api/remote.js @@ -88,7 +88,7 @@ const wrapArgs = function (args, visited) { } } } - return Array.prototype.slice.call(args).map(valueToMeta) + return args.map(valueToMeta) } // Populate object's members from descriptors. @@ -102,14 +102,14 @@ const setObjectMembers = function (ref, object, metaId, members) { let descriptor = { enumerable: member.enumerable } if (member.type === 'method') { - const remoteMemberFunction = function () { + const remoteMemberFunction = function (...args) { if (this && this.constructor === remoteMemberFunction) { // Constructor call. - let ret = ipcRenderer.sendSync('ELECTRON_BROWSER_MEMBER_CONSTRUCTOR', metaId, member.name, wrapArgs(arguments)) + let ret = ipcRenderer.sendSync('ELECTRON_BROWSER_MEMBER_CONSTRUCTOR', metaId, member.name, wrapArgs(args)) return metaToValue(ret) } else { // Call member function. - let ret = ipcRenderer.sendSync('ELECTRON_BROWSER_MEMBER_CALL', metaId, member.name, wrapArgs(arguments)) + let ret = ipcRenderer.sendSync('ELECTRON_BROWSER_MEMBER_CALL', metaId, member.name, wrapArgs(args)) return metaToValue(ret) } } @@ -220,17 +220,17 @@ const metaToValue = function (meta) { if (meta.type === 'function') { // A shadow class to represent the remote function object. - let remoteFunction = function () { + let remoteFunction = function (...args) { if (this && this.constructor === remoteFunction) { // Constructor call. - let obj = ipcRenderer.sendSync('ELECTRON_BROWSER_CONSTRUCTOR', meta.id, wrapArgs(arguments)) + let obj = ipcRenderer.sendSync('ELECTRON_BROWSER_CONSTRUCTOR', meta.id, wrapArgs(args)) // Returning object in constructor will replace constructed object // with the returned object. // http://stackoverflow.com/questions/1978049/what-values-can-a-constructor-return-to-avoid-returning-this return metaToValue(obj) } else { // Function call. - let obj = ipcRenderer.sendSync('ELECTRON_BROWSER_FUNCTION_CALL', meta.id, wrapArgs(arguments)) + let obj = ipcRenderer.sendSync('ELECTRON_BROWSER_FUNCTION_CALL', meta.id, wrapArgs(args)) return metaToValue(obj) } }