@@ -13,23 +13,30 @@ const convertText = (el: Text): string =>
1313
1414const convertElement = async (
1515 el : Element ,
16- customElementHandler : CustomElementHandlerType ,
17- recursor : StaticToReactElementRecursor
18- ) =>
19- // If customElementHandler is truthy, use it; otherwise, just convert to a React element.
20- ( await customElementHandler ( el ) ) || staticToReactElement ( el , recursor ) ;
16+ recursor : StaticToReactElementRecursor ,
17+ customElementHandler ?: CustomElementHandlerType
18+ ) => {
19+ if ( customElementHandler ) {
20+ // If customElementHandler is truthy, use it; otherwise, just convert to a React element.
21+ return (
22+ ( await customElementHandler ( el ) ) || staticToReactElement ( el , recursor )
23+ ) ;
24+ }
25+
26+ return staticToReactElement ( el , recursor ) ;
27+ } ;
2128
2229const convert = async (
2330 el : Node ,
24- customElementHandler : CustomElementHandlerType
31+ customElementHandler ? : CustomElementHandlerType
2532) => {
2633 const recursor : StaticToReactElementRecursor = ( innerEl : Node ) =>
2734 convert ( innerEl , customElementHandler ) ;
2835
2936 if ( el . nodeType === Node . TEXT_NODE ) {
3037 return convertText ( el as Text ) ;
3138 } else if ( el . nodeType === Node . ELEMENT_NODE ) {
32- return convertElement ( el as Element , customElementHandler , recursor ) ;
39+ return convertElement ( el as Element , recursor , customElementHandler ) ;
3340 }
3441
3542 // Unhandled node type. Probably an HTML comment.
0 commit comments