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 Sunday, 17 May 2009 13:43:02 UTC