W3C home > Mailing lists > Public > www-svg@w3.org > May 2010

Re: <use> target/currentTarget handling

From: Erik Dahlstrom <ed@opera.com>
Date: Thu, 06 May 2010 10:40:07 +0200
To: "Nikolas Zimmermann" <zimmermann@physik.rwth-aachen.de>, www-svg@w3.org
Message-ID: <op.vb9zo5z6geuyw5@localhost>
On Wed, 05 May 2010 14:06:43 +0200, Nikolas Zimmermann  
<zimmermann@physik.rwth-aachen.de> wrote:


> How to test
> ==================
> #1) Click on the red rectangle. Should result in:
> alert: "target: [object SVGElementInstance] current target: [object
> SVGElementInstance]"


> #2) Click on the text. _I THINK_ it should result in: (that's the path
> I've chosen for WebKit)
> alert: "target: [object SVGRectElement] current target: [object
> SVGRectElement]"
> alert: "target: [object SVGElementInstance] current target: [object
> SVGElementInstance]"

Yes, that looks correct to me.

> #2) This is tricky.  think it should be possible to dispatch an event
> manually to every element in the DOM.
> So dispatching directly to "rect", should work as expected, and not
> end up on a SVGElementInstance. This should explain the expected
> result for the first alert(), as stated above. Is it correct?


> When dispatching manually to the "rectInstance" WebKit delivers it to
> the SVGElementInstance, and Opera does not. It says "target: [object
> SVGRectElement] current target: [object SVGRectElement]"
> Can anyone explain what's happening? Just a bug in Opera? I think the
> spec clearly states here, that the event should end up on the
> SVGElementInstance.

Yes, that's a bug in Opera (in SVGElementInstance.dispatchEvent). Tracked  
as bug CORE-29603.

> Further questions
> ==================
> Spec says: The event handling for the non-exposed tree works as if the
> referenced element had been textually included as a deeply cloned
> child of the 'use' element, except that events are dispatched to the
> SVGElementInstance objects. The event's target and currentTarget
> attributes are set to the SVGElementInstance that corresponds to the
> target and current target elements in the referenced subtree
> .....
> The currentTarget attribute of the event can be used to determine
> through which object an event listener was invoked.
> What does the last sentence mean in practice? Does it talk about
> target pointing to eg. SVGRectElement, but currentTarget pointing to a
> SVGElementInstance?

It probably should mention target too. I'm guessing this sentence is here  
to hint that the EventTargets may not be actual Nodes, but  
SVGElementInstances, and that you can get the actual referenced element  
via the correspondingElement accessor.

> Of course when the event bubbles currentTarget and target are not
> equal anymore, but I'm wondering about the target phase. The sentence
> above makes me thing there is some difference that I'm overlooking.
> To rephrase: When is currentTarget != target? Only when capturing/
> bubbling?

As noted, during capturing/bubbling they can be different.


Erik Dahlstrom, Core Technology Developer, Opera Software
Co-Chair, W3C SVG Working Group
Personal blog: http://my.opera.com/macdev_ed
Received on Thursday, 6 May 2010 08:40:43 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 8 March 2017 09:47:21 UTC