W3C home > Mailing lists > Public > public-script-coord@w3.org > April to June 2013

Re: Specs and Object.observe()

From: Rick Waldron <waldron.rick@gmail.com>
Date: Mon, 17 Jun 2013 14:59:04 -0400
Message-ID: <CAHfnhfqJUxOiOV-v_=qCrfTWiXGfL2Ku3ZgtA7BN-+Je_jxLkA@mail.gmail.com>
To: François REMY <francois.remy.dev@outlook.com>
Cc: Marcos Caceres <w3c@marcosc.com>, public-script-coord <public-script-coord@w3.org>
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)

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
Received on Monday, 17 June 2013 18:59:51 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 17:14:13 UTC