RE: DOM Level 3 Events

My understanding is that the "document does it all". In this manner, recursive or re-entrant event handlers that modify the tree do not have an effect on the original computed path. In other words, if an event handler is triggered which removes the target node from the document before the capture phase completes, that target node will still receive the event despite the fact that it's no longer in the tree (because the document is managing it).

From: www-dom-request@w3.org [mailto:www-dom-request@w3.org] On Behalf Of Emanuele D'Arrigo
Sent: Sunday, May 17, 2009 6:42 AM
To: www-dom@w3.org
Subject: DOM Level 3 Events

Hi everybody, greetings from wet, windy and rainy UK! But no worries: we -should- get a couple of weeks of summer in the next three months! ;)

Down to business:
I've spent the past few days sifting through the DOM Level 3 documents to add Events support to pxdom<http://www.doxdesk.com/software/py/pxdom.html>, a pure-python implementation of the Document Object Model. I'm finding there's a bit of a gap in my understanding of the dispatch process and I hope this is the right place where to ask some tips and tricks.

Specifically, once an event is created through Document.createEvent(), which object is responsible for -orchestrating- the dispatch? I currently have two options in mind:

1) the Document object does it all. It creates the event, initializes it, establishes the routing and then iterates through targets and listeners along the way and back.

2) the Document object creates, initializes and establish the routing, but it then leaves the responsibility to the nodes on the way to the target to recursively call the dispatchEvent() method on their appropriate children, i.e.:

dispatchEvent(event)
     letCapturingListenersHandleTheEvent(event)
     nextTargetNode = event.getNextTargetFromRouting(thisTargetNode)
     nextTarget.dispatchEvent(event)
     letBubblingListenersHandleTheEventIfTheEventBubbles(event)

Is either way (or further alternatives) the intended or better way?

Manu

Received on Monday, 18 May 2009 16:02:25 UTC