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

Re: removeChild and <use> question

From: Erik Dahlstrom <ed@opera.com>
Date: Wed, 13 Jan 2010 15:24:57 +0100
To: "Patrick Dengler" <patd@microsoft.com>, "Jeff Schiller" <codedread@gmail.com>, "Boris Zbarsky" <bzbarsky@mit.edu>, www-svg <www-svg@w3.org>
Message-ID: <op.u6g6bvmogeuyw5@localhost>
It's known that Firefox doesn't (yet) support the SVGElementInstance DOM  
interface, while Opera does. This is probably what you're seeing.

This means that behavior will differ slightly, since Events can have  
SVGElementInstances as the target (whereas firefox uses the cloned element  
AFAIK, so an element implementing one of the SVG*Element interfaces). This  
small issue is entirely possible to work around in js by checking the  
object type, or existence of particular methods on the SVGElementInstance  
interface. One example here:  
http://files.myopera.com/MacDev_ed/svg/coords/showbbox.js (see "fixes for  
use element").

The drawback of using cloned elements: uses as much RAM as the  
"equivalent" expanded DOM tree. This is however not the case in Opera, we  
use a lightweight object that only implements the SVGElementInstance  
interface which uses less memory than the normal cloned nodes would (as  
you may note SVGElementInstance doesn't inherit from Node, Element or any  
of the SVG*Element interfaces).

Cheers
/Erik

On Tue, 12 Jan 2010 22:51:24 +0100, Patrick Dengler <patd@microsoft.com>  
wrote:

> We also saw similar inconsistent behaviors with events on <use>
>
> We found that the behavior of <use> referring to an element which is  
> currently not the part of DOM but added later to DOM via DOM  
> manipulation are handled differently in different browsers.
>
> These seem like good topics for our next conference call.
>
> -----Original Message-----
> From: www-svg-request@w3.org [mailto:www-svg-request@w3.org] On Behalf  
> Of Jeff Schiller
> Sent: Tuesday, January 12, 2010 1:31 PM
> To: Boris Zbarsky; www-svg
> Subject: Re: removeChild and <use> question
>
> Boris,
>
> Thanks for the explanations.
>
> On Tue, Jan 12, 2010 at 3:28 PM, Boris Zbarsky <bzbarsky@mit.edu> wrote:
>> On 1/12/10 4:08 PM, Jeff Schiller wrote:
>>> would result in someUsePointingToFoo still holding a reference to a
>>> <use>  element, but it is now detached from the DOM
>>
>> Not at all.  It's in the DOM just fine.  However its cloned instance  
>> tree is
>> now gone.  It's the same as if you had a <use xlink:href="#foo"> and  
>> had no
>> node with id="foo" in the document.
>>
>
> Ok, I took Patrick's email to mean that the use element itself was
> removed from the DOM.  This is what I found odd.
>
> Jeff
>
>
>


-- 
Erik Dahlstrom, Core Technology Developer, Opera Software
Co-Chair, W3C SVG Working Group
Personal blog: http://my.opera.com/macdev_ed
Received on Wednesday, 13 January 2010 14:22:04 GMT

This archive was generated by hypermail 2.3.1 : Friday, 8 March 2013 15:54:44 GMT