Skip to content

Commit 5b76bb5

Browse files
authored
Added HTML white list
I renamed the preserveEmpty option to html, because this is mainly useful for HTML files. Every tag that is from type br, img, input, link and meta won't be output in the longer form when html option is specified. However the whitelist array might be obsolete, but I'll do further testing with it :)
1 parent 9ce0b30 commit 5b76bb5

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/xmldoc.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,14 @@ XmlElement.prototype.toStringWithIndent = function(indent, options) {
175175

176176
s += indent + "</" + this.name + ">";
177177
}
178-
else s += options && options.preserveEmpty ? "></" + this.name + ">" : "/>";
178+
else if (options && options.html) {
179+
var whiteList = ["br", "img", "input", "link", "meta"];
180+
if (whiteList.indexOf(this.name) !== -1) s += "/>";
181+
else s += "></" + this.name + ">";
182+
}
183+
else {
184+
s += "/>";
185+
}
179186

180187
return s;
181188
};

0 commit comments

Comments
 (0)