(I was tempted to call this Integration by Parts, but I think the other calculus fans reading Planet Mozilla would raise a pitchfork or two.)
In my last blog entry, I talked briefly about an idea I had:
Tom Van Cutsem saw my sample this way in an e-mail he sent back:
If that’s the case, I think your code here actually demonstrates two nice use cases of proxies:
- it shows aggregation of object properties.
- it shows how you can create a “side-effect-free” proxy for an object (or a graph of objects), which provides the illusion of side-effects (adding/deleting properties) to the proxy client without affecting the wrapped object.
I can imagine proxies that support only 1) or 2) to be useful in their own right. It may even make sense to separate out the functionality into two proxies and then chain them together so that we have:
client -> side-effect-free-proxy -> aggregate-proxy -> target
The version I’m posting here has Tom’s annotations in the source code.
I’d love to work on this with fellow Mozilla contributors, to build a complete aggregation by proxy script for the DOM. Anyone interested?