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

Hi Jonathan,

Try this:
<svg width="100%"
 xmlns="http://www.w3.org/2000/svg"
 xmlns:xlink="http://www.w3.org/1999/xlink"
 onload="startup()"
>
<script><![CDATA[
xmlns="http://www.w3.org/2000/svg"
function startup(){
 T=document.getElementById("T")
 Msg=document.createTextNode("hello")
 T.appendChild(Msg)
}
//]]>
</script>
 <text id="T" x="100" y="200" font-size="20" fill="black"></text>
</svg>
It works for me everywhere.[1]

I do recall some cross browser idiosyncracies involving <text> </text> where 
there is whitespace in the <text> tag. It seems like FF and IE for example 
handle embeded carriage returns differently, with one of them viewing white 
space as text nodes, but I can't remember and that may be in HTML rather 
than SVG.


cheers
David

[1] 
http://www.w3.org/Graphics/SVG/IG/resources/svgprimer.html#createTextNode
----- Original Message ----- 
From: "Jonathan Chetwynd" <j.chetwynd@btinternet.com>
To: "www-svg" <www-svg@w3.org>
Sent: Saturday, October 02, 2010 5:44 PM
Subject: SVG 1.1 Does no text exist in the DOM? or why no eggs?


> 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  safari,
> so why not?
> ie is there a specification that defines this behaviour?
> hard to file a bug, as I cant fathom this out.
>
> regards
>
> 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';
> }
> ]]></script>
> </svg>
>
>
> 

Received on Sunday, 3 October 2010 01:02:01 UTC