1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-12-28 02:50:27 +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) { if(this instanceof Element) {
this.type = type; this.type = type;
this.attributes = attributes || {}; this.attributes = attributes || {};
this.children = children || []; this.children = children;
} else { } else {
return new Element(type,attributes,children); return new Element(type,attributes,children);
} }
@ -27,16 +27,21 @@ Element.prototype = new Node();
Element.prototype.constructor = Element; Element.prototype.constructor = Element;
Element.prototype.clone = function() { Element.prototype.clone = function() {
var childClones = []; var childClones;
for(var t=0; t<this.children.length; t++) { if(this.children) {
childClones.push(this.children[t].clone()); childClones = [];
for(var t=0; t<this.children.length; t++) {
childClones.push(this.children[t].clone());
}
} }
return new Element(this.type,this.attributes,childClones); return new Element(this.type,this.attributes,childClones);
}; };
Element.prototype.execute = function(parents,tiddlerTitle) { Element.prototype.execute = function(parents,tiddlerTitle) {
for(var t=0; t<this.children.length; t++) { if(this.children) {
this.children[t].execute(parents,tiddlerTitle); for(var t=0; t<this.children.length; t++) {
this.children[t].execute(parents,tiddlerTitle);
}
} }
}; };