Re: [D3E] Possible Changes to Mutation Events

Boris Zbarsky <bzbarsky@MIT.EDU> wrote:

> 
> Doug Schepers wrote:
> >> 2) If DOMNodeRemoved is fired after the mutation, event won't be 
> >> capable of bubbling
> > 
> > I don't believe that is correct.  DOM3 Event states:
> > 
> > "At the beginning of the dispatch, implementations must first determine 
> > the event object's propagation path.
> 
> I think Sergey's point was that if dispatch happens after the removal, 
> and the target is the node being removed, this path will have nothing else
> in it.

It may be possible to pre-compute the list, but that would certainly
complicate the code that implements event dispatch, and as all of a sudden
we would have two events that needs to behave differently in some cases -
because, of course, you wouldn't want to modify the tree if the event was
dispatched via dispatchEvent()

Specifying the order would be the most helpful that could be done for these
two events.  For removal, I dispatch DOMNodeRemoved first and then do a
post-order traversal issuing DOMNodeRemovedFromDocument.  For insertion, I
dispatch DOMNodeInserted first and then do a pre-order traversal issuing
DOMNodeInsertedIntoDocument.  IIRC, this was consistent with Firefox and
Opera at the time and it seems sensible enough.


-- 
Stewart Brodie
Software Engineer
ANT Software Limited

Received on Wednesday, 16 July 2008 09:03:04 UTC