Fix Issue 159: loop the right way when cloning elements
git-svn-id: http://svg-edit.googlecode.com/svn/trunk@520 eee81c28-f429-11dd-99c0-75d572ba1dddmaster
parent
ee2e362b1a
commit
3557a0a94b
|
@ -2902,17 +2902,21 @@ function SvgCanvas(c)
|
|||
// this creates deep DOM copies (clones) of all selected elements
|
||||
this.cloneSelectedElements = function() {
|
||||
var batchCmd = new BatchCommand("Clone Elements");
|
||||
var copiedElements = [];
|
||||
var i = selectedElements.length;
|
||||
while(i--) {
|
||||
// find all the elements selected (stop at first null)
|
||||
var len = selectedElements.length;
|
||||
for (var i = 0; i < len; ++i) {
|
||||
var elem = selectedElements[i];
|
||||
if (elem == null) break;
|
||||
copiedElements.push(elem.cloneNode(true));
|
||||
}
|
||||
// use slice to quickly get the subset of elements we need
|
||||
var copiedElements = selectedElements.slice(0,i);
|
||||
this.clearSelection();
|
||||
var len = copiedElements.length;
|
||||
for (var i = 0; i < len; ++i) {
|
||||
var elem = copiedElements[i];
|
||||
// note that we loop in the reverse way because of the way elements are added
|
||||
// to the selectedElements array (top-first)
|
||||
var i = copiedElements.length;
|
||||
while (i--) {
|
||||
// clone each element and replace it within copiedElements
|
||||
var elem = copiedElements[i] = copiedElements[i].cloneNode(true);
|
||||
elem.removeAttribute("id");
|
||||
elem.id = getNextId();
|
||||
svgroot.appendChild(elem);
|
||||
|
|
Loading…
Reference in New Issue