1.1 --- a/libxml2dom/svg.py Fri Apr 06 18:38:22 2007 +0000
1.2 +++ b/libxml2dom/svg.py Fri Apr 06 21:45:01 2007 +0000
1.3 @@ -690,7 +690,10 @@
1.4 namespaces["svg"] = SVG_NAMESPACE
1.5 return libxml2dom.Node.xpath(self, expr, variables, namespaces)
1.6
1.7 -class SVGDocument(libxml2dom._Document, SVGNode, EventTarget, DocumentEvent): # NOTE: The latter is from DOM Level 3 Events.
1.8 +# NOTE: DocumentEvent is from DOM Level 3 Events.
1.9 +# NOTE: EventSystem is a special libxml2dom.events class.
1.10 +
1.11 +class SVGDocument(libxml2dom._Document, SVGNode, EventTarget, DocumentEvent, EventSystem):
1.12
1.13 "An SVG-specific document node."
1.14
1.15 @@ -821,19 +824,29 @@
1.16
1.17 """
1.18 See: http://www.w3.org/TR/SVGMobile12/svgudom.html#svg__EventListenerInitializer2
1.19 + See: http://www.w3.org/TR/xml-events/#section-listener-element
1.20 """
1.21
1.22 + # Initialise script element listeners.
1.23 +
1.24 for script in doc.xpath("//svg:script"):
1.25 doc.global_.initializeEventListeners(script)
1.26 +
1.27 + # Initialise handler element listeners using XML Events.
1.28 +
1.29 for handler in doc.xpath("//svg:handler"):
1.30 listener = doc.global_.createEventListener(handler)
1.31
1.32 - # NOTE: May need to have the event type understood and correctly parameterised.
1.33 + # Attempt to parameterise the registration using the XML Events attributes.
1.34 +
1.35 + phase = handler.getAttributeNS(libxml2dom.events.XML_EVENTS_NAMESPACE, "phase")
1.36 +
1.37 + # Add the listener for the appropriate type and phases.
1.38
1.39 handler.parentNode.addEventListener(
1.40 handler.getAttributeNS(libxml2dom.events.XML_EVENTS_NAMESPACE, "event"),
1.41 listener,
1.42 - 0
1.43 + phase == "capture"
1.44 )
1.45
1.46 # Utility functions.