Re: Specs and Object.observe()

On Mon, Jun 17, 2013 at 11:59 AM, Rick Waldron <waldron.rick@gmail.com>wrote:

>
> On Mon, Jun 17, 2013 at 5:55 AM, François REMY <
> francois.remy.dev@outlook.com> wrote:
>
>> As far as I know, Object.observe only works for "plain objects" i.e. it
>> doesn't fire when properties with getter/setter are changed. If you are
>> working on a DOM spec, it's very likely you're in this specific case.
>>
>
> Object.observe works with all objects. Some objects, such as Dates, Maps,
> Sets, WeakMaps and likely WeakSets will not trigger change events when
> their internal data is modified via methods (setTime, set, add, delete,
> etc), but defining and later modifying expando properties will trigger a
> change. (This list is not exhaustive)
>

Hi Rick, I never recall deciding that they would not. In general, mutable
abstractions should consider sending synthetic change notifications if
anyone is listening. We need to take it on a case by case basis per mutable
abstraction, and on the design of these particular synthetic change
notifications. But I see no immediate reason why the non-Weak* ones above
would be candidates. Even the Weak* ones perhaps, if we're careful enough
with the security issues.



>
> As François stated, accessors will not trigger change events; instead,
> you'd define a set accessor that will manually call an object's notifier
> function:
> https://gist.github.com/rwldrn/3453045#file-complex-observe-js-L39-L56
>
>
> Rick
>
>
>


-- 
    Cheers,
    --MarkM

Received on Monday, 17 June 2013 19:35:55 UTC