Don't load remote properties until they are accessed
authorKevin Sawicki <kevinsawicki@gmail.com>
Wed, 14 Sep 2016 20:21:44 +0000 (13:21 -0700)
committerKevin Sawicki <kevinsawicki@gmail.com>
Wed, 14 Sep 2016 20:29:49 +0000 (13:29 -0700)
lib/renderer/api/remote.js
spec/api-ipc-spec.js

index d1c9193..3cb99e5 100644 (file)
@@ -167,6 +167,11 @@ const proxyFunctionProperties = function (remoteMemberFunction, metaId, name) {
   }
 
   return new Proxy(remoteMemberFunction, {
+    set: (target, property, value, receiver) => {
+      if (property !== 'ref') loadRemoteProperties()
+      target[property] = value
+      return true
+    },
     get: (target, property, receiver) => {
       if (!target.hasOwnProperty(property)) loadRemoteProperties()
       return target[property]
index 542c742..eedab2b 100644 (file)
@@ -72,7 +72,7 @@ describe('ipc module', function () {
 
       a = remote.require(path.join(fixtures, 'module', 'function-with-missing-properties.js')).setup()
       assert.equal(a.bar(), true)
-      assert.equal(typeof a.bar.baz, 'function')
+      assert.equal(a.bar.baz, undefined)
     })
 
     it('should work with static class members', function () {