ember-template-lint / ember-template-recast

Non-destructive template transformer.
MIT License
40 stars 38 forks source link

Changing attr value from text node to mustache generates erroneous quotes #139

Closed timlindvall closed 4 years ago

timlindvall commented 4 years ago

Crumbs... looks like fixing #111 might have caused the opposite case to fail. T_T

    QUnit.test('changing an attribute value from text node to mustache', function(assert) {
      let template = `<FooBar @foo="Hi, I'm a string!" @baz="This is also a string!" @bar={{1234}} />`;

      let ast = parse(template);
      ast.body[0].attributes[0].value = builders.mustache('my-awesome-helper', [
        builders.string("hello"),
        builders.string("world")
      ]);
      ast.body[0].attributes[1].value = builders.mustache('my-awesome-helper', [
        builders.string("hello"),
        builders.string("world")
      ]);
      ast.body[0].attributes[2].value = builders.mustache('my-awesome-helper', [
        builders.string("hello"),
        builders.string("world")
      ]);

      assert.equal(print(ast), `<FooBar @foo={{my-awesome-helper "hello" "world"}} @baz={{my-awesome-helper "hello" "world"}} @bar={{my-awesome-helper "hello" "world"}} />`);
    });
not ok 24 ember-template-recast > ElementNode > changing an attribute value from text node to mustache
  ---
  message: "failed"
  severity: failed
  actual: "<FooBar @foo=\"{{my-awesome-helper \"hello\" \"world\"}}\" @baz=\"{{my-awesome-helper \"hello\" \"world\"}}\" @bar={{my-awesome-helper \"hello\" \"world\"}} />"
  expected: "<FooBar @foo={{my-awesome-helper \"hello\" \"world\"}} @baz={{my-awesome-helper \"hello\" \"world\"}} @bar={{my-awesome-helper \"hello\" \"world\"}} />"
  ...
rwjblue commented 4 years ago

Thanks for reporting (and working on the fix), I should have thought about this when I implemented the fix for #111. Sorry about that :(