Skip to content

Commit d7589e2

Browse files
Refactor JSX fragment
1 parent 52d132c commit d7589e2

File tree

1 file changed

+4
-20
lines changed

1 file changed

+4
-20
lines changed

TypeScriptReact.YAML-tmLanguage

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -28,36 +28,21 @@ repository:
2828
patterns:
2929
- include: '#jsx-tag-without-attributes-in-expression'
3030
- include: '#jsx-tag-in-expression'
31-
- include: '#jsx-fragment'
3231

3332
#jsx tags
34-
jsx-fragment:
35-
name: meta.tag.fragment.tsx
36-
begin: (<)\s*(>)
37-
end: (</)\s*(>)
38-
beginCaptures:
39-
'1': {name: punctuation.definition.tag.begin.tsx}
40-
'2': {name: punctuation.definition.tag.end.tsx}
41-
endCaptures:
42-
'1': {name: punctuation.definition.tag.begin.tsx}
43-
'2': {name: punctuation.definition.tag.end.tsx}
44-
contentName: meta.jsx.children.tsx
45-
patterns:
46-
- include: '#jsx-children'
47-
4833
jsx-tag-without-attributes-in-expression:
4934
begin: |-
5035
(?x)
5136
(?<=[({\[,?=>:*]|&&|\|\||\?|\Wreturn|^return|\Wdefault|^)\s*
52-
(?=(<)\s*((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\w.]*))(?<!\.|-))\s*(>))
53-
end: (?!\s*(<)\s*((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\w.]*))(?<!\.|-))\s*(>))
37+
(?=(<)\s*((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\w.]*))(?<!\.|-))?\s*(>))
38+
end: (?!\s*(<)\s*((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\w.]*))(?<!\.|-))?\s*(>))
5439
patterns:
5540
- include: '#jsx-tag-without-attributes'
5641

5742
jsx-tag-without-attributes:
5843
name: meta.tag.without-attributes.tsx
59-
begin: (<)\s*((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\w.]*))(?<!\.|-))\s*(>)
60-
end: (</)\s*((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\w.]*))(?<!\.|-))\s*(>)
44+
begin: (<)\s*((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\w.]*))(?<!\.|-))?\s*(>)
45+
end: (</)\s*((?:[a-z][a-z0-9]*|([_$a-zA-Z][-$\w.]*))(?<!\.|-))?\s*(>)
6146
beginCaptures:
6247
'1': {name: punctuation.definition.tag.begin.tsx}
6348
'2': {name: entity.name.tag.tsx}
@@ -147,7 +132,6 @@ repository:
147132
patterns:
148133
- include: '#jsx-tag-without-attributes'
149134
- include: '#jsx-child-tag'
150-
- include: '#jsx-fragment'
151135
- include: '#jsx-evaluated-code'
152136
- include: '#jsx-entities'
153137

0 commit comments

Comments
 (0)