Skip to content
Open
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
26 changes: 11 additions & 15 deletions src/prototype/dom/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,13 @@
return isBuggy;
})();

function updateNodes(element, nodes) {
while (element.firstChild)
element.removeChild(element.firstChild);
for (var i = 0, node; node = nodes[i]; i++)
element.appendChild(node);
}

/**
* Element.update(@element[, newContent]) -> Element
*
Expand Down Expand Up @@ -664,26 +671,15 @@

if (ANY_INNERHTML_BUGGY) {
if (tagName in INSERTION_TRANSLATIONS.tags) {
while (element.firstChild)
element.removeChild(element.firstChild);

var nodes = getContentFromAnonymousElement(tagName, content.stripScripts());
for (var i = 0, node; node = nodes[i]; i++)
element.appendChild(node);

updateNodes(element, getContentFromAnonymousElement(tagName,
content.stripScripts()));
} else if (LINK_ELEMENT_INNERHTML_BUGGY && Object.isString(content) && content.indexOf('<link') > -1) {
// IE barfs when inserting a string that beings with a LINK
// element. The workaround is to add any content to the beginning
// of the string; we'll be inserting a text node (see
// getContentFromAnonymousElement below).
while (element.firstChild)
element.removeChild(element.firstChild);

var nodes = getContentFromAnonymousElement(tagName,
content.stripScripts(), true);

for (var i = 0, node; node = nodes[i]; i++)
element.appendChild(node);
updateNodes(element, getContentFromAnonymousElement(tagName,
content.stripScripts(), true));
} else {
element.innerHTML = content.stripScripts();
}
Expand Down