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

Re: Should MutationObservers be able to observe work done by the HTML parser?

From: Ryosuke Niwa <rniwa@webkit.org>
Date: Sun, 17 Jun 2012 12:17:07 -0700
Message-ID: <CABNRm61epr4nctpFLK+5MPzkmtNGRpWOBFO=jMHpCO3AgXPLPQ@mail.gmail.com>
To: Jonas Sicking <jonas@sicking.cc>
Cc: Rafael Weinstein <rafaelw@google.com>, Mihai Parparita <mihaip@chromium.org>, Adam Klein <adamk@chromium.org>, WebApps WG <public-webapps@w3.org>, Olli@pettay.fi
On Sun, Jun 17, 2012 at 5:03 AM, Jonas Sicking <jonas@sicking.cc> wrote:

> On Sat, Jun 16, 2012 at 7:04 AM, Rafael Weinstein <rafaelw@google.com>
> wrote:
> > I too thought we had intentionally spec'd them to not fire during load.
> >
> > The HTML spec is clear about this WRT Mutation Events:
> >
> > http://www.whatwg.org/specs/web-apps/current-work/#tree-construction:
> >
> > "DOM mutation events must not fire for changes caused by the UA
> > parsing the document. (Conceptually, the parser is not mutating the
> > DOM, it is constructing it.) This includes the parsing of any content
> > inserted using document.write() and document.writeln() calls."
> >
> > It seems like this should also apply to Mutation Observers, unless we
> > have compelling reasons to do otherwise.
>
> This was something that we got people complaining about with mutation
> events over the years. Our answer used to be that mutation events
> generally suck and you can't depend on them anyway. Obviously not an
> argument we'd want to use for MutationObservers.
>
> I can't think of any cases where you would *not* want these to fire
> for parser mutations.
>

Agreed. I'm in favor of observers being notified for parser-initiated DOM
mutations. The primary reason we don't fire mutation events for parser
insertion & removal is because they're synchronous and introduces all sorts
of problems including security vulnerabilities but that isn't the case with
mutation observers.

One question. Should we also notify mutation observers immediately before
executing synchronous scripts (i.e. script elements without differ or async
content attributes) to address Mihai's use case?

- Ryosuke
Received on Sunday, 17 June 2012 19:17:56 GMT

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