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

Re: SVG 1.1 Does no text exist in the DOM? or why no eggs?

From: Alex Danilo <alex@abbra.com>
Date: Sun, 03 Oct 2010 10:20:02 +1000
Message-Id: <E9UO9L.TSLSA5NPJWBL@abbra.com>
To: Jonathan Chetwynd <j.chetwynd@btinternet.com>
Cc: www-svg <www-svg@w3.org>
Hi Jonathan,

	That looks like a bug in the DOM implementations to me.

	As a guess, the first SVG text node has a single DOM text
node child containing one space. In the second case, there is no
child text node since the XML tags butt up against one another.

	The implementation of 'nodeValue' applying to the parent
SVG text node should create a new DOM text node child to hold the
'eggs' when it is set. Current code most likely looks for an existing
child text node and tries to replace the referenced string. It should
of course see the missing child node and add a new one to host the 'eggs'.

	When you set the string to empty, the child DOM text node
probably hangs around referencing an empty string.

	But it appears that this case isn't being handled
correctly in current implementations. Makes for a good test.

	This could be put into an SVG test since it is testing
the specific case of setting the text child content on an SVG
text node which is quite different to the HTML world.


--Original Message--:
>Does no text exist in the DOM? or why no eggs?
><text></text> should to my way of  thinking provide a handle for  
>script to enter  text into the DOM, but it doesn't in ff opera or  
>so why not?
>ie is there a specification that defines this behaviour?
>hard to file a bug, as I cant fathom this out.
>Jonathan Chetwynd
>in this testcase onmouseover, "ham'n" gets displayed, but no 'eggs'
>this  may likely be correct, but what is the benefit, or purpose?
>and what the workaround?
>please note that once instantiated, on can remove all the content, and  
>add new content, but not apparently start with no content.
>not a very nice workaround.....
><?xml version="1.0" encoding="utf-8" standalone="no"?>
><svg xmlns="http://www.w3.org/2000/svg">
><rect x="80" y="75" id="chat" width="45" height="36" fill="#cca"  
>onmouseover="addText()" />
><text id="chatText" x="83" y="90" > </text>
><text id="chat2Text" x="83" y="105" ></text>
><script type="text/ecmascript"> <![CDATA[
>function addText(){
>         e = document.getElementById("chatText");
>	e.firstChild.nodeValue='';
>	e.firstChild.nodeValue="ham'n";
>         2e = document.getElementById("chat2Text");
>	2e.firstChild.nodeValue='eggs';
Received on Sunday, 3 October 2010 00:20:48 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 22:54:28 UTC