Fix Formatter Regression
The changes made for #87 and #90 contributed to this regression. It affected any element with one or more attributes and text content. Fixes #109
This commit is contained in:
parent
60cf5e34ce
commit
ba248c4c8d
@ -36,7 +36,7 @@ export class XmlFormatter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let parts: string[] = xml.split('~::~');
|
let parts: string[] = xml.split('~::~');
|
||||||
|
console.log(parts);
|
||||||
let inComment: boolean = false;
|
let inComment: boolean = false;
|
||||||
let level: number = 0;
|
let level: number = 0;
|
||||||
let output: string = '';
|
let output: string = '';
|
||||||
@ -61,7 +61,7 @@ export class XmlFormatter {
|
|||||||
|
|
||||||
// <elm></elm>
|
// <elm></elm>
|
||||||
else if (/^<(\w|:)/.test(parts[i - 1]) && /^<\/(\w|:)/.test(parts[i])
|
else if (/^<(\w|:)/.test(parts[i - 1]) && /^<\/(\w|:)/.test(parts[i])
|
||||||
&& /^<[\w:\-\.\,\/ ]+/.exec(parts[i - 1])[0] == /^<\/[\w:\-\.\, ]+/.exec(parts[i])[0].replace('/', '')) {
|
&& /^<[\w:\-\.\,\/]+/.exec(parts[i - 1])[0] == /^<\/[\w:\-\.\,]+/.exec(parts[i])[0].replace('/', '')) {
|
||||||
|
|
||||||
output += parts[i];
|
output += parts[i];
|
||||||
if (!inComment) level--;
|
if (!inComment) level--;
|
||||||
@ -98,7 +98,7 @@ export class XmlFormatter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// xmlns
|
// xmlns
|
||||||
else if (parts[i].search(/xmlns\:/) > -1 || parts[i].search(/xmlns\=/) > -1) {
|
else if (this.splitNamespaces && (parts[i].search(/xmlns\:/) > -1 || parts[i].search(/xmlns\=/) > -1)) {
|
||||||
output += this._getIndent(level, parts[i]);
|
output += this._getIndent(level, parts[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user