From e298a4a95de93951eee23d33ba7e8d1387a90a5b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Aleksander=20=C5=81ukasz?= Date: Thu, 16 Jan 2014 15:37:43 +0100 Subject: [PATCH] smartxml: data cloning handler gets reference to the cloned node --- src/smartxml/smartxml.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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)); } }); }); -- 2.20.1