salesforce / near-membrane

JavaScript Near Membrane Library that powers Lightning Locker Service

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Passing the red `Proxy` to a blue function

jdalton opened this issue · comments

When passing a red Proxy to a blue function the constructor is wrapped in a proxy that uses an arrow function as the target which means it can no longer do new Proxy(...) since arrow functions cannot be newed.
https://github.com/caridy/sandboxed-javascript-environment/blob/e9602e9274f39b690c7c48571c21f01961253541/src/red.ts#L623

For function constructors that are native but lack a prototype we can create a target line

shadowTarget = (function(){}).bind()

For arrow functions which lack a prototype and are not new-able:

shadowTarget = () => {}

For everything else is:

shadowTarget = function () {}