-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathjsxFactory.ts
More file actions
36 lines (32 loc) · 820 Bytes
/
jsxFactory.ts
File metadata and controls
36 lines (32 loc) · 820 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import {createElement, ReactElement, ReactType} from 'react';
import {incorporate} from './incorporate';
export {Attributes} from 'react';
declare global {
namespace JSX {
interface IntrinsicAttributes {
sel?: string | symbol;
}
}
namespace React {
interface ClassAttributes<T> extends Attributes {
sel?: string | symbol;
}
}
}
type PropsExtensions = {
sel?: string | symbol;
}
function createIncorporatedElement<P = any>(
type: ReactType<P>,
props: P & PropsExtensions | null,
...children: Array<string | ReactElement<any>>
): ReactElement<P> {
if (!props || !props.sel) {
return createElement(type, props, ...children);
} else {
return createElement(incorporate(type), props, ...children);
}
}
export default {
createElement: createIncorporatedElement
}