From 88de7743891b035fb42627d36939992bdd63969f Mon Sep 17 00:00:00 2001 From: Josh Johnson Date: Mon, 11 Jun 2018 18:40:54 -0400 Subject: [PATCH] Fix Attribute Quotes Regression Issue: #187 --- src/formatting/formatters/v2-xml-formatter.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/formatting/formatters/v2-xml-formatter.ts b/src/formatting/formatters/v2-xml-formatter.ts index bed5f8a..0d8af2a 100644 --- a/src/formatting/formatters/v2-xml-formatter.ts +++ b/src/formatting/formatters/v2-xml-formatter.ts @@ -32,6 +32,7 @@ export class V2XmlFormatter implements XmlFormatter { let indentLevel = 0; let location = Location.Text; let lastNonTextLocation = Location.Text; // hah + let attributeQuote = ""; // NOTE: all "exiting" checks should appear after their associated "entering" checks for (let i = 0; i < xml.length; i++) { @@ -126,13 +127,17 @@ export class V2XmlFormatter implements XmlFormatter { output += cc; lastNonTextLocation = location; location = Location.AttributeValue; + + attributeQuote = cc; } // exiting StartTag.Attribute.AttributeValue, entering StartTag - else if (location === Location.AttributeValue && (cc === "\"" || cc === "'")) { + else if (location === Location.AttributeValue && cc === attributeQuote) { output += cc; lastNonTextLocation = location; location = Location.StartTag; + + attributeQuote = undefined; } // approaching the end of a self-closing tag where there was no whitespace (issue #149)