Angle brackets in helper string argument terminates tag early and duplicates remaining tag text
Closed this issue · 2 comments
Recently, when working on a codemod I ran into an issue where some of our code had angle brackets in the string argument to a helper in a component argument. The resulting output incorrectly terminates this tag and duplicates a portion of the tag after the closing bracket. Here's an example test that will fail:
test('issue can handle angle brackets in modifier argument values', function () {
let template = `
<Select
@placeholder={{do-something ">> Some Text Here"}}
@options={{this.items}}
as |item|
>
{{item.name}}
</Select>
`;
let ast = parse(template);
traverse(ast, {
ElementNode(node) {
node.tag = `${node.tag}`;
},
});
expect(print(ast)).toEqual(template);
});
I've included a traverse
call with an artificial modification to trigger the issue. Even though nothing is really changed the output is as follows:
<Select
@placeholder={{do-something ">> Some Text Here"}}
@options={{this.items}}
as |item|>> Some Text Here"}}
@options={{this.items}}
as |item|>
{{item.name}}
</Select>
Note here the tag gets closed after as |item
and immediately followed by the 2nd angle bracket from the do-something
string argument and the remainder of the opening tag: as |item|>> Some Text Here"}}
.
I did look into seeing if more recent versions of the Glimmer packages would resolve the issue, but there are breaking changes from 0.84.3 and the next version, 0.85.0 (or any newer versions). It seems like a more significant refactor would be required to upgrade these packages.
I found that the issue was specific to cases with block params where it matches on >
for tag closing index without considering one could be present in a string before the true closing bracket. PR here: #996