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

Lines changed: 5 additions & 0 deletions
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

Lines changed: 2 additions & 1 deletion
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 4 additions & 4 deletions
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy