W3C home > Mailing lists > Public > public-webapps@w3.org > July to September 2011

Re: Mutation events replacement

From: Sean Hogan <shogun70@westnet.com.au>
Date: Tue, 05 Jul 2011 21:07:21 +1000
Message-ID: <4E12F069.8040200@westnet.com.au>
To: public-webapps@w3.org
On 3/07/11 5:36 AM, Ryosuke Niwa wrote:
> On Sat, Jul 2, 2011 at 10:46 AM, John J. Barton
> <johnjbarton@johnjbarton.com>  wrote:
>> 2) element transformation. The replacement fires "after" a mutation.
>> Library or tools that want to transform the application dynamically want
>> to get notification "before" the mutation.
> Why do you need to get notified before the mutation?  Again, this is
> exactly the sort of usage that causes us headaches and what we want to
> avoid because scripts can then modify DOM before we make mutations.

Another reason for notifying before mutation (only applies to 
DOMNodeRemoved):

Some javascript libraries such as reglib 
(http://code.google.com/p/reglib/) use event delegation and CSS 
selectors to apply behavior to elements in a document.

If these libs wanted to take actions when an element is removed from the 
document they would need notification to occur before the element is 
removed, as this would allow element.matchesSelector() or equivalent to 
be called. Being notified after removal would require more complex code.

This is a fairly weak use-case. In general, if you need to know that an 
element is removed from the document then you already responded to it 
being in the document, at which time you could attach a mutation 
listener on the element.

Sean
Received on Tuesday, 5 July 2011 11:07:49 GMT

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