On 3/07/11 5:36 AM, Ryosuke Niwa wrote:
On Sat, Jul 2, 2011 at 10:46 AM, John J. Barton
<johnjbar...@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


Reply via email to