This repository was archived by the owner on Dec 15, 2022. It is now read-only.
Fix close-tag for JSX tags with member access #396
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
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