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

Re: <use> target/currentTarget handling

From: Nikolas Zimmermann <zimmermann@physik.rwth-aachen.de>
Date: Thu, 06 May 2010 11:40:36 +0200
Cc: www-svg@w3.org
Message-id: <929A6407-FAB8-479C-BA4F-5CCAC8E1E9D9@physik.rwth-aachen.de>
To: Erik Dahlstrom <ed@opera.com>

Am 06.05.2010 um 10:40 schrieb Erik Dahlstrom:

> 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]"
> Right.
>> #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?
> Yes.
>> 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.
Good to know!

>> 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.
Okay, I'm fine with that. It should be clarified :-)

>> 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.

Excellent, I thought I may had a major misunderstanding. Glad that  
it's resolved.

Thanks for the quick answer,
Received on Thursday, 6 May 2010 09:41:14 UTC

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