Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Conversation

@MoritzKn
Copy link
Contributor

@MoritzKn MoritzKn commented May 8, 2020

Description of the Change

Adjust the regex used to find matching tags. The regex was extended to support a dot (.) in the middle of the tag so that member access in JSX is now supported (e.g. <Grid.Row>). To support deep member access the existing suffix part of the regex was changed from zero or once ? to N times *. This now also enables deep nesting of XML namespaces (<custom:test:tag>).

I also added a test case containing attributes. I didn't change anything about that but I wanted to make sure that that behavior is tested.

Alternate Designs

To my knowledge deep nesting of XML namespace is not valid. So we could have just not allowed it but this way the regex stays simpler.

In addition, using deeply nested XML namespaces would have resulted in strange behavior. Now it is what the user would expect. I.e. just closing the tag no matter what.

Benefits

JSX Tags with member access can now be closed. Before the change:

<Foo.Bar>
/* closing the tag here resulted in </Foo> instead of </Foo.Bar>  */
<div>
<Foo.Bar></Foo.Bar>
/* closing the tag here resulted in </Foo> instead of </div> */

Possible Drawbacks

This should have no performance impact but might perhaps break tag matching in some cases.
I can't think of anything and all tests are passing but regexes are fragile.

Applicable Issues

No issue yet

@sadick254 sadick254 merged commit 00d1543 into atom:master May 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants