Re: Should the base svg tag receive events?

On 8/13/10 3:19 AM, Doug Schepers wrote:
>> Per the letter of the SVG spec right now, that event should not even be
>> fired. In particular, a click listener added on the window should not
>> fire at all when the viewport is clicked after loading that document. I
>> would be very surprised if any browser implemented that behavior,
>> though; it seems pretty broken to me.
>
> Why's that? It seems very logical to me, actually... there's nothing to
> click on, therefore, there should be no pointer events.

Because if I click somewhere in the window, the window itself should get 
a click event.  Breaking that doesn't seem reasonable.  The only 
question is what the target of the event should be.

> Are you referring to this?
> [[
> If a target element for the pointer event does not exist, then the event
> is ignored.
> ]]

Yes.

> I don't interpret that to mean that the event is discarded for any
> content outside the SVG context... rather, I read it to mean that in
> that case, SVG doesn't do anything with the action... the action is
> ignored, and not treated as an interaction with the SVG content. Put
> another way, SVG doesn't intercept the event, and it should be treated
> normally by whatever is "below" the SVG fragment.
>
> To be honest, I find it a bit difficult to interpret that as saying
> anything about the events or DOM of some host document; SVG doesn't
> usually say anything at all about the behavior of host languages. Did I
> miss something else?

Look, the spec says that you do one of two things.  Either you take the 
input and dispatch a DOM event through the normal DOM event dispatch 
path or you "ignore the event".  If your interpretation is taken that 
this is just talking about SVG and that host languages should do their 
own additional thing, then the only way to make things "work" in the 
case when SVG ignores the event is if the embedding document itself 
defines that events must be dispatched to a DOM node indepedently of 
what SVG does.  But in that case, clicking on a graphical element in SVG 
will dispatch two DOM events: one to the graphical element and one to 
something in the embedding document.  That's clearly wrong.

The right way to define this is to say that a DOM event is always 
dispatched, but that the target when there are no graphical elements 
under the pointer is the nearest ancestor of the root SVG element that's 
sensitive to events or something.  There are probably other ways to 
define it too, but what the spec has now seems pretty clear and isn't right.

I'm out for the next week, so the next reply, if needed, will be laggy, 
but not because I'm ignoring you.

-Boris

Received on Friday, 13 August 2010 12:23:02 UTC