Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Fixes issue #1124 & #1059 #1188

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion src/jqLite.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,36 @@ function JQLite(element) {
}
}

function JQLiteCloneData(src, dst) {
if (src.nodeType !== 1 || !jqLite.hasData(src))
return;

var data = jqLite(src).data();

forEach(data, function(value, key){
jqLite(dst).data(key, value);
});
}

function JQLiteClone(element) {
return element.cloneNode(true);
var clone = element.cloneNode(true);

if (element.nodeType !== 1)
return clone;

JQLiteCloneData(element, clone);

var getAll = element.getElementsByTagName || element.querySelectorAll || function(){return []},
srcAll = getAll.call(element, '*'),
dstAll = getAll.call(clone, '*');

for(var i = 0 ; i < srcAll.length ; i++) {
var src = srcAll[i],
dst = dstAll[i];
JQLiteCloneData(src, dst);
}

return clone;
}

function JQLiteDealoc(element){
Expand Down
2 changes: 1 addition & 1 deletion src/ng/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ function $CompileProvider($provide) {
// We can not compile top level text elements since text nodes can be merged and we will
// not be able to attach scope data to them, so we will wrap them in <span>
forEach($compileNode, function(node, index){
if (node.nodeType == 3 /* text node */) {
if (node.nodeType == 3 /* text node */ && node.childNodes.length /* non-empty */) {
$compileNode[index] = jqLite(node).wrap('<span>').parent()[0];
}
});
Expand Down