Could not find text element with id in SVG

I played with animation in SVG: http://imgh.us/renamon-animtest.svg (links to script "anim.js")

In the window.onload event, I have:

function init(evt)
{
    if(window.svgDocument == null)
    {
        if(evt.target && evt.target.ownerDocument)
            svgDocument = evt.target.ownerDocument;
        else if(evt.originalTarget && evt.originalTarget.ownerDocument)
            svgDocument = evt.originalTarget.ownerDocument;
        else svgDocument = document;
    }

    _debug = svgDocument.getElementById('debug');
    alert(_debug.firstChild.nodeValue);

    for(i = 0; i < 1; i++)
        balls[i] = svgDocument.getElementById('ball' + i);
    setInterval(loop, 50);
}

It can find the ball objects in order, but not the debug object (getElementById returns null). I see this in the source, so why can't the script find it?

+3
source share
1 answer

Most likely, you are testing the implementation of SVG 1.1, since flowRoot was introduced in SVG 1.2.
Invalid elements are ignored, therefore they are not displayed in the DOM

+1

Source: https://habr.com/ru/post/1757058/


All Articles