Comparing version 3.0.4 to 3.0.5
@@ -26,2 +26,6 @@ var util = require('utils-extend'); | ||
function hasTag (tags) { | ||
return tags.find(item => item.type === 'tag') | ||
} | ||
module.exports = function(nodes, options) { | ||
@@ -49,3 +53,3 @@ var html = []; | ||
if (value) { | ||
html.push(newline + value); | ||
html.push(value); | ||
} | ||
@@ -59,3 +63,4 @@ break; | ||
} | ||
html.push(newline + '<!--' + dom.value + '-->'); | ||
html.push('<!--' + dom.value + '-->'); | ||
break; | ||
@@ -93,5 +98,14 @@ case 'tag': | ||
} else { | ||
dom.children.forEach(function(item) { | ||
html.push(recurse(item, depth + 1)); | ||
}); | ||
// Has children tag indent | ||
if (hasTag(dom.children)) { | ||
dom.children.forEach(function(item) { | ||
html.push(recurse(item, depth + 1)); | ||
}); | ||
} else { | ||
newline = '' | ||
dom.children.forEach(function(item) { | ||
html.push(recurse(item, depth)); | ||
}); | ||
} | ||
} | ||
@@ -105,2 +119,3 @@ html.push(newline + '</' + name + '>'); | ||
for (var i = 0, l = nodes.length; i < l; i++) { | ||
@@ -107,0 +122,0 @@ html.push(recurse(nodes[i], 0)); |
@@ -118,3 +118,3 @@ var REG = require('./reg'); | ||
var dom = { | ||
name: name.toLowerCase(), | ||
name: name, | ||
attributes: attrs | ||
@@ -177,3 +177,3 @@ }; | ||
type: 'closetag', | ||
name: tagname.toLowerCase() | ||
name: tagname | ||
}); | ||
@@ -180,0 +180,0 @@ return true; |
{ | ||
"name": "htmldom", | ||
"version": "3.0.4", | ||
"version": "3.0.5", | ||
"description": "Simplified html handle in nodejs", | ||
@@ -5,0 +5,0 @@ "main": "htmldom.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
87495
2400