diff --git a/src/parse-result.test.ts b/src/parse-result.test.ts index 978cf07c..27ee801e 100644 --- a/src/parse-result.test.ts +++ b/src/parse-result.test.ts @@ -1257,6 +1257,14 @@ describe('ember-template-recast', function () { expect(print(ast)).toEqual('
'); }); + + test('quotes are preserved when updating an AttrNode name - issue #319', function () { + let template = '
'; + + let ast = parse(template) as any; + ast.body[0].attributes[0].name = 'class'; + expect(print(ast)).toEqual('
'); + }); }); describe('HashPair', function () { diff --git a/src/parse-result.ts b/src/parse-result.ts index 966f0cdc..ae56abc5 100644 --- a/src/parse-result.ts +++ b/src/parse-result.ts @@ -961,6 +961,10 @@ export default class ParseResult { const wasQuotableValue = attrNode.value.type === 'TextNode'; if (dirtyFields.has('name')) { + if (!wasQuotableValue) { + quote = ''; + } + nameSource = ast.name; dirtyFields.delete('name');