Skip to content

Commit bdf033e

Browse files
authored
fix: allow self-closing tags within math namespace (#15761)
fixes #15757
1 parent de43762 commit bdf033e

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

.changeset/wicked-cheetahs-juggle.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: allow self-closing tags within math namespace

packages/svelte/src/compiler/phases/2-analyze/visitors/RegularElement.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,8 @@ export function RegularElement(node, context) {
173173
if (
174174
context.state.analysis.source[node.end - 2] === '/' &&
175175
!is_void(node_name) &&
176-
!is_svg(node_name)
176+
!is_svg(node_name) &&
177+
!is_mathml(node_name)
177178
) {
178179
w.element_invalid_self_closing_tag(node, node.name);
179180
}

packages/svelte/tests/validator/samples/invalid-self-closing-tag/input.svelte

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<!-- valid -->
22
<link />
33
<svg><g /></svg>
4+
<math><mspace /></math>
45
<enhanced:img />
56

67

packages/svelte/tests/validator/samples/invalid-self-closing-tag/warnings.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,23 @@
33
"code": "element_invalid_self_closing_tag",
44
"message": "Self-closing HTML tags for non-void elements are ambiguous — use `<div ...></div>` rather than `<div ... />`",
55
"start": {
6-
"line": 8,
6+
"line": 9,
77
"column": 0
88
},
99
"end": {
10-
"line": 8,
10+
"line": 9,
1111
"column": 7
1212
}
1313
},
1414
{
1515
"code": "element_invalid_self_closing_tag",
1616
"message": "Self-closing HTML tags for non-void elements are ambiguous — use `<my-thing ...></my-thing>` rather than `<my-thing ... />`",
1717
"start": {
18-
"line": 9,
18+
"line": 10,
1919
"column": 0
2020
},
2121
"end": {
22-
"line": 9,
22+
"line": 10,
2323
"column": 12
2424
}
2525
}

0 commit comments

Comments
 (0)