Re: [w3c/webcomponents] Returning a Proxy from a Custom Element constructor (#857)

I expect a membrane, or whatever I implement with a Proxy, on an element to be for userland. If the engine needs to modify `this` internally and it will bypass my Proxy, I'm totally fine with that. The majority of cases for Proxy (at least in my case) are to handle users' set/get on the instance. I already know that the HTML engine isn't going to arbitrarily set properties that I care about on my custom element instances. If the engine does anything with my instances, it will call life cycle hooks in response to user actions, which signal for me to manipulate my instance in response to the action. I don't see how the engine using the underlying [[Target]] would be an issue, unless that [[Target]] is not the same object that the engine created.

> target leak issue on account of the unupgraded element (the target) being potentially accessed and closed over before the upgrade took place

What leak? The reference to the userland object (which is the target in the proxy) doesn't change.

I'm imagining that the engine will upgrade the underlying `this` object that it originally created, not the Proxy. The underlying [[Target]] reference won't change, and the underlying [[Target]] is the `this` that the engine is going to upgrade.

Regardless of Proxy, people need to at some point handle an upgraded instance (whose reference is the same) in either the custom element `constructor` or something else. Proxy would contain the same [[Target]] reference whose prototype is upgraded and whose state is potentially modified by the custom element `constructor`.

It won't affect the Proxy, because the Proxy traps will be called when the user of the Proxy performs an action like getting or setting a property on the Proxy, at which point the property or method will either exist, or it won't, depending on whether the underlying [[Target]] that the HTML engine references is upgraded yet or not. 

We can close over non-upgraded instances today, as is,  and manipulate them before upgrade, and the problem isn't any different with or without Proxies, the way I see it.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/webcomponents/issues/857#issuecomment-560019633

Received on Saturday, 30 November 2019 20:42:21 UTC