Fix Attribute Quotes Regression

Issue: #187
This commit is contained in:
Josh Johnson 2018-06-11 18:40:54 -04:00
parent b50cdaea8e
commit 88de774389
1 changed files with 6 additions and 1 deletions

View File

@ -32,6 +32,7 @@ export class V2XmlFormatter implements XmlFormatter {
let indentLevel = 0; let indentLevel = 0;
let location = Location.Text; let location = Location.Text;
let lastNonTextLocation = Location.Text; // hah let lastNonTextLocation = Location.Text; // hah
let attributeQuote = "";
// NOTE: all "exiting" checks should appear after their associated "entering" checks // NOTE: all "exiting" checks should appear after their associated "entering" checks
for (let i = 0; i < xml.length; i++) { for (let i = 0; i < xml.length; i++) {
@ -126,13 +127,17 @@ export class V2XmlFormatter implements XmlFormatter {
output += cc; output += cc;
lastNonTextLocation = location; lastNonTextLocation = location;
location = Location.AttributeValue; location = Location.AttributeValue;
attributeQuote = cc;
} }
// exiting StartTag.Attribute.AttributeValue, entering StartTag // exiting StartTag.Attribute.AttributeValue, entering StartTag
else if (location === Location.AttributeValue && (cc === "\"" || cc === "'")) { else if (location === Location.AttributeValue && cc === attributeQuote) {
output += cc; output += cc;
lastNonTextLocation = location; lastNonTextLocation = location;
location = Location.StartTag; location = Location.StartTag;
attributeQuote = undefined;
} }
// approaching the end of a self-closing tag where there was no whitespace (issue #149) // approaching the end of a self-closing tag where there was no whitespace (issue #149)