File tree Expand file tree Collapse file tree 1 file changed +13
-16
lines changed Expand file tree Collapse file tree 1 file changed +13
-16
lines changed Original file line number Diff line number Diff line change @@ -12,18 +12,16 @@ const ClayPortalContext = React.createContext<React.RefObject<Element | null> |
1212
1313ClayPortalContext . displayName = 'ClayPortalContext' ;
1414
15- const createElement = (
16- nodeName : string ,
17- attributes : Record < string , string >
18- ) => {
19- const element = document . createElement ( nodeName ) ;
20-
21- Object . keys ( attributes ) . forEach ( ( key ) => {
22- element . setAttribute (
23- key === 'className' ? 'class' : key ,
24- attributes [ key ]
25- ) ;
26- } ) ;
15+ const createDivElement = ( className ?: string , id ?: string ) => {
16+ const element = document . createElement ( 'div' ) ;
17+
18+ if ( className ) {
19+ element . setAttribute ( 'class' , className ) ;
20+ }
21+
22+ if ( id ) {
23+ element . setAttribute ( 'id' , id ) ;
24+ }
2725
2826 return element ;
2927} ;
@@ -54,16 +52,15 @@ interface IProps {
5452
5553export const ClayPortal : React . FunctionComponent < IProps > = ( {
5654 children,
55+ className,
5756 containerRef,
57+ id,
5858 subPortalRef,
59- ...otherProps
6059} ) => {
6160 const parentPortalRef = React . useContext ( ClayPortalContext ) ;
6261
6362 const portalRef = React . useRef (
64- typeof document !== 'undefined'
65- ? createElement ( 'div' , otherProps as Record < string , string > )
66- : null
63+ typeof document !== 'undefined' ? createDivElement ( className , id ) : null
6764 ) ;
6865
6966 React . useEffect ( ( ) => {
You can’t perform that action at this time.
0 commit comments