Fix "xmlns" Identification

The previous code did not account for "xmlns=" in self-closing elements
(it only identified "xmlns:"). But the indent counter identified both,
which caused the odd nesting behavior.

Fixes #87
This commit is contained in:
Josh Johnson 2017-06-20 23:30:54 -04:00
parent 3f7ee2773b
commit 157bafa5b9
1 changed files with 2 additions and 2 deletions

View File

@ -83,12 +83,12 @@ export class XmlFormatter {
}
// <elm />
else if (parts[i].search(/\/>/) > -1 && (!this.splitNamespaces || parts[i].search(/xmlns\:/) == -1)) {
else if (parts[i].search(/\/>/) > -1 && (!this.splitNamespaces || parts[i].search(/xmlns(:|=)/) == -1)) {
output = (!inComment) ? output += this._getIndent(level, parts[i]) : output += parts[i];
}
// xmlns />
else if (parts[i].search(/\/>/) > -1 && parts[i].search(/xmlns\:/) > -1 && this.splitNamespaces) {
else if (parts[i].search(/\/>/) > -1 && parts[i].search(/xmlns(:|=)/) > -1 && this.splitNamespaces) {
output = (!inComment) ? output += this._getIndent(level--, parts[i]) : output += parts[i];
}