You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by Yaroslav Bulatov <ya...@gmail.com> on 2006/08/31 01:07:41 UTC

DOM doesn't get updated

I use Javascript to remove a child of "<g>" element and add it as a
child of "<use>" element

oldNode.removeChild(node);
newNode.insertBefore(node, newNode.firstChild);

Inside Batik this seems to create a new DOM node which is not rooted
in the existing DOM hiearchy (ie, not accessible through
svgCanvas.getSVGDocument()). The old DOM node is not removed from the
DOM hierarchy.

The BridgeContext is updated correctly however, and it is possible to
access the new node through BridgeContext.getElement(GraphicsNode).

Is there a way to force Batik to update the DOM so that it is
synchronized with the GraphicalNode hierarchy?

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


Re: DOM doesn't get updated

Posted by th...@kodak.com.
Hi Yaroslav,

"Yaroslav Bulatov" <ya...@gmail.com> wrote on 09/01/2006 02:31:37 PM:

> The <use> element references those <rects> however and they are
> displayed in the component as expected. What is the recommended way of
> getting a hold of this "shadow tree"?

   The short answer is you don't.  If you need to manipulate the 
use tree you should not use 'use' you should just deepClone the 
referenced elements and insert them where the use element would be.


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


Re: DOM doesn't get updated

Posted by Yaroslav Bulatov <ya...@gmail.com>.
>    Perhaps you are getting confused by the 'shadow copy' of the
> used tree?  When a 'use' element references a element.  That element
> and it's children are copied into a shadow tree (mostly so we can
> do CSS inheritance from the use element).

Yes, this seems to be what's happening. There are <rect> elements inside of a
<defs> element which are in the DOM, but don't have a corresponding
object in the GraphicsNode hierarchy

The <use> element references those <rects> however and they are
displayed in the component as expected. What is the recommended way of
getting a hold of this "shadow tree"?

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


Re: DOM doesn't get updated

Posted by th...@kodak.com.
Hi Yaroslav,

"Yaroslav Bulatov" <ya...@gmail.com> wrote on 08/30/2006 07:07:41 PM:

> I use Javascript to remove a child of "<g>" element and add it as a
> child of "<use>" element

   Do you mean this literally?  a 'use' element can't have
graphic children in SVG.  Do you really mean that you add
it as a child of a 'used' element (probably a 'g' with id
or a 'symbol' element).

> oldNode.removeChild(node);
> newNode.insertBefore(node, newNode.firstChild);
> 
> Inside Batik this seems to create a new DOM node which is not rooted
> in the existing DOM hiearchy (ie, not accessible through
> svgCanvas.getSVGDocument()). The old DOM node is not removed from the
> DOM hierarchy.

   This is certainly not my experience with the Batik DOM.
I think I would have noticed by now if this was common behavior
in Batik. ;)

> The BridgeContext is updated correctly however, and it is possible to
> access the new node through BridgeContext.getElement(GraphicsNode).

   Perhaps you are getting confused by the 'shadow copy' of the
used tree?  When a 'use' element references a element.  That element
and it's children are copied into a shadow tree (mostly so we can
do CSS inheritance from the use element).

> Is there a way to force Batik to update the DOM so that it is
> synchronized with the GraphicalNode hierarchy?

    Well in Batik the GraphicsNodes are updated from
the DOM never the other way round.  So if your 'nodes' above
are GraphicsNodes then you need to change them to be DOM
nodes (but I suspect that this is the case).


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org