X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/bd0c9397ecd0cccdc7af0f0b0153adf5126e1538..67d116b3f6f2b4a62f31433bd7b3cb85ecc0c171:/src/smartxml/smartxml.js?ds=sidebyside diff --git a/src/smartxml/smartxml.js b/src/smartxml/smartxml.js index e525c14..d168e6d 100644 --- a/src/smartxml/smartxml.js +++ b/src/smartxml/smartxml.js @@ -33,14 +33,17 @@ $.extend(DocumentNode.prototype, { }, clone: function() { - var clone = this._$.clone(true, true); + var clone = this._$.clone(true, true), + node = this; clone.find('*').addBack().each(function() { - var clonedData = $(this).data(); + var el = this, + clonedData = $(this).data(); + _.pairs(clonedData).forEach(function(pair) { var key = pair[0], value = pair[1]; if(_.isFunction(value.clone)) { - clonedData[key] = value.clone(); + clonedData[key] = value.clone(node.document.createDocumentNode(el)); } }); });