Re: question about struct-use-205-t.svg

On Wed, 11 Jun 2008 17:34:53 +0200, Andrew Emmons <andrew.emmons@quickoffice.com> wrote:

> Hello Erik,
>
> I have a question about struct-use-205-t.svg, which is marked as approved in the upcoming testsuite.
>
> For the last subtest ( the use with id="u3") , it is asserting that:
>
> // If the nested use handler was executed then the rect element where the event originated has no
> // corresponding use element anymore, correspondingUseElement will be null.
> if(!event.target.correspondingUseElement)
>
> This makes sense, if indeed the test was removing the use element in the nested use handler ( use with id="nesteduse" ). However, this handler does not remove the use element, but rather the handler itself.

Only handlers are meant to be removed from the tree, and only to avoid unwanted side-effects. The use with id="nesteduse" changes what it refers to during the event bubbling, that's the thing that may be tricky to get right in the last subtest. First the inner handler (id="nestedhandler") is executed, and regardless of whether that is a pass or fail there it changes the xlink:href to point to another element. When the event bubbles from there up into the use with id="u3" the event.target (the rect with id="r") is no longer in the original shadowtree, so it doesn't have a correspondingUseElement.

This is expressed too in the test description:
"The bottom-right rect uses nested 'use' elements. The event handler 'nestedhandler' should be executed first, and will
 check some aspects of nested use elements. It will modify what it references, and that is checked in the 'h4' event
 handler."

> // Remove the handler, so that clicking again does nothing
> document.getElementById("nesteduse").removeChild(document.getElementById("nestedhandler"));
>
> It is my understanding that removing the handler only would not change the fact that the <rect> element is in a use or not.

Yes, that's correct. The comment says what it's meant to do though. The handler is removed because once it's been executed it wouldn't give correct behavior on a second or third click, and the test would fail.

> If the intent was to test the removal, should it not be removing "nesteduse" instead?

That's not the point of the test. It's testing that changing the xlink:href has an effect on the shadowtree.

Cheers
/Erik

-- 
Erik Dahlstrom, Core Technology Developer, Opera Software
Co-Chair, W3C SVG Working Group
Personal blog: http://my.opera.com/macdev_ed

Received on Thursday, 12 June 2008 07:16:29 UTC