Browse Source

Don't load remote properties until they are accessed

Kevin Sawicki 8 years ago
parent
commit
a23c6e39a2
2 changed files with 6 additions and 1 deletions
  1. 5 0
      lib/renderer/api/remote.js
  2. 1 1
      spec/api-ipc-spec.js

+ 5 - 0
lib/renderer/api/remote.js

@@ -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]

+ 1 - 1
spec/api-ipc-spec.js

@@ -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 () {