Skip to content

Commit

Permalink
Merge pull request #1790 from riganti/fix-js-memberaccessindexer
Browse files Browse the repository at this point in the history
JS translator: fix member access formatted as indexer
  • Loading branch information
tomasherceg committed Mar 8, 2024
2 parents 9b5f9dd + 6bc3634 commit cae2bbe
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public void VisitMemberAccessExpression(JsMemberAccessExpression memberAccessExp
{
EmitComment(memberAccessExpression.CommentBefore);
if (!memberAccessExpression.MemberNameToken.IsValidName())
new JsIndexerExpression(memberAccessExpression.Target.Clone(), new JsLiteral(memberAccessExpression.MemberNameToken))
new JsIndexerExpression(memberAccessExpression.Target.Clone(), new JsLiteral(memberAccessExpression.MemberName))
.AcceptVisitor(this);
else
{
Expand Down
6 changes: 6 additions & 0 deletions src/Tests/Runtime/JavascriptCompilation/JsFormatterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ public void JsFormatter_MemberAccess()
AssertFormatting("a.b.c", new JsIdentifierExpression("a").Member("b").Member("c"));
}

[TestMethod]
public void JsFormatter_MemberAccessIndexer()
{
AssertFormatting("a['']['some-name'].if.$type['12']['1x']['a\u200Bb']".Replace('\'', '"'), new JsIdentifierExpression("a").Member("").Member("some-name").Member("if").Member("$type").Member("12").Member("1x").Member("a\u200Bb"));
}

[TestMethod]
public void JsFormatter_Invocation()
{
Expand Down

0 comments on commit cae2bbe

Please sign in to comment.