File tree Expand file tree Collapse file tree 4 files changed +16
-6
lines changed
src/compiler/phases/2-analyze
tests/validator/samples/invalid-self-closing-tag Expand file tree Collapse file tree 4 files changed +16
-6
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' svelte ' : patch
3
+ ---
4
+
5
+ fix: tweak element_invalid_self_closing_tag to exclude namespace
Original file line number Diff line number Diff line change @@ -636,11 +636,14 @@ const validation = {
636
636
}
637
637
}
638
638
639
+ // Strip off any namespace from the beginning of the node name.
640
+ const node_name = node . name . replace ( / [ a - z A - Z - ] * : / g, '' ) ;
641
+
639
642
if (
640
643
context . state . analysis . source [ node . end - 2 ] === '/' &&
641
644
context . state . options . namespace !== 'foreign' &&
642
- ! VoidElements . includes ( node . name ) &&
643
- ! SVGElements . includes ( node . name )
645
+ ! VoidElements . includes ( node_name ) &&
646
+ ! SVGElements . includes ( node_name )
644
647
) {
645
648
w . element_invalid_self_closing_tag ( node , node . name ) ;
646
649
}
Original file line number Diff line number Diff line change 1
1
<!-- valid -->
2
2
<link />
3
3
<svg ><g /></svg >
4
+ <enhanced:img />
5
+
4
6
5
7
<!-- invalid -->
6
8
<div />
Original file line number Diff line number Diff line change 3
3
"code" : " element_invalid_self_closing_tag" ,
4
4
"message" : " Self-closing HTML tags for non-void elements are ambiguous — use `<div ...></div>` rather than `<div ... />`" ,
5
5
"start" : {
6
- "line" : 6 ,
6
+ "line" : 8 ,
7
7
"column" : 0
8
8
},
9
9
"end" : {
10
- "line" : 6 ,
10
+ "line" : 8 ,
11
11
"column" : 7
12
12
}
13
13
},
14
14
{
15
15
"code" : " element_invalid_self_closing_tag" ,
16
16
"message" : " Self-closing HTML tags for non-void elements are ambiguous — use `<my-thing ...></my-thing>` rather than `<my-thing ... />`" ,
17
17
"start" : {
18
- "line" : 7 ,
18
+ "line" : 9 ,
19
19
"column" : 0
20
20
},
21
21
"end" : {
22
- "line" : 7 ,
22
+ "line" : 9 ,
23
23
"column" : 12
24
24
}
25
25
}
You can’t perform that action at this time.
0 commit comments