lewisje / svgweb

Automatically exported from code.google.com/p/svgweb
Other
0 stars 0 forks source link

Removing all childs from box #490

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hi. Im trying to remove all childs from box (just want to clean drawing field)

var grs = document.getElementById('graphRightSide');
if ( grs.hasChildNodes() )
{
    while ( grs.childNodes.length >= 1 )
    {
        console.log(grs.firstChild);
        svgweb.removeChild(grs.firstChild, grs);
    }
}

Log says that nothing is deleting - I got infinite loop. What Im doing
wrong? And if my actions are wrong, then why there is no error or exception?
Thanks, Vitaly.

Original issue reported on code.google.com by md.xytop on 18 May 2010 at 10:47

GoogleCodeExporter commented 8 years ago
Found a solution:

var grs = document.getElementById('graphRightSide');
if ( grs.hasChildNodes() )
{
    while (grs.childNodes.length > 0)
    {
        grs.removeChild(grs.firstChild);
    }
}

As I found in sources, svgweb.removeChild works only for OBJECT, EMBED and SVG 
elements.
Can you confirm, that I not getting a memory leak or smthg by using this code?

Original comment by md.xytop on 19 May 2010 at 7:58

GoogleCodeExporter commented 8 years ago
Please don't ask questions by opening bug reports! Send your question to the 
mail list instead.

Original comment by bradneub...@gmail.com on 19 May 2010 at 5:27