Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge JavaScript Proxy methods #52

Open
jcalfee opened this issue Feb 20, 2022 · 0 comments
Open

Merge JavaScript Proxy methods #52

jcalfee opened this issue Feb 20, 2022 · 0 comments

Comments

@jcalfee
Copy link

jcalfee commented Feb 20, 2022

Is it possible for merge to capture a generic getter or setter from a proxy?

I'm providing:

const additionalJsContext = new Proxy({}, {
  set(obj, prop, value) {
    debug('set', {prop, value})
    obj[prop] = value
    return true
  },

  get(obj, prop) {
    const value = obj[prop]
    debug('get', {prop, value})
    return value === undefined ? null : value
  }
})

Then merge is used in this example [ref]:

  const sandbox: { [ind: string]: any } = merge(
    ctx.jsSandbox || {},
    data,
    additionalJsContext
  );

The generic "get" and "set" are not being merged into the sandbox object. If I put static properties in the 1st argument to Proxy it works or if I test my proxy alone additionalJsContext.anyprop === null it works. I'm not concerned about Proxy immutability, I can handle that with the set.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant