@@ -6,13 +6,24 @@ import {
66 ReactHTML ,
77 Attributes ,
88} from 'react' ;
9- import { incorporate } from './incorporate' ;
10- import { hasModuleProps } from './Modulizer' ;
9+ import { incorporate , setIncorporator } from './incorporate' ;
10+ import { setModules , hasModuleProps , Modulizer } from './Modulizer' ;
11+ import Incorporator from './Incorporator' ;
1112
1213export type PropsExtensions = {
1314 sel ?: string | symbol ;
1415} ;
1516
17+ let shouldIncorporate = props => props . sel
18+
19+ export function useModules ( modules : any ) {
20+ if ( ! modules || typeof modules !== 'object' ) return
21+
22+ setModules ( modules ) ;
23+ shouldIncorporate = props => props . sel || hasModuleProps ( props )
24+ setIncorporator ( Modulizer )
25+ }
26+
1627type PropsLike < P > = P & PropsExtensions & Attributes ;
1728
1829type Children = string | Array < ReactNode > ;
@@ -33,7 +44,7 @@ function hyperscriptProps<P = any>(
3344 type : ReactType < P > | keyof ReactHTML ,
3445 props : PropsLike < P > ,
3546) : ReactElement < P > {
36- if ( ! props . sel && ! hasModuleProps ( props ) ) {
47+ if ( ! shouldIncorporate ( props ) ) {
3748 return createElement ( type , props ) ;
3849 } else {
3950 return createElement ( incorporate ( type ) , props ) ;
@@ -52,7 +63,7 @@ function hyperscriptPropsChildren<P = any>(
5263 props : PropsLike < P > ,
5364 children : Children ,
5465) : ReactElement < P > {
55- if ( ! props . sel && ! hasModuleProps ( props ) ) {
66+ if ( ! shouldIncorporate ( props ) ) {
5667 return createElementSpreading ( type , props , children ) ;
5768 } else {
5869 return createElementSpreading ( incorporate ( type ) , props , children ) ;
0 commit comments