@@ -13,7 +13,10 @@ const RESERVED_SVG_MATHML_ELEMENTS = new Set([
13
13
'font-face-format' ,
14
14
'font-face-name' ,
15
15
'missing-glyph' ,
16
- ] ) ;
16
+ ] as const ) ;
17
+
18
+ type ReservedSvgMathmlElements =
19
+ typeof RESERVED_SVG_MATHML_ELEMENTS extends Set < infer T > ? T : never ;
17
20
18
21
/**
19
22
* Check if a tag is a custom component.
@@ -26,7 +29,7 @@ const RESERVED_SVG_MATHML_ELEMENTS = new Set([
26
29
*/
27
30
export function isCustomComponent (
28
31
tagName : string ,
29
- props ?: Record < string , any > ,
32
+ props ?: Record < PropertyKey , any > ,
30
33
) : boolean {
31
34
if ( tagName . indexOf ( '-' ) === - 1 ) {
32
35
return Boolean ( props && typeof props . is === 'string' ) ;
@@ -36,7 +39,7 @@ export function isCustomComponent(
36
39
// We don't mind this whitelist too much because we expect it to never grow.
37
40
// The alternative is to track the namespace in a few places which is convoluted.
38
41
// https://w3c.github.io/webcomponents/spec/custom/#custom-elements-core-concepts
39
- if ( RESERVED_SVG_MATHML_ELEMENTS . has ( tagName ) ) {
42
+ if ( RESERVED_SVG_MATHML_ELEMENTS . has ( tagName as ReservedSvgMathmlElements ) ) {
40
43
return false ;
41
44
}
42
45
@@ -88,7 +91,10 @@ export const ELEMENTS_WITH_NO_TEXT_CHILDREN = new Set([
88
91
'head' ,
89
92
'html' ,
90
93
'frameset' ,
91
- ] ) ;
94
+ ] as const ) ;
95
+
96
+ type ElementsWithNoTextChildren =
97
+ typeof ELEMENTS_WITH_NO_TEXT_CHILDREN extends Set < infer T > ? T : never ;
92
98
93
99
/**
94
100
* Checks if the given node can contain text nodes
@@ -97,7 +103,7 @@ export const ELEMENTS_WITH_NO_TEXT_CHILDREN = new Set([
97
103
* @returns - Whether the node can contain text nodes.
98
104
*/
99
105
export const canTextBeChildOfNode = ( node : Element ) =>
100
- ! ELEMENTS_WITH_NO_TEXT_CHILDREN . has ( node . name ) ;
106
+ ! ELEMENTS_WITH_NO_TEXT_CHILDREN . has ( node . name as ElementsWithNoTextChildren ) ;
101
107
102
108
/**
103
109
* Returns the first argument as is.
0 commit comments