1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-10-01 00:10:45 +00:00

Fixed problem with element child nodes being created during cloning

This commit is contained in:
Jeremy Ruston 2012-05-02 17:26:55 +01:00
parent 52a6b1036c
commit ff8ef8b8d2

View File

@ -17,7 +17,7 @@ var Element = function(type,attributes,children) {
if(this instanceof Element) {
this.type = type;
this.attributes = attributes || {};
this.children = children || [];
this.children = children;
} else {
return new Element(type,attributes,children);
}
@ -27,16 +27,21 @@ Element.prototype = new Node();
Element.prototype.constructor = Element;
Element.prototype.clone = function() {
var childClones = [];
for(var t=0; t<this.children.length; t++) {
childClones.push(this.children[t].clone());
var childClones;
if(this.children) {
childClones = [];
for(var t=0; t<this.children.length; t++) {
childClones.push(this.children[t].clone());
}
}
return new Element(this.type,this.attributes,childClones);
};
Element.prototype.execute = function(parents,tiddlerTitle) {
for(var t=0; t<this.children.length; t++) {
this.children[t].execute(parents,tiddlerTitle);
if(this.children) {
for(var t=0; t<this.children.length; t++) {
this.children[t].execute(parents,tiddlerTitle);
}
}
};