Skip to content

Commit d1152bf

Browse files
committed
remember ref in RemoteObject
1 parent 52152d7 commit d1152bf

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

lib/node/node-wsh.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export class WindowsScriptingHost extends EventEmitter {
3030

3131
get( target, prop) {
3232
if( prop === Symbol.toPrimitive)
33-
return () => `ref#${ this.wsh.#proxy2ref.get( target[ PROXY])}`;
33+
return () => `ref#${ target.ref}`;
3434
const encodedTarget = this.wsh.#encode( target[ PROXY]);
3535
const encodedProp = this.wsh.#encode( prop);
3636
const output = JSON.parse( this.wsh.#syncline.exchange( JSON.stringify( [ 'get', encodedTarget, encodedProp])));
@@ -60,7 +60,7 @@ export class WindowsScriptingHost extends EventEmitter {
6060

6161
get( target, prop) {
6262
if( prop === Symbol.toPrimitive)
63-
return () => `ref#${ this.wsh.#proxy2ref.get( target[ PROXY])}`;
63+
return () => `ref#${ target.ref}`;
6464
return undefined;
6565
},
6666

@@ -141,7 +141,7 @@ export class WindowsScriptingHost extends EventEmitter {
141141
if( existingProxy)
142142
return existingProxy;
143143

144-
const target = handler === this.#objectHandler? new RemoteObject(): function() {};
144+
const target = handler === this.#objectHandler? new RemoteObject( ref): function() {};
145145
const newProxy = new Proxy( target, handler);
146146
target[ PROXY] = newProxy;
147147
this.#ref2proxy.set( ref, newProxy);
@@ -247,4 +247,14 @@ export class WindowsScriptingHost extends EventEmitter {
247247
}
248248

249249
class RemoteObject {
250+
251+
#ref;
252+
253+
constructor( ref) {
254+
this.#ref = ref;
255+
}
256+
257+
get ref() {
258+
return this.#ref;
259+
}
250260
}

0 commit comments

Comments
 (0)