Skip to content

Commit

Permalink
Merge pull request #555 from dcyriller/fix-319
Browse files Browse the repository at this point in the history
  • Loading branch information
rwjblue authored May 19, 2021
2 parents 2453c70 + 50e39ed commit a3e4315
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/parse-result.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1257,6 +1257,14 @@ describe('ember-template-recast', function () {

expect(print(ast)).toEqual('<div class="hahah {{foo}}"></div>');
});

test('quotes are preserved when updating an AttrNode name - issue #319', function () {
let template = '<div @class="{{if foo "bar"}} baz" />';

let ast = parse(template) as any;
ast.body[0].attributes[0].name = 'class';
expect(print(ast)).toEqual('<div class="{{if foo "bar"}} baz" />');
});
});

describe('HashPair', function () {
Expand Down
4 changes: 4 additions & 0 deletions src/parse-result.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit a3e4315

Please sign in to comment.