W3C home > Mailing lists > Public > public-webapps@w3.org > April to June 2011

Re: Mutation events replacement

From: Ryosuke Niwa <rniwa@webkit.org>
Date: Thu, 30 Jun 2011 16:09:37 -0700
Message-ID: <BANLkTi=ez2n2m-vWYpa2MqSc5htdk4FQzA@mail.gmail.com>
To: Jonas Sicking <jonas@sicking.cc>
Cc: Aryeh Gregor <Simetrical+w3c@gmail.com>, "Olli@pettay.fi" <Olli@pettay.fi>, Anne van Kesteren <annevk@opera.com>, Webapps WG <public-webapps@w3.org>
On Wed, Jun 29, 2011 at 6:11 PM, Jonas Sicking <jonas@sicking.cc> wrote:
>
>  > Maybe this is a stupid question, since I'm not familiar at all with
> > the use-cases involved, but why can't we delay firing the
> > notifications until the event loop spins?  If we're already delaying
> > them such that there are no guarantees about what the DOM will look
> > like by the time they fire, it seems like delaying them further
> > shouldn't hurt the use-cases too much more.  And then we don't have to
> > put further effort into saying exactly when they fire for each method.
> >  But this is pretty obvious, so I assume there's some good reason not
> > to do it.
>
> To enable things like widget libraries which want to keep state
> up-to-date with a DOM.
>

I agree that in many cases, libraries will be able to update states before
application gets back control.  However, callbacks are called synchronously
sometimes and asynchronously sometimes might cause problems in some
situations.  Consider the following situation.

I write a function that mutates DOM and updates some internal state based on
a value automatically provided by some library (say jQuery, etc...) upon in
a DOM mutation callback.

Later, my colleague adds new feature and decides to call my function in a
middle of DOM mutation callback.  And oops!  My function doesn't work
because it relied on the assumption that DOM mutation callbacks are called
synchronously when I mutate DOM.

- Ryosuke
Received on Thursday, 30 June 2011 23:10:38 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 18:49:45 GMT