Le 18/10/2011 21:47, Tom Van Cutsem a écrit :
> Hi David,
>
> What you seem to want is the ability to define new kinds of properties
> in addition to data and accessor properties. That is beyond the goal
> of proxies.
If proxies allow to pass property descriptor attributes other than
get/set/configurable/enumerable/writable/value, then I think whatever
new attribute is passed is part of a new kind of property descriptor.
The approach you describe below is very interesting but seem to force
event properties to be accessor properties. If ever implemented
natively, this may result in particular semantics of
Object.defineProperty(o, name, {event:true}) (defaulting to an accessor
rather than a data descriptor as it would now).

The idea of having only data or accessor property + some metadata is
appealing, but I'm afraid it won't be enough to give these other
"description attribute" enough power. And I'm afraid that if this isn't
discussed today, we run into backward compatibility issues if new kinds
of property descriptors are ever considered for standardization.

> (...)
>
> I would model your event property descriptors as follows:
>
> getOwnPropertyDescriptor: function(name) {
>   if (/* name is an event property */) {
>     return {
>       event: true,
>       get: function() {
>         // we now have access to "receiver", it's |this|
>         // fire the listeners
>       }
>     }
>   }
> }
That's a very interesting approach. I'll try to implement it and give
feedback.

Thanks,

David
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to