From f7fb4255b663272770c3cad5a3c92094137225b2 Mon Sep 17 00:00:00 2001 From: Jeff Schiller Date: Fri, 9 Oct 2009 02:14:47 +0000 Subject: [PATCH] Fix Issue 260: Ensure defs do not get shoved into a new layer git-svn-id: http://svg-edit.googlecode.com/svn/trunk@784 eee81c28-f429-11dd-99c0-75d572ba1ddd --- editor/svgcanvas.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/editor/svgcanvas.js b/editor/svgcanvas.js index c6d579ad..eb72b0bf 100644 --- a/editor/svgcanvas.js +++ b/editor/svgcanvas.js @@ -3051,8 +3051,8 @@ function BatchCommand(text) { orphans.push(child); } } - // if child has a bbox (i.e. not a element), then it is an orphan - else if(child.getBBox) { + // if child has a bbox (i.e. not a <title> or <defs> element), then it is an orphan + else if(canvas.getBBox(child)) { orphans.push(child); } } @@ -3712,13 +3712,15 @@ function BatchCommand(text) { this.getBBox = function(elem) { var selected = elem || selectedElements[0]; - + if (elem.nodeType != 1) return null; + var ret = null; if(elem.nodeName == 'text' && selected.textContent == '') { selected.textContent = 'a'; // Some character needed for the selector to use. - var ret = selected.getBBox(); + ret = selected.getBBox(); selected.textContent = ''; } else { - var ret = selected.getBBox(); + try { ret = selected.getBBox(); } + catch(e) { ret = null; } } // get the bounding box from the DOM (which is in that element's coordinate system)