test(sortedHtml): fix comment support in sortedHtml helper

This commit is contained in:
Igor Minar
2012-12-04 18:24:15 +01:00
parent 8f8510fc22
commit 9039ddbb56
2 changed files with 15 additions and 10 deletions

View File

@@ -91,11 +91,14 @@ function dealoc(obj) {
function sortedHtml(element, showNgClass) {
var html = "";
forEach(jqLite(element), function toString(node) {
if (node.nodeName == "#text") {
html += node.nodeValue.
replace(/&(\w+[&;\W])?/g, function(match, entity){return entity?match:'&';}).
replace(/</g, '&lt;').
replace(/>/g, '&gt;');
} else if (node.nodeName == "#comment") {
html += '<!--' + node.nodeValue + '-->';
} else {
html += '<' + (node.nodeName || '?NOT_A_NODE?').toLowerCase();
var attributes = node.attributes || [];