do not change nodes if not needed

This commit is contained in:
Andrea Giammarchi
2015-03-12 20:41:20 +00:00
parent 39a091da4b
commit 92d5bea1ab
5 changed files with 21 additions and 12 deletions

View File

@ -327,6 +327,7 @@ define(function () {
var
allText = grabAllTextNodes(node, []),
length = allText.length,
modified = false,
fragment,
subnode,
text,
@ -367,13 +368,15 @@ define(function () {
img.setAttribute('draggable', 'false');
img.alt = alt;
img.src = src;
modified = true;
fragment.appendChild(img);
}
}
fragment.appendChild(img || createText(alt));
if (!img) fragment.appendChild(createText(alt));
img = null;
}
// is there actually anything to replace in here ?
if (0 < i) {
if (modified) {
// any text left to be added ?
if (i < text.length) {
fragment.appendChild(