@@ -13,7 +13,10 @@ const RESERVED_SVG_MATHML_ELEMENTS = new Set([
1313 'font-face-format' ,
1414 'font-face-name' ,
1515 'missing-glyph' ,
16- ] ) ;
16+ ] as const ) ;
17+
18+ type ReservedSvgMathmlElements =
19+ typeof RESERVED_SVG_MATHML_ELEMENTS extends Set < infer T > ? T : never ;
1720
1821/**
1922 * Check if a tag is a custom component.
@@ -26,7 +29,7 @@ const RESERVED_SVG_MATHML_ELEMENTS = new Set([
2629 */
2730export function isCustomComponent (
2831 tagName : string ,
29- props ?: Record < string , any > ,
32+ props ?: Record < PropertyKey , any > ,
3033) : boolean {
3134 if ( tagName . indexOf ( '-' ) === - 1 ) {
3235 return Boolean ( props && typeof props . is === 'string' ) ;
@@ -36,7 +39,7 @@ export function isCustomComponent(
3639 // We don't mind this whitelist too much because we expect it to never grow.
3740 // The alternative is to track the namespace in a few places which is convoluted.
3841 // 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 ) ) {
4043 return false ;
4144 }
4245
@@ -88,7 +91,10 @@ export const ELEMENTS_WITH_NO_TEXT_CHILDREN = new Set([
8891 'head' ,
8992 'html' ,
9093 'frameset' ,
91- ] ) ;
94+ ] as const ) ;
95+
96+ type ElementsWithNoTextChildren =
97+ typeof ELEMENTS_WITH_NO_TEXT_CHILDREN extends Set < infer T > ? T : never ;
9298
9399/**
94100 * Checks if the given node can contain text nodes
@@ -97,7 +103,7 @@ export const ELEMENTS_WITH_NO_TEXT_CHILDREN = new Set([
97103 * @returns - Whether the node can contain text nodes.
98104 */
99105export const canTextBeChildOfNode = ( node : Element ) =>
100- ! ELEMENTS_WITH_NO_TEXT_CHILDREN . has ( node . name ) ;
106+ ! ELEMENTS_WITH_NO_TEXT_CHILDREN . has ( node . name as ElementsWithNoTextChildren ) ;
101107
102108/**
103109 * Returns the first argument as is.
0 commit comments