-- SVG WG is asking for feedback - event propagation --
Hi,
SVG provides a way to reference an entire SVG document using the
<image> element. The referenced document has its own DOM tree,
animations, scripting, and so DOM event propagation. The SVG WG had an
issue regarding how the event propagation is supposed to work in such
an environment (2 documents, one referencing another) and we would
like to have feedback from the DOM WG.
Scenario [A]:
=============
1. A.svg references a SVG document using the <image> tag.
<svg .../>
<image onclick="foo()" xlink:href="B.svg" ... />
</svg>
2. B.svg is the referenced SVG document (with a rect and a circle for
example):
<svg ...>
<rect onclick="bar()" ... />
<circle ... />
</svg>
Q1: Does both the bar() and foo() methods are invoked?
Q2: If both are invoked, which one is first?
Scenario [B]:
=============
<svg>
<a xlink:href="myDocument.svg">
<image xlink:href="B.svg" ... />
</a>
</svg>
B.svg
-----
<svg>
<rect ... />
<a xlink:href="myDocument2.svg">
<circle ... />
</a>
</svg>
Q3: If I click on the circle, which anchor is activated?
Q4: Which part of the SVG image is sensitive to events?
---
We had three different options:
1. The <image> element is a black box. A mouse click on the image will
only generate an event in the referenced document.
Scenario[A]: bar() is invoked.
Scenario[B]: myDocument2.svg is now the current document.
The side effect is that the author of the referencing document can not
override the behavior of the referenced document and does not control
what happens. We though that's going to be confusing for our users.
2. Both the referenced and the referencing document will receive a
mouse event. The event propagation happens first in the referenced
document (full capture and bubbling phase) and once it's completed,
the referencing document will dispatch a mouse event.
Scenario[A]: bar() is invoked then foo() are invoked
Scenario[B]: myDocument.svg is now the current document.
3. Try to unify the event propagation mecanism across documents. Do a
full capture from the referencing root element to the target element
of the referenced document. Then, do the full bubbling phase from the
target of the referenced document to the root element of the
referencing document.
Scenario[A]: bar() is invoked then foo() are invoked
Scenario[B]: myDocument.svg is now the current document.
The implementation of 3. is a bit tricky and it means that we have to
mutate twice the event during propagation (to go from referencing
document to the referenced document during the capture phase and the
opposite for the bubbling phase). Futhermore, plugins might not be
able to do that.
---
The SVG WG has choosen option 2 so far and we will provide an errata
to the SVG specification.
Before that, we are willing to hear feedback/comments/issues from the
DOM WG. How event propagation is working in a multiple namespaces
environment for example or how event propagation is working with
plugins might help us a lot to choose the best option.
Thanks in advance,
Thierry.